class ByteArraySet
extends java.lang.Object
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.
Modifier and Type | Class and Description |
---|---|
(package private) static class |
ByteArraySet.Hasher
An incremental hash function.
|
Modifier and Type | Field and Description |
---|---|
private int |
grow |
private ByteArraySet.Hasher |
hasher |
private int |
mask |
private int |
size |
private byte[][] |
table |
Constructor and Description |
---|
ByteArraySet(int capacity)
Create an empty set.
|
Modifier and Type | Method and 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() |
private int size
private int grow
private int mask
private byte[][] table
private ByteArraySet.Hasher hasher
ByteArraySet(int capacity)
capacity
- private byte[] get(byte[] toFind, int length, int hash)
private static boolean equals(byte[] storedObj, byte[] toFind, int length)
boolean contains(byte[] toFind, int length, int hash)
toFind
- array to find.length
- The number of bytes in toFind that are usedhash
- pre-computed hash of toFindbyte[] addIfAbsent(byte[] newValue, int length, int hash)
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;
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 toFindnewValue
if stored, or the prior value already stored and
that would have been returned had the caller used
get(newValue)
first.private static byte[] copyIfNotSameSize(byte[] newValue, int length)
int size()
boolean isEmpty()
size()
is 0.private void insert(byte[] newValue, int hash)
private void grow()
private void initTable(int sz)
public java.lang.String toString()
toString
in class java.lang.Object
private int chainlength(byte[] b)
byte[][] toArray()