Top Description Fields Constructors Methods
org.eclipse.jgit.lib

public Class ObjectIdSubclassMap<V extends ObjectId>

extends Object
implements Iterable<V extends ObjectId>, ObjectIdSet
Class Inheritance
All Implemented Interfaces
org.eclipse.jgit.lib.ObjectIdSet, java.lang.Iterable
Type Parameters
<V>
type of subclass of ObjectId that will be stored in the map.
Imports
java.util.Iterator, .NoSuchElementException

Fast, efficient map specifically for org.eclipse.jgit.lib.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, org.eclipse.jgit.lib.ObjectIdOwnerMap is a more efficient implementation.

Field Summary

Modifier and TypeField and Description
private int
private static final int
private int
pack-priv int
pack-priv V[]

Constructor Summary

AccessConstructor and Description
public
ObjectIdSubclassMap()

Create an empty map.

Method Summary

Modifier and TypeMethod and Description
public <
type of values
Q extends V
>
void
add(Q
the object to store.
newValue
)

Store an object for future lookup.

public <
type of values
Q extends V
>
V

Returns:

newValue if stored, or the prior value already stored and that would have been returned had the caller used get(newValue) first.
addIfAbsent
(Q
the object to store.
newValue
)

Store an object for future lookup.

public void
clear()

Remove all entries from this map.

public boolean
contains(AnyObjectId
the objectId to find
toFind
)

Implements org.eclipse.jgit.lib.ObjectIdSet.contains.

Returns true if the objectId is contained within the collection.

private final V[]
createArray(int sz)

public V

Returns:

the instance mapped to toFind, or null if no mapping exists.
get
(AnyObjectId
the object identifier to find.
toFind
)

Lookup an existing mapping.

private void
grow()

private void
initTable(int sz)

private void
insert(V newValue)

public boolean

Returns:

true if size() is 0.
isEmpty
()

Whether size() is 0.

public Iterator<V>
iterator()

Implements java.lang.Iterable.iterator.

Returns an iterator over elements of type T.

public int

Returns:

number of objects in map
size
()

Get number of objects in map

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

growback to summary
private int grow
INITIAL_TABLE_SIZEback to summary
private static final int INITIAL_TABLE_SIZE
maskback to summary
private int mask
sizeback to summary
pack-priv int size
tableback to summary
pack-priv V[] table

Constructor Detail

ObjectIdSubclassMapback to summary
public ObjectIdSubclassMap()

Create an empty map.

Method Detail

addback to summary
public <Q extends V> void add(Q newValue)

Store an object for future lookup.

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).

Parameters
<Q>
type of values
newValue:Q

the object to store.

addIfAbsentback to summary
public <Q extends V> V addIfAbsent(Q newValue)

Store an object for future lookup.

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;
Parameters
<Q>
type of values
newValue:Q

the object to store.

Returns:V

newValue if stored, or the prior value already stored and that would have been returned had the caller used get(newValue) first.

clearback to summary
public void clear()

Remove all entries from this map.

containsback to summary
public boolean contains(AnyObjectId toFind)

Implements org.eclipse.jgit.lib.ObjectIdSet.contains.

Doc from org.eclipse.jgit.lib.ObjectIdSet.contains.

Returns true if the objectId is contained within the collection.

Returns true if this map contains the specified object.

Parameters
toFind:AnyObjectId

the objectId to find

Returns:boolean

whether the collection contains the objectId.

Annotations
@Override
createArrayback to summary
private final V[] createArray(int sz)
Annotations
@SuppressWarnings:unchecked
getback to summary
public V get(AnyObjectId toFind)

Lookup an existing mapping.

Parameters
toFind:AnyObjectId

the object identifier to find.

Returns:V

the instance mapped to toFind, or null if no mapping exists.

growback to summary
private void grow()
initTableback to summary
private void initTable(int sz)
insertback to summary
private void insert(V newValue)
isEmptyback to summary
public boolean isEmpty()

Whether size() is 0.

Returns:boolean

true if size() is 0.

iteratorback to summary
public Iterator<V> iterator()

Implements java.lang.Iterable.iterator.

Doc from java.lang.Iterable.iterator.

Returns an iterator over elements of type T.

Returns:Iterator<V>

an Iterator.

Annotations
@Override
sizeback to summary
public int size()

Get number of objects in map

Returns:int

number of objects in map