class VMAP{ITP,TTP} < $VMAP{ITP,TTP}
****
Hash table based on data buckets


Ancestors
$VMAP{_,_} $VMULTIMAP{_,_} $VBAG{_} $HASH
$IS_EQ $RO_BAG{_} $CONTAINER{_} $STR
$ELT{_} $ELT $RO_MULTIMAP{_,_} $RO_MAP{_,_}



Public


Features
add(k:ITP,e:TTP):VMULTIMAP{ITP,TTP} .. Included as add
**** Result is a new multimap containing all the elements of self and 'k,e'
add(e:TUP{ITP,TTP}):VMULTIMAP{ITP,TTP} .. Included as add
**** Result is a new multimap containing all the elements of self and 'e'
map_aget(k:K): E .. Included as aget
**** Returns the element equal to 'e' from the set. Returns void or T::nil if there is no such element. Self may not be void.
as_array:ARRAY{TUP{ITP,TTP}} .. Included as as_array
**** Return the elements of the container as an array
as_value:VMAP{ITP,TTP} .. Included as as_value
**** Return the value associated with this reference type
concat(arg:$ELT{TUP{ITP,TTP}}):VMULTIMAP{ITP,TTP} .. Included as concat
**** Returns a multimap containing all the elements of self and 'arg'. For elements that occur multiple times, the result contains the sum of the number of occurences in self and 'arg'
_
result=multimap of all e s.t.
__________________result.count(e)=self.count(e)+arg.count(e)>0_
map_copy: SAME .. Included as copy
**** Returns a copy of self with all properties set like self.
count(arg:TUP{ITP,TTP}):INT .. Included as count
**** Return the number of occurences of 'arg' in the container
create(arg:$ELT{TUP{ITP,TTP}}):SAME .. Included as create
**** Create a new bag out of the elements of 'arg'
create: SAME .. Included as create
delete(k:ITP,e:TTP):SAME .. Included as delete
**** Result is a new multimap containing all the elements of self except 'k,e'
delete(e:TUP{ITP,TTP}):SAME .. Included as delete
**** Delete the tuple 'e' from this map, if it exists
delete_all(k:ITP,e:TTP):SAME .. Included as delete_all
**** Shortcut for for delete(e:TUP{ITP,TTP})
delete_all(e:TUP{ITP,TTP}):SAME .. Included as delete_all
**** Shortcut for for delete(e:TUP{ITP,TTP})
delete_ind(k:ITP):SAME .. Included as delete_ind
**** Returns a new map in which any occurences of the tuple (k,_) has been deleted
diff(arg:$RO_BAG{TUP{ITP,TTP}}):SAME .. Included as diff
**** Returns a map containing the elements of 'self' not in 'arg'
_
result=set of all e s.t. self.has(e) and ~arg.has(e)
elt_eq(e1,e2:ETP):BOOL .. Included as elt_eq
elt_hash(e:$OB):INT .. Included as elt_hash
elt_lt(e1,e2:ETP):BOOL .. Included as elt_lt
elt_nil:ETP .. Included as elt_nil
equals(c:$RO_BAG{TUP{ITP,TTP}}):BOOL .. Included as equals
**** Return true if self contains all the elements of 'c' and vice versa.
has(e:TUP{ITP,TTP}):BOOL .. Included as has
**** True if the container contains the element "e" Inefficient
map_has_ind(k:K): BOOL .. Included as has_ind
hash:INT
insert(k:ITP,e:TTP):SAME .. Included as insert
**** Insert the element 'e' in the bag. If a tuple (e.t1,_) exists, the replace it with (e.t1,e.t2)
insert(e:TUP{ITP,TTP}):SAME .. Included as insert
intersection(arg: $RO_BAG{TUP{ITP,TTP}}):VMULTIMAP{ITP,TTP} .. Included as intersection
**** Returns a multimap containing the elements common to self and 'arg' For elements that occur multiple times, the result contains the minimum number of occurrences in either self or 'arg'
_
result=bag of all e s.t.
______________result.count(e)=min(self.count(e),arg.count(e))_>_0_
intersection(arg: $RO_MAP{ITP,TTP}):SAME .. Included as intersection
**** Returns a map containing the elements common to self and 'arg'
is_elt_nil(e:ETP):BOOL .. Included as is_elt_nil
is_empty:BOOL .. Included as is_empty
**** Return true if the size = 0.
is_eq(a:$OB):BOOL
**** Return true if 'self' and 'v' have the same value
is_subset_of(arg:$RO_BAG{TUP{ITP,TTP}}):BOOL .. Included as is_subset_of
**** Returns true if 'self' is a subset of 'arg'. For elements that occur multiple times, the number of occurences of the element in 'arg' must be greater than or equal to the number of occurences in self
_
result=true iff for all e in self: count(e) <= arg.count(e)
map_delete(k:K): E .. Included as map_delete
**** Removes an element from the set. Does nothing if there is no such element.
n_ind:INT .. Included as n_ind
**** Return the number of indices in the map
n_targets(k:ITP):INT .. Included as n_targets
**** Return the number of targets associated with the index 'k'
n_unique:INT .. Included as n_unique
**** Return the number of unique pairs in 'self'
size: INT .. Included as size
str: STR .. Included as str
**** Return a string representation of self
sym_diff(arg:$RO_MAP{ITP,TTP}):SAME .. Included as sym_diff
**** Returns a map containing all the elements of self that are not in 'arg' and in 'arg' but not in self.
to_diff(arg: $ELT{TUP{ITP,TTP}}) .. Included as to_diff
**** Convert this set into the diff of self and 'arg' i.e. delete from self any elements that occur in 'arg'
_
self <- initial(self).diff(arg)
to_intersection(arg:$RO_MAP{ITP,TTP}) .. Included as to_intersection
**** Convert this set into the intersection of self and 'arg'
_
self <- initial(self).intersection(arg)
to_sym_diff(arg: $ELT{TUP{ITP,TTP}}) .. Included as to_sym_diff
**** Convert this set into the diff of self and 'arg'
_
self <- initial(self).sym_diff(arg)
to_union(arg:$ELT{TUP{ITP,TTP}}) .. Included as to_union
**** Convert this set into the union of self and 'arg'
_
self <- initial(self).union(arg)
union(arg: $RO_BAG{TUP{ITP,TTP}}):VMULTIMAP{ITP,TTP} .. Included as union
**** Returns a multimap containing the elements of 'self' and 'arg'. For elements that occur multiple times, the result contains the maximum number of occurences in either self or 'arg' This definition permits the union of sets to be consistent with the union of bags.
_
result=bag of all e s.t.
_____________result.count(e)=_max(self.count(e),arg.count(e))_>_0
union(arg: $RO_MAP{ITP,TTP}):SAME .. Included as union
**** Returns a map containing the union of elements of 'self' and 'arg'.

Iters
map_pair!: TUP{K,E} .. Included as elt!
map_key!: K .. Included as ind!
pair!:TUP{ITP,TTP} .. Included as pair!
**** Yields all elements of self in an unspecified order. An alias for "elt!"
target!(once k:ITP): TTP .. Included as target!
**** Yields all the targets associated with index 'k' yield any t s.t. self.has((k,t))
target!:TTP .. Included as target!
unique!:TUP{ITP,TTP} .. Included as unique!
**** Yield the elements of self


Private

map_aset(k:K,e:E) .. Included as aset
**** Over-ride data if 'k' exists. Otherwise grow the bucket chain associated with hash(k)
attr asize: INT; .. Included as asize
**** The size of the fraction of the store which is currently in use. Array access beyond this bound is illegal.
attr asize: INT; .. Included as asize
**** The size of the fraction of the store which is currently in use. Array access beyond this bound is illegal.
attr bound: INT; .. Included as bound
**** Upper bound for split_pos. Is always initial_size * 2.pow(doubles)
attr bound: INT; .. Included as bound
**** Upper bound for split_pos. Is always initial_size * 2.pow(doubles)
bucket(i:INT): BUCKET .. Included as bucket
create_sized(initial_size:INT): SAME .. Included as create_sized
**** Creating a table with another minimal size. This might be useful to avoid shrinking of large table which might get very empty.
data_nil: E .. Included as data_nil
dbg: STR .. Included as dbg
**** Returns an interal string representation of the hashtable. For debugging only.
delete(k:ITP) .. Included as delete
delete(e:TUP{ITP,TTP}) .. Included as delete
attr doubles: INT; .. Included as doubles
**** Number of times the initial table size has been doubled.
attr doubles: INT; .. Included as doubles
**** Number of times the initial table size has been doubled.
elt_eq(e1,e2:ETP):BOOL .. Included as elt_key_eq
elt_hash(e:$OB):INT .. Included as elt_key_hash
elt_nil:ETP .. Included as elt_key_nil
grow .. Included as grow
**** Increases the size of the array by one. The functions changing the size of the bucket table: They are split into two parts. 1.) Splitting the next bucket into two. (update_*) 2.) Resizing the storage area. (shrink/grow)
hash(e:E): INT .. Included as hash
**** Returns the bucket to store e. This number will be generated from the hash-value and be normailzed through the actual size of the set.
shared lower_fill_ratio: FLT := 0.800; .. Included as lower_fill_ratio
shared lower_fill_ratio: FLT := 0.800; .. Included as lower_fill_ratio
map_elt!: E .. Included as map_elt!
attr minsize: INT; .. Included as minsize
**** Lower bound for the store size.
attr minsize: INT; .. Included as minsize
**** Lower bound for the store size.
attr n_inds: INT; .. Included as n_inds
**** Returns the number of elements (resp. indices) in the table.
attr n_inds: INT; .. Included as n_inds
**** Returns the number of elements (resp. indices) in the table.
set_bucket(i:INT,l:BUCKET) .. Included as set_bucket
shrink .. Included as shrink
**** Decreases the size of the array by one. Resizes the storage area, if neccessary. If the size in use = minsize, do nothing. If the size in use is half the array size then shrink the array
attr split_pos: INT; .. Included as split_pos
**** Position of the next bucket to split.
attr split_pos: INT; .. Included as split_pos
**** Position of the next bucket to split.
attr store: AREF{BUCKET}; .. Included as store
**** Here is the data being stored.
attr store: AREF{BUCKET}; .. Included as store
**** Here is the data being stored.
update_delete .. Included as update_delete
**** Checks the actual fill ratio of the set. Removes a bucket from the hash table if the ratio is low enough.
update_insert .. Included as update_insert
**** Checks the actual fill ratio of the set. Adds a bucket to the hash table if the ratio is high enough. The functions changing the size of the bucket table are split into two parts. 1.) Splitting the next bucket into two. (update_*) 2.) Resizing the storage area. (shrink/grow)
shared upper_fill_ratio: FLT := 1.000; .. Included as upper_fill_ratio
**** For fast access one needs a low ratio between number of elements in the and number of cells. For efficient memory usage one needs a high ratio. The ratio should always be between these two bounds (unless the table is really small; where the ratio can get even lower.)
shared upper_fill_ratio: FLT := 1.000; .. Included as upper_fill_ratio
**** For fast access one needs a low ratio between number of elements in the and number of cells. For efficient memory usage one needs a high ratio. The ratio should always be between these two bounds (unless the table is really small; where the ratio can get even lower.)

The Sather Home Page