|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.eclipse.jgit.lib.ObjectIdOwnerMap<V>
V
- type of subclass of ObjectId that will be stored in the map.public class ObjectIdOwnerMap<V extends ObjectIdOwnerMap.Entry>
Fast, efficient map for ObjectId
subclasses in only one map.
To use this map type, applications must have their entry value type extend
from ObjectIdOwnerMap.Entry
, which itself extends from ObjectId.
Object instances may only be stored in ONE ObjectIdOwnerMap. This restriction exists because the map stores internal map state within each object instance. If an instance is be placed in another ObjectIdOwnerMap it could corrupt one or both map's internal state.
If an object instance must be in more than one map, applications may use
ObjectIdOwnerMap for one of the maps, and ObjectIdSubclassMap
for the
other map(s). It is encouraged to use ObjectIdOwnerMap for the map that is
accessed most often, as this implementation runs faster than the more general
ObjectIdSubclassMap implementation.
Nested Class Summary | |
---|---|
static class |
ObjectIdOwnerMap.Entry
Type of entry stored in the ObjectIdOwnerMap . |
Constructor Summary | |
---|---|
ObjectIdOwnerMap()
Create an empty map. |
Method Summary | ||
---|---|---|
|
add(Q newValue)
Store an object for future lookup. |
|
|
addIfAbsent(Q newValue)
Store an object for future lookup. |
|
void |
clear()
Remove all entries from this map. |
|
boolean |
contains(AnyObjectId toFind)
Returns true if this map contains the specified object. |
|
V |
get(AnyObjectId toFind)
Lookup an existing mapping. |
|
boolean |
isEmpty()
|
|
Iterator<V> |
iterator()
|
|
int |
size()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ObjectIdOwnerMap()
Method Detail |
---|
public void clear()
public V get(AnyObjectId toFind)
toFind
- the object identifier to find.
public boolean contains(AnyObjectId toFind)
toFind
- object to find.
public <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(Entry)
.
Q
- type of instance to store.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;
Q
- type of instance to store.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 boolean isEmpty()
size()
is 0.public Iterator<V> iterator()
iterator
in interface Iterable<V extends ObjectIdOwnerMap.Entry>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |