Package org.eclipse.jgit.treewalk.filter
Class ByteArraySet
java.lang.Object
org.eclipse.jgit.treewalk.filter.ByteArraySet
Specialized set for byte arrays, interpreted as strings for use in
PathFilterGroup.Group. Most methods assume the hash is already know
and therefore requires the caller to supply it beforehand. The implementation
is a loose derivative of ObjectIdSubclassMap.
The class is only intended for use by PathFilterGroup.
The arrays stored may not be changed after adding.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static classAn incremental hash function. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) byte[]addIfAbsent(byte[] newValue, int length, int hash) Store a byte array for future lookup.private intchainlength(byte[] b) (package private) booleancontains(byte[] toFind, int length, int hash) Returns true if this set contains the specified array.private static byte[]copyIfNotSameSize(byte[] newValue, int length) private static booleanequals(byte[] storedObj, byte[] toFind, int length) private byte[]get(byte[] toFind, int length, int hash) private voidgrow()private voidinitTable(int sz) private voidinsert(byte[] newValue, int hash) (package private) booleanisEmpty()(package private) intsize()(package private) byte[][]toArray()toString()
-
Field Details
-
size
private int size -
grow
private int grow -
mask
private int mask -
table
private byte[][] table -
hasher
-
-
Constructor Details
-
ByteArraySet
ByteArraySet(int capacity) Create an empty set.- Parameters:
capacity-
-
-
Method Details
-
get
private byte[] get(byte[] toFind, int length, int hash) -
equals
private static boolean equals(byte[] storedObj, byte[] toFind, int length) -
contains
boolean contains(byte[] toFind, int length, int hash) Returns true if this set contains the specified array.- Parameters:
toFind- array to find.length- The number of bytes in toFind that are usedhash- pre-computed hash of toFind- Returns:
- true if the mapping exists for this byte array; false otherwise.
-
addIfAbsent
byte[] addIfAbsent(byte[] newValue, int length, int hash) Store a byte array for future lookup.Stores
newValue, but only if it does not already exist in the set. Callers can tell if the value is new by checking the return value with reference equality:byte[] obj = ...; boolean wasNew = map.addIfAbsent(array, length, hash) == array;
- Parameters:
newValue- the array to store by reference if the length is the same as the length parameterlength- The number of bytes in newValue that are usedhash- pre-computed hash of toFind- Returns:
newValueif stored, or the prior value already stored and that would have been returned had the caller usedget(newValue)first.
-
copyIfNotSameSize
private static byte[] copyIfNotSameSize(byte[] newValue, int length) -
size
int size()- Returns:
- number of arrays in the set
-
isEmpty
boolean isEmpty()- Returns:
- true if
size()is 0.
-
insert
private void insert(byte[] newValue, int hash) -
grow
private void grow() -
initTable
private void initTable(int sz) -
toString
-
chainlength
private int chainlength(byte[] b) -
toArray
byte[][] toArray()
-