Package org.apache.lucene.util
Class LongsRef
java.lang.Object
org.apache.lucene.util.LongsRef
- All Implemented Interfaces:
Cloneable
,Comparable<LongsRef>
Represents long[], as a slice (offset + length) into an
existing long[]. The
longs
member should never be null; use
EMPTY_LONGS
if necessary.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final long[]
An empty long array for convenienceint
Length of used longs.long[]
The contents of the LongsRef.int
Offset of first valid long. -
Constructor Summary
ConstructorsConstructorDescriptionLongsRef()
Create a LongsRef withEMPTY_LONGS
LongsRef
(int capacity) Create a LongsRef pointing to a new array of sizecapacity
.LongsRef
(long[] longs, int offset, int length) This instance will directly reference longs w/o making a copy. -
Method Summary
Modifier and TypeMethodDescriptionclone()
Returns a shallow clone of this instance (the underlying longs are not copied and will be shared by both the returned object and this object.int
Signed int order comparisonvoid
static LongsRef
deepCopyOf
(LongsRef other) Creates a new IntsRef that points to a copy of the longs fromother
boolean
void
grow
(int newLength) Used to grow the reference array.int
hashCode()
boolean
isValid()
Performs internal consistency checks.boolean
longsEquals
(LongsRef other) toString()
-
Field Details
-
EMPTY_LONGS
public static final long[] EMPTY_LONGSAn empty long array for convenience -
longs
public long[] longsThe contents of the LongsRef. Should never benull
. -
offset
public int offsetOffset of first valid long. -
length
public int lengthLength of used longs.
-
-
Constructor Details
-
LongsRef
public LongsRef()Create a LongsRef withEMPTY_LONGS
-
LongsRef
public LongsRef(int capacity) Create a LongsRef pointing to a new array of sizecapacity
. Offset and length will both be zero. -
LongsRef
public LongsRef(long[] longs, int offset, int length) This instance will directly reference longs w/o making a copy. longs should not be null
-
-
Method Details
-
clone
Returns a shallow clone of this instance (the underlying longs are not copied and will be shared by both the returned object and this object. -
hashCode
public int hashCode() -
equals
-
longsEquals
-
compareTo
Signed int order comparison- Specified by:
compareTo
in interfaceComparable<LongsRef>
-
copyLongs
-
grow
public void grow(int newLength) Used to grow the reference array. In general this should not be used as it does not take the offset into account. -
toString
-
deepCopyOf
Creates a new IntsRef that points to a copy of the longs fromother
The returned IntsRef will have a length of other.length and an offset of zero.
-
isValid
public boolean isValid()Performs internal consistency checks. Always returns true (or throws IllegalStateException)
-