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 ofID
to index instead of searching the list for the value. Items in the list for which theID
Function
returnsnull
are allowed and can safely be assigned a non-null
ID
after being added to the list. Otherwise, theID
of an item in the list should not change.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(int index, T element)
T
get(int index)
int
indexOf(java.lang.Object o)
int
lastIndexOf(java.lang.Object o)
T
remove(int index)
T
set(int index, T element)
int
size()
-
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
-
-