Package org.apache.lucene.util
Class LongsRef
- java.lang.Object
-
- org.apache.lucene.util.LongsRef
-
- All Implemented Interfaces:
java.lang.Cloneable,java.lang.Comparable<LongsRef>
public final class LongsRef extends java.lang.Object implements java.lang.Comparable<LongsRef>, java.lang.Cloneable
Represents long[], as a slice (offset + length) into an existing long[]. Thelongsmember should never be null; useEMPTY_LONGSif necessary.
-
-
Field Summary
Fields Modifier and Type Field Description static long[]EMPTY_LONGSAn empty long array for convenienceintlengthLength of used longs.long[]longsThe contents of the LongsRef.intoffsetOffset of first valid long.
-
Constructor Summary
Constructors Constructor Description LongsRef()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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description LongsRefclone()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.intcompareTo(LongsRef other)Signed int order comparisonvoidcopyLongs(LongsRef other)static LongsRefdeepCopyOf(LongsRef other)Creates a new IntsRef that points to a copy of the longs fromotherbooleanequals(java.lang.Object other)voidgrow(int newLength)Used to grow the reference array.inthashCode()booleanisValid()Performs internal consistency checks.booleanlongsEquals(LongsRef other)java.lang.StringtoString()
-
-
-
Constructor Detail
-
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 Detail
-
clone
public LongsRef 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()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object other)
- Overrides:
equalsin classjava.lang.Object
-
longsEquals
public boolean longsEquals(LongsRef other)
-
compareTo
public int compareTo(LongsRef other)
Signed int order comparison- Specified by:
compareToin interfacejava.lang.Comparable<LongsRef>
-
copyLongs
public void copyLongs(LongsRef other)
-
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
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
deepCopyOf
public static LongsRef deepCopyOf(LongsRef other)
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)
-
-