class StrongInternPool<E>
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable
Modifier and Type | Class and Description |
---|---|
private class |
StrongInternPool.IdentityHashSetIterator |
class |
StrongInternPool.Index |
Modifier and Type | Field and Description |
---|---|
private static int |
DEFAULT_CAPACITY
Same default as HashMap, must be a power of 2
|
private static float |
DEFAULT_LOAD_FACTOR
67%, just like IdentityHashMap
|
private StrongInternPool.Index |
index
Cache for an index
|
private float |
loadFactor
The user defined load factor which defines when to resize
|
private static int |
MAXIMUM_CAPACITY
MAX_INT - 1
|
private int |
modCount
Counter used to detect changes made outside of an iterator
|
private static java.lang.Object |
NULL
Marks null keys.
|
private static long |
serialVersionUID
Serialization ID
|
private int |
size
The current number of key-value pairs
|
private java.lang.Object[] |
table
The open-addressed table
|
private int |
threshold
The next resize
|
Constructor and Description |
---|
StrongInternPool() |
StrongInternPool(int initialCapacity) |
StrongInternPool(int initialCapacity,
float loadFactor) |
Modifier and Type | Method and Description |
---|---|
void |
clear() |
StrongInternPool<E> |
clone() |
boolean |
contains(java.lang.Object entry) |
private static boolean |
eq(java.lang.Object o1,
java.lang.Object o2) |
private static int |
hash(java.lang.Object o) |
StrongInternPool.Index |
index() |
private static int |
index(int hashCode,
int length) |
private void |
init(int initialCapacity,
float loadFactor) |
E |
intern(E entry)
Internalizes the specified object by always returning the first ever stored.
|
boolean |
isEmpty() |
java.util.Iterator<E> |
iterator() |
private static <K> K |
maskNull(K key) |
private int |
nextIndex(int index,
int length) |
private int |
offset(java.lang.Object entry) |
void |
printDebugStats() |
private void |
putForCreate(E entry) |
private void |
readObject(java.io.ObjectInputStream s) |
private void |
relocate(int start) |
boolean |
remove(java.lang.Object o) |
private void |
resize(int from) |
int |
size() |
java.lang.Object[] |
toInternalArray()
Advanced method that returns the internal table.
|
java.lang.String |
toString() |
private static <K> K |
unmaskNull(K key) |
private void |
writeObject(java.io.ObjectOutputStream s) |
private static final java.lang.Object NULL
private static final long serialVersionUID
private static final int DEFAULT_CAPACITY
private static final int MAXIMUM_CAPACITY
private static final float DEFAULT_LOAD_FACTOR
private transient java.lang.Object[] table
private transient int size
private transient int threshold
private final float loadFactor
private transient int modCount
private transient StrongInternPool.Index index
public StrongInternPool(int initialCapacity, float loadFactor)
public StrongInternPool(int initialCapacity)
public StrongInternPool()
private void init(int initialCapacity, float loadFactor)
private static boolean eq(java.lang.Object o1, java.lang.Object o2)
private static int hash(java.lang.Object o)
private static final <K> K maskNull(K key)
private static final <K> K unmaskNull(K key)
private int nextIndex(int index, int length)
private static final int index(int hashCode, int length)
public int size()
public boolean isEmpty()
public boolean contains(java.lang.Object entry)
private int offset(java.lang.Object entry)
public E intern(E entry)
entry
- the object to internalizeprivate void resize(int from)
public boolean remove(java.lang.Object o)
private void relocate(int start)
public void clear()
public StrongInternPool<E> clone()
clone
in class java.lang.Object
public java.lang.Object[] toInternalArray()
public void printDebugStats()
private void readObject(java.io.ObjectInputStream s) throws java.io.IOException, java.lang.ClassNotFoundException
java.io.IOException
java.lang.ClassNotFoundException
private void putForCreate(E entry)
private void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException
java.io.IOException
public java.util.Iterator<E> iterator()
public StrongInternPool.Index index()
public java.lang.String toString()
toString
in class java.lang.Object