Package org.apache.lucene.util
Class IntsRef
java.lang.Object
org.apache.lucene.util.IntsRef
- All Implemented Interfaces:
Cloneable
,Comparable<IntsRef>
Represents int[], as a slice (offset + length) into an existing int[]. The
ints
member
should never be null; use EMPTY_INTS
if necessary.- NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int[]
An empty integer array for convenienceint[]
The contents of the IntsRef.int
Length of used ints.int
Offset of first valid integer. -
Constructor Summary
ConstructorDescriptionIntsRef()
Create a IntsRef withEMPTY_INTS
IntsRef
(int capacity) Create a IntsRef pointing to a new array of sizecapacity
.IntsRef
(int[] ints, int offset, int length) This instance will directly reference ints w/o making a copy. -
Method Summary
Modifier and TypeMethodDescriptionclone()
Returns a shallow clone of this instance (the underlying ints are not copied and will be shared by both the returned object and this object.int
Signed int order comparisonstatic IntsRef
deepCopyOf
(IntsRef other) Creates a new IntsRef that points to a copy of the ints fromother
boolean
int
hashCode()
boolean
intsEquals
(IntsRef other) boolean
isValid()
Performs internal consistency checks.toString()
-
Field Details
-
EMPTY_INTS
public static final int[] EMPTY_INTSAn empty integer array for convenience -
ints
public int[] intsThe contents of the IntsRef. Should never benull
. -
offset
public int offsetOffset of first valid integer. -
length
public int lengthLength of used ints.
-
-
Constructor Details
-
IntsRef
public IntsRef()Create a IntsRef withEMPTY_INTS
-
IntsRef
public IntsRef(int capacity) Create a IntsRef pointing to a new array of sizecapacity
. Offset and length will both be zero. -
IntsRef
public IntsRef(int[] ints, int offset, int length) This instance will directly reference ints w/o making a copy. ints should not be null.
-
-
Method Details
-
clone
Returns a shallow clone of this instance (the underlying ints are not copied and will be shared by both the returned object and this object. -
hashCode
public int hashCode() -
equals
-
intsEquals
-
compareTo
Signed int order comparison- Specified by:
compareTo
in interfaceComparable<IntsRef>
-
toString
-
deepCopyOf
Creates a new IntsRef that points to a copy of the ints 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)
-