## hashtable.api
#
# Typeagnostic hashtable api.
# Compiled by:
#
src/lib/std/standard.lib### "If life were fair, there would be no hope for most of us;
### we would be doomed to our just desserts.
### Fortunately, the gods are not that cruel!"
# This api is implemented in:
#
#
src/lib/src/hashtable.pkg#
api Hashtable {
#
Hashtable (X, Y); # Type of a hashtable mapping X to Y.
# Create a new hashtable given a hash-fn
# and an equality predicate.
#
# The int is a size hint and
# the exception is to be raised by find.
#
make_hashtable
:
( (X -> Unt), # Hashing function.
((X,X) -> Bool) # Equality predicate.
)
-> { size_hint: Int, not_found_exception: Exception } #
-> Hashtable (X,Y);
clear: Hashtable(X,Y) -> Void; # Remove all elements from the table.
set: Hashtable (X,Y) -> (X,Y) -> Void; # Insert key-val pair; discard any pre-existing entry with that key.
contains_key: Hashtable(X,Y) -> X -> Bool; # Return TRUE iff the key is in the table.
look_up: Hashtable (X,Y) -> X -> Y; # Find an item. If it doesn't exist raise table.not_found_exception.
find: Hashtable( X, Y) -> X -> Null_Or(Y); # Look for an item. Return NULL if the item doesn't exist.
remove: Hashtable( X, Y) -> X -> Y; # Remove and return item. If item is missing raise table.exception_not_found.
vals_count: Hashtable(X,Y) -> Int; # Return the number of items in the table
vals_list: Hashtable(X,Y) -> List(Y);
keyvals_list: Hashtable(X,Y) -> List ((X,Y)); # Return a list of the items (and their keys) in the table.
apply: (Y -> Void) -> Hashtable (X,Y) -> Void;
keyed_apply: ((X,Y) -> Void) -> Hashtable(X,Y) -> Void; # Apply a function to the entries of the table.
map: (Y -> Z) -> Hashtable(X,Y) -> Hashtable(X, Z);
keyed_map: ((X,Y) -> Z) -> Hashtable(X,Y) -> Hashtable(X, Z); # Map a table to a new table that has the same keys.
fold: ( (Y, Z) -> Z) -> Z -> Hashtable(X,Y) -> Z;
foldi: ((X, Y, Z) -> Z) -> Z -> Hashtable(X,Y) -> Z; # Fold a function over the elements of a table.
map_in_place: (Y -> Y) -> Hashtable(X,Y) -> Void;
keyed_map_in_place: ((X,Y) -> Y) -> Hashtable(X,Y) -> Void; # Modify the hashtable items in place.
filter: (Y -> Bool) -> Hashtable(X,Y) -> Void;
keyed_filter: ((X,Y) -> Bool) -> Hashtable(X,Y) -> Void; # Remove any hashtable items that do not satisfy the given predicate.
copy: Hashtable(X,Y) -> Hashtable(X,Y); # Copy a hashtable.
bucket_sizes: Hashtable(X,Y) -> List(Int);
#
# Returns a list of the sizes of the various buckets.
# This allows users to gauge the quality of their hash-fn.
}; # api Hashtable.
## AUTHOR: John Reppy
## AT&T Bell Laboratories
## Murray Hill, NJ 07974
## jhr@research.att.com
## COPYRIGHT (c) 1993 by AT&T Bell Laboratories.
## Subsequent changes by Jeff Prothero Copyright (c) 2010-2015,
## released per terms of SMLNJ-COPYRIGHT.