Top Description Inners Fields Constructors Methods
org.eclipse.jgit.treewalk.filter

pack-priv Class ByteArraySet

extends Object
Class Inheritance
Imports
java.util.Arrays, .Set, java.util.stream.Collectors, org.eclipse.jgit.util.RawParseUtils

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 and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
ByteArraySet.Hasher

An incremental hash function.

Field Summary

Modifier and TypeField and Description
private int
private ByteArraySet.Hasher
private int
private int
private byte[][]

Constructor Summary

AccessConstructor and Description
pack-priv
ByteArraySet(int
initial capacity of the set
capacity
)

Create an empty set.

Method Summary

Modifier and TypeMethod and Description
pack-priv byte[]

Returns:

newValue if stored, or the prior value already stored and that would have been returned had the caller used get(newValue) first.
addIfAbsent
(final byte[]
the array to store by reference if the length is the same as the length parameter
newValue
,
int
The number of bytes in newValue that are used
length
,
int
pre-computed hash of toFind
hash
)

Store a byte array for future lookup.

private int
chainlength(byte[] b)

pack-priv boolean

Returns:

true if the mapping exists for this byte array; false otherwise.
contains
(byte[]
array to find.
toFind
,
int
The number of bytes in toFind that are used
length
,
int
pre-computed hash of toFind
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)

pack-priv boolean

Returns:

true if size() is 0
isEmpty
()

Returns true if size() is 0

pack-priv int

Returns:

number of arrays in the set
size
()

Returns number of arrays in the set

pack-priv byte[][]
pack-priv Set<byte[]>
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

growback to summary
private int grow
hasherback to summary
private ByteArraySet.Hasher hasher
maskback to summary
private int mask
sizeback to summary
private int size
tableback to summary
private byte[][] table

Constructor Detail

ByteArraySetback to summary
pack-priv ByteArraySet(int capacity)

Create an empty set.

Parameters
capacity:int

initial capacity of the set

Method Detail

addIfAbsentback to summary
pack-priv byte[] addIfAbsent(final 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:byte[]

the array to store by reference if the length is the same as the length parameter

length:int

The number of bytes in newValue that are used

hash:int

pre-computed hash of toFind

Returns:byte[]

newValue if stored, or the prior value already stored and that would have been returned had the caller used get(newValue) first.

chainlengthback to summary
private int chainlength(byte[] b)
containsback to summary
pack-priv boolean contains(byte[] toFind, int length, int hash)

Returns true if this set contains the specified array.

Parameters
toFind:byte[]

array to find.

length:int

The number of bytes in toFind that are used

hash:int

pre-computed hash of toFind

Returns:boolean

true if the mapping exists for this byte array; false otherwise.

copyIfNotSameSizeback to summary
private static byte[] copyIfNotSameSize(byte[] newValue, int length)
equalsback to summary
private static boolean equals(byte[] storedObj, byte[] toFind, int length)
getback to summary
private byte[] get(byte[] toFind, int length, int hash)
growback to summary
private void grow()
initTableback to summary
private void initTable(int sz)
insertback to summary
private void insert(byte[] newValue, int hash)
isEmptyback to summary
pack-priv boolean isEmpty()

Returns true if size() is 0

Returns:boolean

true if size() is 0

sizeback to summary
pack-priv int size()

Returns number of arrays in the set

Returns:int

number of arrays in the set

toArrayback to summary
pack-priv byte[][] toArray()
toSetback to summary
pack-priv Set<byte[]> toSet()
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
org.eclipse.jgit.treewalk.filter back to summary

pack-priv Class ByteArraySet.Hasher

extends Object
Class Inheritance

An incremental hash function.

Field Summary

Modifier and TypeField and Description
private byte[]
private int
private int
private int

Constructor Summary

AccessConstructor and Description
pack-priv
Hasher(byte[] data, int length)

Method Summary

Modifier and TypeMethod and Description
pack-priv int
pack-priv int
hash()

pack-priv boolean
pack-priv void
init(byte[] d, int l)

public int
pack-priv int
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

databack to summary
private byte[] data
hashback to summary
private int hash
lengthback to summary
private int length
posback to summary
private int pos

Constructor Detail

Hasherback to summary
pack-priv Hasher(byte[] data, int length)

Method Detail

getHashback to summary
pack-priv int getHash()
hashback to summary
pack-priv int hash()
hasNextback to summary
pack-priv boolean hasNext()
initback to summary
pack-priv void init(byte[] d, int l)
lengthback to summary
public int length()
nextHashback to summary
pack-priv int nextHash()
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override