Class Hash
Object
|
+--Hash
-
Direct Known Subclasses:
-
WidgetHash
- class
Hash
Defined in hash.js
|
Field Summary |
Function |
hash
|
|
Constructor Summary |
Hash
(<Function> hashFunc)
A hash map.
|
|
Method Summary |
Object
|
add(<Object> key, <Object> value)
Adds a mapping from key to value.
|
void
|
clear()
Removes all key-value pairs from this hash.
|
boolean
|
contains(<Object> key)
Checks the hash for a mapping from key to anything and returns true
if such a mapping exists.
|
boolean
|
containsKey(<string> index)
Returns true if and only if there is an key in the hash
with a hash value identical to index.
|
Object
|
get(<Object> key)
Retrieves the value associated with key from the map.
|
Object
|
remove(<Object> key)
Removes the mapping for which key is the key.
|
<static> string
|
IDENTITY(<Object> obj)
A hash function that returns its argument.
|
hash
Function hash
Hash
function Hash(<Function> hashFunc)
Parameters:
hashFunc - a function taking one argument and returning a unique value identifying the argument.
add
Object add(<Object> key, <Object> value)
Adds a mapping from key to value. If this.hash(key) === null
then no mapping will be created. This can be used to exclude invalid values from the hash. Note
that both key and value may be null, although for
key to be null, this.hash must return a unique and consistent
value when passed null. There are no special requirements for value to be
null.
Parameters:
key - the key object that maps to value
value - the value object that key maps to
Returns:
the value that key was previously mapped to, or null if key was not previously in the hash.
clear
void clear()
Removes all key-value pairs from this hash.
contains
boolean contains(<Object> key)
Checks the hash for a mapping from key to anything and returns true
if such a mapping exists. Note that this.get(key) might be null.
Parameters:
key - the key part of the mapping to look for
Returns:
true if this.containsKey(this.hash(key)) == true and false otherwise.
containsKey
boolean containsKey(<string> index)
Returns true if and only if there is an key in the hash
with a hash value identical to index.
Parameters:
index - the hash value to check for
Returns:
true if there is an element e in the hash such that this.hash(e) === index, false otherwise.
get
Object get(<Object> key)
Retrieves the value associated with key from the map. The return value
may be null event if this.contains(key) returns true.
Parameters:
key - the key part of the mapping to search for.
Returns:
the value associated with key
remove
Object remove(<Object> key)
Removes the mapping for which key is the key. Returns the value part of
the mapping, or null if key did not map to anything.
Parameters:
key - the key part of the mapping to remove
Returns:
the value part of the mapping that was removed, or null if key did not map to anything.
IDENTITY
<static> string IDENTITY(<Object> obj)
A hash function that returns its argument.
