class VSET{ETP} < $VSET{ETP} |
---|
**** | A set with value semantics. All modifying operations return a new object, thus eliminating the possibility of aliasing problems |
$VSET{_} | $VBAG{_} | $HASH | $IS_EQ | $RO_BAG{_} | $CONTAINER{_} | $STR | $ELT{_} | $ELT | $RO_SET{_} |
add(e:ETP):VBAG{ETP} .. Included as add |
---|
**** | Result is a new bag containing all the elements of self and 'e' From $RO_BAG |
as_array:ARRAY{ETP} .. Included as as_array |
---|
**** | Return the elements of the container as an array |
concat(arg:$ELT{ETP}):VBAG{ETP} .. Included as concat |
---|
**** | Returns a bag 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=bag 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(e:ETP):INT .. Included as count |
---|
create(arg:ARRAY{ETP}):SAME .. Included as create |
---|
**** | Create a new bag from the elements of the array 'arg' The reason for having a separate routine in this case is to permit type inference to be used so that a user may write
____a:BAG{INT}_:=_#(|1,2,3|); |
create(arg:$ELT{ETP}):SAME .. Included as create |
---|
**** | Create a new bag out of the elements of 'arg' |
create: SAME .. Included as create |
---|
delete(e:ETP):SAME |
---|
delete_all(e:ETP):SAME .. Included as delete_all |
---|
**** | Result is a new set containing all the elements of self except for any elements equal to 'e' Redefined from $RO_BAG to change the return type from $RO_BAG to $RO_SET |
delete_and_return(e:ETP):ETP .. Included as delete_and_return |
---|
**** | Removes an element from the set. Returns the deleted element. Returns void (or E::nil if E inherits $NIL{ETP}) if there is no element to delete. |
diff(arg: $RO_SET{ETP}):SAME .. Included as diff |
---|
**** | Returns a set 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{ETP}):BOOL .. Included as equals |
---|
**** | Return true if self contains all the elements of 'c' and vice versa. |
get(e:ETP):ETP .. Included as get |
---|
**** | Returns the element equal to 'e' from the set. Returns void or E::nil if there is no such element. Self may not be void. |
has(e:ETP): BOOL .. Included as has |
---|
hash:INT |
---|
insert(e:ETP):SAME |
---|
intersection(arg: $RO_BAG{ETP}):VBAG{ETP} .. Included as intersection |
---|
**** | Returns a bag 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_SET{ETP}):SAME .. Included as intersection |
---|
**** | Returns a set containing the elements of 'self' and in 'arg' Overloads the function in $RO_BAG which has an argument and return value of $RO_BAG
_ result=set of all e s.t. self.has(e) and arg.has(e) |
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{ETP}):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: arg.has(e) |
n_unique:INT .. Included as n_unique |
---|
**** | Return teh number of elements in self |
size: INT .. Included as size |
---|
str: STR .. Included as str |
---|
**** | Return a string representation of self |
sym_diff(arg: $RO_SET{ETP}): SAME .. Included as sym_diff |
---|
**** | Returns a set containing the elements of 'self' and not in 'arg' or in 'arg' but not in self
_ result=set of all e s.t. self.has(e) xor arg.has(e) |
union(arg: $RO_BAG{ETP}):VBAG{ETP} .. Included as union |
---|
**** | Returns a bag 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_SET{ETP}):SAME .. Included as union |
---|
**** | Returns a set containing all elements in 'self' or 'arg'. Overloads the function in $RO_BAG which has an argument and return value of $RO_BAG
_ result=set of all e s.t. self.has(e) or arg.has(e) |
elt!:ETP .. Included as elt! |
---|
unique!:ETP .. Included as unique! |
---|
**** | Yield the elements of 'self' |
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 |
---|
clear .. Included as clear |
---|
**** | Extremely inefficient. Must be rewritten by someone who has looked at the implementation (delete(elt!) may have problems) Creates a separate list of elements to delete to separte out iteration from modification |
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. |
dbg: STR .. Included as dbg |
---|
**** | Returns an interal string representation of the hashtable. For debugging only. |
delete(e:ETP) .. 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. |
insert(e:ETP) .. Included as insert |
---|
insert_replace(e:ETP) .. Included as insert_replace |
---|
**** | Inserts e into the set. If there is already an element equal to e in the set, the old element will be replaced. |
insert_replace(e:ETP):ETP .. Included as insert_replace |
---|
**** | Does the same like insert_replace but returns the old element which is being replaced or the same object if there was no old one. |
shared lower_fill_ratio: FLT := 0.800; .. Included as lower_fill_ratio |
---|
shared lower_fill_ratio: FLT := 0.800; .. Included as lower_fill_ratio |
---|
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.) |