Class HashList
Object
|
+--AbstractList
|
+--LinkedList
|
+--HashList
-
Direct Known Subclasses:
-
CompositeList
- class
HashList
- extends LinkedList
Defined in hash_list.js
Methods inherited from class AbstractList |
append, copy, getHead, getIndexOf, getItemAfter, getItemAt, getItemBefore, getLength, getTail, insertAfter, insertBefore, insertItemAt, isEmpty, iterator, join, prepend, remove, removeAll, removeHead, removeTail, removeItemAt, replace, reverseIterator, selectRangeInto, sort, toArray, toString
|
HashList
function HashList(hashFunc)
contains
boolean contains(item)
Returns true
if item
is in this list.
Parameters:
item
- the item to search for
Returns:
true
if item
is in the list, false
otherwise
containsKey
boolean containsKey(key)
Returns true
if there is an item, i
, in this list such that
key
maps to i
.
Parameters:
key
- the key to search for
Returns:
true
if key
maps to an item in this list, false
otherwise
getIntersectionWith
LinkedList getIntersectionWith(<AbstractList> list, <boolean> makeHash)
Returns a LinkedList
containing all the elements of
list
that are also in this
. If
makeHash
is true
, the returned list will be a
new instance of HashList
with the same hash function as
this
, rather than a plain LinkedList
. This
method runs in time proportional to the length of list
.
Parameters:
list
- the list to intersect with this
makeHash
- (Optional) - a flag to indicate whether or not the returned list should be a HashList
. Defaults to false
, which means the returned list is a plain LinkedList
.
Returns:
a list containing all the elements of list
that are also in this list
getItemByKey
Object getItemByKey(key)
Returns the item that key
maps to.
Parameters:
key
- the hash key to search for
Returns:
the item, i
, such that key
maps to i
, or null
if there is no such item