## numbered-set.api
# Compiled by:
#
src/lib/std/standard.lib# Compare to:
#
src/lib/src/tagged-numbered-list.api#
src/lib/src/numbered-list.api#
src/lib/src/map.api#
src/lib/src/set.api# This api is implemented in:
#
src/lib/src/red-black-numbered-set-g.pkg# Given a set of keys, assign (and maintain) consecutive integer tags
# starting at zero.
api Numbered_Set {
package key: Key; # Key is from
src/lib/src/key.api Numbered_Set;
empty: Numbered_Set; # The empty numbering
is_empty: Numbered_Set -> Bool; # Return TRUE if and only if the numbering is empty
from_list: List( key::Key ) -> Numbered_Set; # Build a Numbered_Set from the contents of a list.
singleton: key::Key -> Numbered_Set; # return the specified singleton numbering
set: (Numbered_Set, key::Key) -> Numbered_Set;
set' : (key::Key, Numbered_Set) -> Numbered_Set;
($): (Numbered_Set, key::Key) -> Numbered_Set;
# Insert an item.
find # Look for an item, return NULL if the item doesn't exist
:
(Numbered_Set, key::Key)
->
Null_Or( Int );
contains_key # Return TRUE, iff the key is in the domain of the numbering
:
((Numbered_Set, key::Key))
->
Bool;
remove # Remove an item, returning new numbering and value removed.
: # Raises lib_base::NOT_FOUND if not found.
(Numbered_Set, key::Key)
->
(Numbered_Set, Int);
first_key_else_null: Numbered_Set -> Null_Or( key::Key );
# return the first item in the numbering (or NULL if it is empty)
vals_count: Numbered_Set -> Int;
# Return the number of items in the numbering
keys_list: Numbered_Set -> List key::Key;
# return an ordered list of the keys in the numbering.
union_with: ((X, X) -> X) -> ((Numbered_Set, Numbered_Set)) -> Numbered_Set;
keyed_union_with: ((key::Key, X, X) -> X) -> ((Numbered_Set, Numbered_Set)) -> Numbered_Set;
# return a numbering whose domain is the union of the domains of the two input
# numberings, using the supplied function to define the numbering on elements that
# are in both domains.
intersect_with: ((X, Y) -> Z) -> ((Numbered_Set, Numbered_Set)) -> Numbered_Set;
keyed_intersect_with: ((key::Key, X, Y) -> Z) -> ((Numbered_Set, Numbered_Set)) -> Numbered_Set;
# return a numbering whose domain is the intersection of the domains of the
# two input numberings, using the supplied function to define the range.
apply: (key::Key -> Void) -> Numbered_Set -> Void;
keyed_apply: (((key::Key, Int)) -> Void) -> Numbered_Set -> Void;
# Apply a function to the entries of the numbering in numbering order.
fold_forward: ((key::Key, Y) -> Y) -> Y -> Numbered_Set -> Y;
keyed_fold_forward: ((key::Key, Int, Y) -> Y) -> Y -> Numbered_Set -> Y;
# Apply a folding function to the entries of the numbering
# in increasing map order.
fold_backward: ((key::Key, Y) -> Y) -> Y -> Numbered_Set -> Y;
keyed_fold_backward: ((key::Key, Int, Y) -> Y) -> Y -> Numbered_Set -> Y;
# Apply a folding function to the entries of the numbering
# in decreasing map order.
filter: (key::Key -> Bool) -> Numbered_Set -> Numbered_Set;
keyed_filter: ((key::Key, Int) -> Bool) -> Numbered_Set -> Numbered_Set;
# Filter out those elements of the numbering that do not satisfy the
# predicate. The filtering is done in increasing map order.
all_invariants_hold: Numbered_Set -> Bool;
debug_print
:
( Numbered_Set, # Print tree structure of this map.
key::Key -> Void # Here's how to print out the keys.
)
->
Int;
}; # Numbered_Set
## COPYRIGHT (c) 1996 by AT&T Research. See SMLNJ-COPYRIGHT file for details.
## Subsequent changes by Jeff Prothero Copyright (c) 2010-2015,
## released per terms of SMLNJ-COPYRIGHT.