Package org.apache.lucene.util

# Class IntsRef

java.lang.Object
org.apache.lucene.util.IntsRef

All Implemented Interfaces:
  `Cloneable`, `Comparable<IntsRef>`

public final class IntsRef extends Object implements Comparable<IntsRef>, Cloneable
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

  Fields
  Modifier and Type
  Field
  Description
  `static final int[]`
  `EMPTY_INTS`
  An empty integer array for convenience
  `int[]`
  `ints`
  The contents of the IntsRef.
  `int`
  `length`
  Length of used ints.
  `int`
  `offset`
  Offset of first valid integer.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `IntsRef()`
  Create a IntsRef with `EMPTY_INTS`
  `IntsRef(int capacity)`
  Create a IntsRef pointing to a new array of size `capacity`.
  `IntsRef(int[] ints, int offset, int length)`
  This instance will directly reference ints w/o making a copy.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `IntsRef`
  `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.
  `int`
  `compareTo(IntsRef other)`
  Signed int order comparison
  `static IntsRef`
  `deepCopyOf(IntsRef other)`
  Creates a new IntsRef that points to a copy of the ints from `other`
  `boolean`
  `equals(Object other)`
  `int`
  `hashCode()`
  `boolean`
  `intsEquals(IntsRef other)`
  `boolean`
  `isValid()`
  Performs internal consistency checks.
  `String`
  `toString()`

  ### Methods inherited from class java.lang.Object

  `finalize, getClass, notify, notifyAll, wait, wait, wait`

- ## Field Details

  - ### EMPTY_INTS

    public static final int[] EMPTY_INTS
    An empty integer array for convenience

  - ### ints

    public int[] ints
    The contents of the IntsRef. Should never be `null`.

  - ### offset

    public int offset
    Offset of first valid integer.

  - ### length

    public int length
    Length of used ints.

- ## Constructor Details

  - ### IntsRef

    public IntsRef()
    Create a IntsRef with `EMPTY_INTS`

  - ### IntsRef

    public IntsRef(int capacity)
    Create a IntsRef pointing to a new array of size `capacity`. 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

    public IntsRef 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.
    Overrides:
      `clone` in class `Object`
    See Also:
      - `deepCopyOf(org.apache.lucene.util.IntsRef)`

  - ### hashCode

    public int hashCode()
    Overrides:
      `hashCode` in class `Object`

  - ### equals

    public boolean equals(Object other)
    Overrides:
      `equals` in class `Object`

  - ### intsEquals

    public boolean intsEquals(IntsRef other)

  - ### compareTo

    public int compareTo(IntsRef other)
    Signed int order comparison
    Specified by:
      `compareTo` in interface `Comparable<IntsRef>`

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`

  - ### deepCopyOf

    public static IntsRef deepCopyOf(IntsRef other)
    Creates a new IntsRef that points to a copy of the ints from `other`

    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)