public class HopscotchCollection<T>
extends java.util.AbstractCollection<T>
Modifier and Type | Field and Description |
---|---|
protected static double |
LOAD_FACTOR |
protected static int |
SPREADER |
Constructor and Description |
---|
HopscotchCollection()
make a small HopscotchCollection
|
HopscotchCollection(java.util.Collection<? extends T> collection)
make a HopscotchCollection from a collection
|
HopscotchCollection(int capacity)
make a HopscotchCollection for a specified capacity (or good guess)
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(T entry) |
int |
capacity()
maximum number of elements that can be held without resizing.
|
java.util.stream.Stream<T> |
chainHeads() |
void |
clear() |
boolean |
contains(java.lang.Object key) |
protected java.util.function.BiPredicate<T,T> |
entryCollides()
in a general multiset there is no uniqueness criterion, so there is never a collision
|
T |
find(java.lang.Object key)
find an entry equivalent to the key, or return null
|
java.util.Iterator<T> |
findEach(java.lang.Object key)
get an iterator over each of the elements equivalent to the key
|
T |
findOrAdd(java.lang.Object key,
java.util.function.Function<java.lang.Object,T> producer)
find an entry equivalent to the key, or use producer to add a new value
|
protected int |
hashToIndex(java.lang.Object entry) |
boolean |
isEmpty() |
java.util.Iterator<T> |
iterator() |
boolean |
remove(java.lang.Object key) |
boolean |
removeAll(java.util.Collection<?> collection)
unlike the AbstractCollection implementation, this one iterates over the supplied collection
|
boolean |
removeEach(java.lang.Object key)
remove each of the elements equivalent to the key
|
int |
size() |
java.util.stream.Stream<T> |
squatters() |
protected java.util.function.Function<T,java.lang.Object> |
toKey()
in a general multiset, the entry is the key
|
addAll, containsAll, retainAll, toArray, toArray, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
protected static final double LOAD_FACTOR
protected static final int SPREADER
public HopscotchCollection()
public HopscotchCollection(int capacity)
public HopscotchCollection(java.util.Collection<? extends T> collection)
public final boolean add(T entry)
public final void clear()
public final int capacity()
public final boolean contains(java.lang.Object key)
public final T find(java.lang.Object key)
public final T findOrAdd(java.lang.Object key, java.util.function.Function<java.lang.Object,T> producer)
public final java.util.Iterator<T> findEach(java.lang.Object key)
public final boolean isEmpty()
public final java.util.Iterator<T> iterator()
public final boolean remove(java.lang.Object key)
public final boolean removeEach(java.lang.Object key)
public final boolean removeAll(java.util.Collection<?> collection)
public final int size()
public java.util.stream.Stream<T> chainHeads()
public java.util.stream.Stream<T> squatters()
protected java.util.function.BiPredicate<T,T> entryCollides()
protected java.util.function.Function<T,java.lang.Object> toKey()
protected int hashToIndex(java.lang.Object entry)