Package org.eclipse.jgit.util
Class RefMap
- java.lang.Object
-
- java.util.AbstractMap<String,Ref>
-
- org.eclipse.jgit.util.RefMap
-
public class RefMap extends AbstractMap<String,Ref>
Specialized Map to present aRefDatabasenamespace.Although not declared as a
SortedMap, iterators from this map's projections always return references inRefComparatorordering. The map's internal representation is a sorted array ofRefobjects, which means lookup and replacement is O(log N), while insertion and removal can be as expensive as O(N + log N) while the list expands or contracts. Since this is not a general map implementation, all entries must be keyed by the reference name.This class is really intended as a helper for
RefDatabase, which needs to perform a merge-join of three sortedRefLists in order to present the unified namespace of the packed-refs file, the loose refs/ directory tree, and the resolved form of any symbolic references.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K extends Object,V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object,V extends Object>
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancontainsKey(Object name)Set<Map.Entry<String,Ref>>entrySet()Refget(Object key)booleanisEmpty()Refput(String keyName, Ref value)Refremove(Object key)static Collector<Ref,?,RefMap>toRefMap(BinaryOperator<Ref> mergeFunction)StringtoString()-
Methods inherited from class java.util.AbstractMap
clear, clone, containsValue, equals, hashCode, keySet, putAll, size, values
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
-
-
-
Constructor Detail
-
RefMap
public RefMap()
Construct an empty map with a small initial capacity.
-
RefMap
public RefMap(String prefix, RefList<? extends Ref> packed, RefList<? extends Ref> loose, RefList<? extends Ref> resolved)
Construct a map to merge 3 collections together.- Parameters:
prefix- prefix used to slice the lists down. Only references whose names start with this prefix will appear to reside in the map. Must not be null, use""(the empty string) to select all list items.packed- items from the packed reference list, this is the last list searched.loose- items from the loose reference list, this list overridespackedif a name appears in both.resolved- resolved symbolic references. This list overrides the prior listloose, if an item appears in both. Items in this list must also appear inloose.
-
-
Method Detail
-
containsKey
public boolean containsKey(Object name)
- Specified by:
containsKeyin interfaceMap<String,Ref>- Overrides:
containsKeyin classAbstractMap<String,Ref>
-
isEmpty
public boolean isEmpty()
-
toString
public String toString()
- Overrides:
toStringin classAbstractMap<String,Ref>
-
-