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[]. Thelongs
member should never be null; useEMPTY_LONGS
if necessary.
-
-
Field Summary
Fields Modifier and Type Field Description static long[]
EMPTY_LONGS
An empty long array for convenienceint
length
Length of used longs.long[]
longs
The contents of the LongsRef.int
offset
Offset of first valid long.
-
Constructor Summary
Constructors Constructor Description LongsRef()
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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.int
compareTo(LongsRef other)
Signed int order comparisonvoid
copyLongs(LongsRef other)
static LongsRef
deepCopyOf(LongsRef other)
Creates a new IntsRef that points to a copy of the longs fromother
boolean
equals(java.lang.Object other)
void
grow(int newLength)
Used to grow the reference array.int
hashCode()
boolean
isValid()
Performs internal consistency checks.boolean
longsEquals(LongsRef other)
java.lang.String
toString()
-
-
-
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:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object other)
- Overrides:
equals
in classjava.lang.Object
-
longsEquals
public boolean longsEquals(LongsRef other)
-
compareTo
public int compareTo(LongsRef other)
Signed int order comparison- Specified by:
compareTo
in 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:
toString
in classjava.lang.Object
-
deepCopyOf
public static LongsRef deepCopyOf(LongsRef other)
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)
-
-