Package org.eclipse.jgit.treewalk.filter
Class ByteArraySet
- java.lang.Object
-
- org.eclipse.jgit.treewalk.filter.ByteArraySet
-
class ByteArraySet extends java.lang.Object
Specialized set for byte arrays, interpreted as strings for use inPathFilterGroup.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 Classes Modifier and Type Class Description (package private) static class
ByteArraySet.Hasher
An incremental hash function.
-
Constructor Summary
Constructors Constructor Description ByteArraySet(int capacity)
Create an empty set.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) byte[]
addIfAbsent(byte[] newValue, int length, int hash)
Store a byte array for future lookup.private int
chainlength(byte[] b)
(package private) boolean
contains(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 boolean
equals(byte[] storedObj, byte[] toFind, int length)
private byte[]
get(byte[] toFind, int length, int hash)
private void
grow()
private void
initTable(int sz)
private void
insert(byte[] newValue, int hash)
(package private) boolean
isEmpty()
(package private) int
size()
(package private) byte[][]
toArray()
java.lang.String
toString()
-
-
-
Field Detail
-
size
private int size
-
grow
private int grow
-
mask
private int mask
-
table
private byte[][] table
-
hasher
private ByteArraySet.Hasher hasher
-
-
Method Detail
-
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:
newValue
if 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
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
chainlength
private int chainlength(byte[] b)
-
toArray
byte[][] toArray()
-
-