V - type of subclass of ObjectId that will be stored in the map.public class ObjectIdSubclassMap<V extends ObjectId> extends java.lang.Object implements java.lang.Iterable<V>, ObjectIdSet
ObjectId
subclasses.
This map provides an efficient translation from any ObjectId instance to a cached subclass of ObjectId that has the same value.
If object instances are stored in only one map,
ObjectIdOwnerMap is a more efficient
implementation.
| Modifier and Type | Field and Description |
|---|---|
private int |
grow |
private static int |
INITIAL_TABLE_SIZE |
private int |
mask |
(package private) int |
size |
(package private) V[] |
table |
| Constructor and Description |
|---|
ObjectIdSubclassMap()
Create an empty map.
|
| Modifier and Type | Method and Description |
|---|---|
<Q extends V> |
add(Q newValue)
Store an object for future lookup.
|
<Q extends V> |
addIfAbsent(Q newValue)
Store an object for future lookup.
|
void |
clear()
Remove all entries from this map.
|
boolean |
contains(AnyObjectId toFind)
Returns true if the objectId is contained within the collection.
|
private V[] |
createArray(int sz) |
V |
get(AnyObjectId toFind)
Lookup an existing mapping.
|
private void |
grow() |
private void |
initTable(int sz) |
private void |
insert(V newValue) |
boolean |
isEmpty()
Whether
size() is 0. |
java.util.Iterator<V> |
iterator() |
int |
size()
Get number of objects in map
|
private static final int INITIAL_TABLE_SIZE
int size
private int grow
private int mask
public void clear()
public V get(AnyObjectId toFind)
toFind - the object identifier to find.public boolean contains(AnyObjectId toFind)
Returns true if this map contains the specified object.
contains in interface ObjectIdSettoFind - the objectId to findpublic <Q extends V> void add(Q newValue)
An existing mapping for must not be in this map. Callers must
first call get(AnyObjectId) to verify there is no current
mapping prior to adding a new mapping, or use
addIfAbsent(ObjectId).
newValue - the object to store.public <Q extends V> V addIfAbsent(Q newValue)
Stores newValue, but only if there is not already an object for
the same object name. Callers can tell if the value is new by checking
the return value with reference equality:
V obj = ...; boolean wasNew = map.addIfAbsent(obj) == obj;
newValue - the object to store.newValue if stored, or the prior value already stored and
that would have been returned had the caller used
get(newValue) first.public int size()
public java.util.Iterator<V> iterator()
private void insert(V newValue)
private void grow()
private void initTable(int sz)
private final V[] createArray(int sz)