PreviousUpNext

15.3.424  src/lib/src/set.api

## set.api

# Compiled by:
#     src/lib/std/standard.lib

# Compare to:
#     src/lib/src/map.api
#     src/lib/src/numbered-list.api
#     src/lib/src/tagged-numbered-list.api
#     src/lib/src/numbered-list.api

# This api is implemented in:
#     src/lib/src/binary-set-g.pkg
#     src/lib/src/int-binary-set.pkg
#     src/lib/src/int-list-set.pkg
#     src/lib/src/int-red-black-set.pkg
#     src/lib/src/list-set-g.pkg
#     src/lib/src/red-black-set-g.pkg
#     src/lib/src/unt-red-black-set.pkg
#     src/app/yacc/src/utils.pkg                # Should either eliminate or move this one. XXX BUGGO FIXME




# Api for a set of values with an order relation.



###     "When I am working on a problem,
###      I never think about beauty.
###      I think only of how to solve the problem.
###
###      But when I have finished,
###      if the solution is not beautiful,
###      I know it is wrong."
###
###             -- R Buckminster Fuller


api Set {

    package key:  Key;          # Key   is from   src/lib/src/key.api

    Item = key::Key;
    Set;

    empty:  Set;
        #  The empty set 

    singleton:  Item -> Set;
        #  Create a singleton set 

    add:   (Set, Item) -> Set;
    add' : ((Item, Set)) -> Set;
        #  Insert an item. 

    add_list:  (Set, List( Item )) -> Set;
        #  Insert items from list. 

    delete:  (Set, Item) -> Set;
        #  Remove an item. Raise NOT_FOUND if not found. 

    member:  (Set, Item) -> Bool;
        #  Return TRUE if and only if item is an element in the set 

    is_empty:  Set -> Bool;
        #  Return TRUE if and only if the set is empty 

    equal:  ((Set, Set)) -> Bool;
        #  Return TRUE if and only if the two sets are equal 

    compare:  ((Set, Set)) -> Order;
        #  Does a lexical comparison of two sets 

    is_subset:  ((Set, Set)) -> Bool;
        #  Return TRUE if and only if the first set is a subset of the second 

    vals_count:  Set ->  Int;
        #  Return the number of items in the table 

    vals_list:  Set -> List( Item );
        #  Return an ordered list of the items in the set 

    union:  (Set, Set) -> Set;
        #  Union 

    intersection:  (Set, Set) -> Set;
        #  Intersection 

    difference:  (Set, Set) -> Set;
        #  Difference 

    map:  (Item -> Item) -> Set -> Set;
        # Create a new set by applying a map function to the elements
        # of the set.
     
    apply:  (Item -> Void) -> Set -> Void;
        # Apply a function to the entries of the set 
        # in increasing order

    fold_left:  ((Item, Y) -> Y) -> Y -> Set -> Y;
        # Apply a folding function to the entries of the set 
        # in increasing order

    fold_right:  ((Item, Y) -> Y) -> Y -> Set -> Y;
        # Apply a folding function to the entries of the set 
        # in decreasing order

    partition:  (Item -> Bool) -> Set -> ((Set, Set));

    filter:  (Item -> Bool) -> Set -> Set;

    exists:  (Item -> Bool) -> Set -> Bool;

    find:  (Item -> Bool) -> Set -> Null_Or( Item );

    all_invariants_hold: Set -> Bool;

}; #  Set 


## COPYRIGHT (c) 1993 by AT&T Bell Laboratories.  See COPYRIGHT file for details.
## Subsequent changes by Jeff Prothero Copyright (c) 2010-2011,
## released under Gnu Public Licence version 3.


Comments and suggestions to: bugs@mythryl.org

PreviousUpNext