PreviousUpNext

14.2.46  Set

The standard library Set api defines an interface for datastructures which implement set operations, typically via some sort of binary tree datastructure.

The Set api is implemented by the int_binary_set, int_list_set unt_red_black_set, int_red_black_set and string_set packages.

Red-black trees are the de facto standard Mythryl balanced binary tree type, hence int_red_black_set may be considered the standard tree-based integer Set implementation and string_set the standard tree-based string Set implementation.

The Set api source code is in src/lib/src/set.api.

The above information is manually maintained and may contain errors.

api {   package key
          : api {
                Key;
                compare : (Key , Key) -> Order;};;
    Item  = key::Key;
    Set;
    empty : Set;
    singleton : Item -> Set;
    from_list : List(Item ) -> Set;
    add : (Set , Item) -> Set;
    add' : (Item , Set) -> Set;
    add_list : (Set , List(Item )) -> Set;
    drop : (Set , Item) -> Set;
    member : (Set , Item) -> Bool;
    preceding_member : (Set , Item) -> Null_Or(Item );
    following_member : (Set , Item) -> Null_Or(Item );
    is_empty : Set -> Bool;
    equal : (Set , Set) -> Bool;
    compare : (Set , Set) -> Order;
    is_subset : (Set , Set) -> Bool;
    vals_count : Set -> Int;
    vals_list : Set -> List(Item );
    union : (Set , Set) -> Set;
    intersection : (Set , Set) -> Set;
    difference : (Set , Set) -> Set;
    map : (Item -> Item) -> Set -> Set;
    apply : (Item -> Void) -> Set -> Void;
    fold_forward : ((Item , X) -> X) -> X -> Set -> X;
    fold_backward : ((Item , X) -> X) -> X -> Set -> X;
    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;};


Comments and suggestions to: bugs@mythryl.org

PreviousUpNext