Package io.github.jonestimd.collection
Class HashList<T,ID>
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList<T>
-
- io.github.jonestimd.collection.HashList<T,ID>
-
- All Implemented Interfaces:
java.lang.Iterable<T>,java.util.Collection<T>,java.util.List<T>
public class HashList<T,ID> extends java.util.AbstractList<T>List implementation with improved performance forList.indexOf(Object). TheindexOf(Object)method uses a map ofIDto index instead of searching the list for the value. Items in the list for which theIDFunctionreturnsnullare allowed and can safely be assigned a non-nullIDafter being added to the list. Otherwise, theIDof an item in the list should not change.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(int index, T element)Tget(int index)intindexOf(java.lang.Object o)intlastIndexOf(java.lang.Object o)Tremove(int index)Tset(int index, T element)intsize()-
Methods inherited from class java.util.AbstractList
add, addAll, clear, equals, hashCode, iterator, listIterator, listIterator, removeRange, subList
-
Methods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
-
-