org.eclipse.jgit.util
Class RefMap
java.lang.Object
java.util.AbstractMap<String,Ref>
org.eclipse.jgit.util.RefMap
- All Implemented Interfaces:
- Map<String,Ref>
public class RefMap
- extends AbstractMap<String,Ref>
Specialized Map to present a RefDatabase
namespace.
Although not declared as a SortedMap
, iterators from this
map's projections always return references in RefComparator
ordering.
The map's internal representation is a sorted array of Ref
objects,
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 sorted RefList
s 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 classes/interfaces inherited from interface java.util.Map |
Map.Entry<K,V> |
Constructor Summary |
RefMap()
Construct an empty map with a small initial capacity. |
RefMap(String prefix,
RefList<? extends Ref> packed,
RefList<? extends Ref> loose,
RefList<? extends Ref> resolved)
Construct a map to merge 3 collections together. |
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 overrides
packed
if a name appears in both.resolved
- resolved symbolic references. This list overrides the prior
list loose
, if an item appears in both. Items in this
list must also appear in loose
.
containsKey
public boolean containsKey(Object name)
- Specified by:
containsKey
in interface Map<String,Ref>
- Overrides:
containsKey
in class AbstractMap<String,Ref>
get
public Ref get(Object key)
- Specified by:
get
in interface Map<String,Ref>
- Overrides:
get
in class AbstractMap<String,Ref>
put
public Ref put(String keyName,
Ref value)
- Specified by:
put
in interface Map<String,Ref>
- Overrides:
put
in class AbstractMap<String,Ref>
remove
public Ref remove(Object key)
- Specified by:
remove
in interface Map<String,Ref>
- Overrides:
remove
in class AbstractMap<String,Ref>
isEmpty
public boolean isEmpty()
- Specified by:
isEmpty
in interface Map<String,Ref>
- Overrides:
isEmpty
in class AbstractMap<String,Ref>
entrySet
public Set<Map.Entry<String,Ref>> entrySet()
- Specified by:
entrySet
in interface Map<String,Ref>
- Specified by:
entrySet
in class AbstractMap<String,Ref>
toString
public String toString()
- Overrides:
toString
in class AbstractMap<String,Ref>
Copyright © 2012. All Rights Reserved.