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 convenienceintLength of used longs.long[]The contents of the LongsRef.intOffset of first valid long. -
Constructor Summary
ConstructorsConstructorDescriptionLongsRef()Create a LongsRef withEMPTY_LONGSLongsRef(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.intSigned int order comparisonvoidstatic LongsRefdeepCopyOf(LongsRef other) Creates a new IntsRef that points to a copy of the longs fromotherbooleanvoidgrow(int newLength) Used to grow the reference array.inthashCode()booleanisValid()Performs internal consistency checks.booleanlongsEquals(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:
compareToin 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 fromotherThe 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)
-