|
HashAdd
None HashAdd(HashTable table, Value key, Value value)
|
Adds the given value to the hash table using the given key. If a value already
exists for the key, it is replaced with the new value. |
HashAdd(@Table, 'Age', 10);
Adds the key Age to the hash table with a value of
10.
HashAdd(@Table, Canonical_Smiles, LOGIC50);
Uses the value of Canonical_Smiles as the key, and adds the
value of the property LOGIC50.
|
|
HashAppendValue
None HashAppendValue(HashTable table, Value key, Value value)
|
Appends the given value to the value contained in the hash table using the
given key. If the key has a value, and it is an array, the new value is appended to
it. If the key has a value, and it is not an array, an array is created, the
original value is appended to it, and the new value is appended to it. If the key
does not have a value, an array is created and the new value is appended to it. This
function efficiently stores multiple values on single keys. You can try to manage
the arrays yourself, but the cost of copying the arrays using
HashAdd is high. |
HashAppendValue(@Table, 'Maxima', 10.1);
HashAppendValue(@Table, 'Maxima', 15.51);
HashAppendValue(@Table, 'Minima', -1.0);
HashAppendValue(@Table, 'Minima', 0.1);
HashAppendValue(@Table, 'Minima', 0.3);
Creates two keys in the hash table, Maxima and
Minima, adding two values to Maxima and three
to Minima.
|
|
HashClear
None HashClear(HashTable table)
|
Clears all keys and values from the hash table, but does not destroy the hash
table itself. |
HashClear(@Table);
Clears the table.
|
|
HashContains
Boolean HashContains(HashTable table, Value key)
|
Verifies if a particular key is in the hash table. |
IF (Not HashContains(@Table, Name)) THEN
HashAdd(@Table, Name, Age);
END IF;
If the name is not found in the hash table, adds the name and the person's
age.
|
|
HashFind
Value HashFind(HashTable table, Value key)
|
Looks up a key in the hash table. If not found, a null value is returned. (A
null value can be detected by checking if NumValues is zero or
not.) |
IF (HashContains(@Table, Name))
THEN
#Age := HASHFIND(@Table, Name);
IF (#Age > @Oldest)
THEN
@Oldest := #Age;
END IF;
END IF;
If a given name is contained in the hash table, finds the value, and tests
whether it is older than the oldest current name.
|
|
HashFindIndex
Number HashFindIndex(HashTable table, Value key)
|
Looks up a key in the hash table. If not found, 0 is returned. Otherwise, an
index is returned. The index can be used with HashIthKey and
HashIthValue. |
#Index := HashFindIndex(@Table, Name);
IF (#Index > 0)
THEN
Age := HashIthValue(@Table, #Index);
END IF;
If a given name is contained in the hash table, finds the value.
|
|
HashIthKey
Value HashIthKey(HashTable table, Number index)
|
Returns the ith key from the hash table. |
Resize(Keys, 0);
FOR #i in 1 .. HashNumValues(@Table)
LOOP
Append(Keys, HashIthKey(@Table, #i));
END LOOP;
Collects all the keys into an array.
|
|
HashIthValue
Value HashIthValue(HashTable table, Number index)
|
Returns the ith value from the hash table. |
Resize(Values, 0);
FOR #i in 1 .. HashNumValues(@Table) LOOP
Append(Values, HashIthValue(@Table, #i));
END LOOP;
Collects all the values into an array.
|
|
HashNumValues
Number HashNumValues(HashTable table)
|
Returns the number of key/value pairs in the hash table. |
#numValues := HashNumValues(@Table);
Sets the number of values in the hash table into the local property
#numValues.
|
|
HashRemove
None HashRemove(HashTable table, Value key)
|
Removes the given key and its associated value from the given hash
table. |
HashRemove(@Table, Name);
|
|
HashValueCreate
HashTableValue HashValueCreate([Boolean caseSensitive=false, Boolean convertKeysToStrings=true])
|
Returns a property containing an actual hash table value.
If the caseSensitive argument is given, it is a boolean value
that determines whether string comparisons are made with or without consideration
of case. The default is to ignore case. If the
convertKeysToStrings argument is given, it is a boolean value
that determines whether keys will be standardized to
StringValues. Otherwise, keys of different types (e.g.,
18.0 and '18.0') are never equal. The default
is to convert keys into strings.
|
H := HashValueCreate();
HashAdd(H, 'a', 'apple');
HashAdd(H, 'b', 'banana');
HashAdd(H, 'c', 'carrot');
|