LongsRef (Lucene 10.5.1 core API)
Description: declaration: package: org.apache.lucene.util, class: LongsRef

Package org.apache.lucene.util

# Class LongsRef

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

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

public final class LongsRef extends Object implements Comparable<LongsRef>, Cloneable
Represents long[], as a slice (offset + length) into an existing long[]. The `longs` member should never be null; use `EMPTY_LONGS` 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 long[]`
  `EMPTY_LONGS`
  An empty long array for convenience
  `int`
  `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 with `EMPTY_LONGS`
  `LongsRef(int capacity)`
  Create a LongsRef pointing to a new array of size `capacity`.
  `LongsRef(long[] longs, int offset, int length)`
  This instance will directly reference longs w/o making a copy.

- ## Method Summary

  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 comparison
  `static LongsRef`
  `deepCopyOf(LongsRef other)`
  Creates a new LongsRef that points to a copy of the longs from `other`
  `boolean`
  `equals(Object other)`
  `int`
  `hashCode()`
  `boolean`
  `isValid()`
  Performs internal consistency checks.
  `boolean`
  `longsEquals(LongsRef other)`
  `String`
  `toString()`

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

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

- ## Field Details

  - ### EMPTY_LONGS

    public static final long[] EMPTY_LONGS
    An empty long array for convenience

  - ### longs

    public long[] longs
    The contents of the LongsRef. Should never be `null`.

  - ### offset

    public int offset
    Offset of first valid long.

  - ### length

    public int length
    Length of used longs.

- ## Constructor Details

  - ### LongsRef

    public LongsRef()
    Create a LongsRef with `EMPTY_LONGS`

  - ### LongsRef

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

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

  - ### hashCode

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

  - ### equals

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

  - ### longsEquals

    public boolean longsEquals(LongsRef other)

  - ### compareTo

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

  - ### toString

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

  - ### deepCopyOf

    public static LongsRef deepCopyOf(LongsRef other)
    Creates a new LongsRef that points to a copy of the longs 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)