Class IntsRef

java.lang.Object
com.graphhopper.storage.IntsRef
All Implemented Interfaces:
Comparable<IntsRef>

public final class IntsRef extends Object implements Comparable<IntsRef>
Idea and most of the code is from Lucene. But the variables are final, except for the array content.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final IntsRef
    An IntsRef with an array of size 0.
    final int[]
    The contents of the IntsRef.
    final int
    Length of used ints.
    final int
    Offset of first valid integer.
  • Constructor Summary

    Constructors
    Constructor
    Description
    IntsRef(int capacity)
    Create a IntsRef pointing to a new int array of size capacity leading to capacity*32 bits.
    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
    int
    Signed int order comparison
    static IntsRef
    Creates a new IntsRef that points to a copy of the ints from other
    boolean
    equals(Object other)
     
    int
     
    boolean
     
    boolean
     
    boolean
    Performs internal consistency checks.
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • EMPTY

      public static final IntsRef EMPTY
      An IntsRef with an array of size 0.
    • ints

      public final int[] ints
      The contents of the IntsRef. Cannot be null.
    • offset

      public final int offset
      Offset of first valid integer.
    • length

      public final int length
      Length of used ints.
  • Constructor Details

    • IntsRef

      public IntsRef(int capacity)
      Create a IntsRef pointing to a new int array of size capacity leading to capacity*32 bits. Offset will be zero and length will be the capacity.
    • 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

    • 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>
    • 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)
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • isEmpty

      public boolean isEmpty()