HashLists are used if you require quick contains operations on a large list object. LinkedLists should be generally used, but are slow in this regard. Removing elements from a HashList is slower than of LinkedLists.
📖 Read the detailed guide for hand-written examples and background.
public class HashList<T>
Members:
construct()construct(thistype base) Create a new list by copying all elements from another list into itcount(T elem) returns int Returns the number of occurences of an element in this listadd(vararg T elems) Add an element to the end of the listset(int index, T elem) Set an element at the given index. If the index is higher than the list’s size, the list will be resized with null elements added between the index and the previous size.addAll(HashList<T> elems) Add all elements from elems to this listclear() Remove all elements from this list without destroying itremoveAt(int index) returns T Removes and returns the element at the given indexremove(T t) returns boolean Removes the first occurence of t from this list. Returns true if an element was removed from the list.size() returns int Get the size of the listisEmpty() returns bool Return whether the list is emptyget(int index) returns T Get the element at the given index from this listhas(T elem) returns bool Return whether the element exists in the listhasAt(int index) returns bool Return whether the element exists in the listiterator() returns HLIterator<T> Get an iterator for this listcopy() returns HashList<T> Returns a shallow copy of this listforEach(HLItrClosure<T> itr) returns HashList<T> Executes the closure for each elementstaticItr() returns HLIterator<T> get the static iterator for this listremoveIf(RemovePredicate<T> predicate) Removes the element if the predicates returns truegetRandomElement() returns Tpublic class HLIterator<Q>
Members:
construct(HashList<Q> list)hasNext() returns booleanremove()next() returns Qreset()close()public interface RemovePredicate<T>
Members:
shouldRemove(T element) returns booleanpublic interface HLItrClosure<T>
Members:
run(T t)