src/Pure/General/linear_set.ML
changeset 44476 e8a87398f35d
parent 38448 62d16c415019
child 44479 9a04e7502e22
equal deleted inserted replaced
44475:709e1d671483 44476:e8a87398f35d
    12   exception UNDEFINED of key
    12   exception UNDEFINED of key
    13   exception NEXT_UNDEFINED of key option
    13   exception NEXT_UNDEFINED of key option
    14   val empty: 'a T
    14   val empty: 'a T
    15   val is_empty: 'a T -> bool
    15   val is_empty: 'a T -> bool
    16   val defined: 'a T -> key -> bool
    16   val defined: 'a T -> key -> bool
    17   val lookup: 'a T -> key -> 'a option
    17   val lookup: 'a T -> key -> ('a * key option) option
    18   val update: key * 'a -> 'a T -> 'a T
    18   val update: key * 'a -> 'a T -> 'a T
    19   val fold: key option ->
    19   val fold: key option ->
    20     ((key option * key) * 'a -> 'b -> 'b) -> 'a T -> 'b -> 'b
    20     ((key option * key) * 'a -> 'b -> 'b) -> 'a T -> 'b -> 'b
    21   val get_first: key option ->
    21   val get_first: key option ->
    22     ((key option * key) * 'a -> bool) -> 'a T -> ((key option * key) * 'a) option
    22     ((key option * key) * 'a -> bool) -> 'a T -> ((key option * key) * 'a) option
    68 val empty = Set {start = NONE, entries = Table.empty};
    68 val empty = Set {start = NONE, entries = Table.empty};
    69 fun is_empty set = is_none (start_of set);
    69 fun is_empty set = is_none (start_of set);
    70 
    70 
    71 fun defined set key = Table.defined (entries_of set) key;
    71 fun defined set key = Table.defined (entries_of set) key;
    72 
    72 
    73 fun lookup set key = Option.map fst (Table.lookup (entries_of set) key);
    73 fun lookup set key = Table.lookup (entries_of set) key;
    74 
    74 
    75 fun update (key, x) = map_set (fn (start, entries) =>
    75 fun update (key, x) = map_set (fn (start, entries) =>
    76   (start, put_entry (key, (x, next_entry entries key)) entries));
    76   (start, put_entry (key, (x, next_entry entries key)) entries));
    77 
    77 
    78 
    78