Class NaturalRanking.IntList

java.lang.Object
org.apache.commons.statistics.ranking.NaturalRanking.IntList
Enclosing class:
NaturalRanking

private static class NaturalRanking.IntList extends Object
An expandable list of int values. This allows tracking array positions without using boxed values in a List<Integer>.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private int[]
    The list data.
    private final int
    The maximum size of array to allocate.
    private int
    The size of the list.
  • Constructor Summary

    Constructors
    Constructor
    Description
    IntList(int max)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    (package private) void
    add(int value)
    Adds the value to the list.
    (package private) void
    Clear the list.
    (package private) int
    get(int index)
    Gets the element at the specified index.
    (package private) void
    shuffle(IntUnaryOperator randomIntFunction)
    Shuffle the list.
    (package private) int
    Gets the number of elements in the list.
    private static void
    swap(int[] array, int i, int j)
    Swaps the two specified elements in the specified array.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • max

      private final int max
      The maximum size of array to allocate.
    • size

      private int size
      The size of the list.
    • data

      private int[] data
      The list data. Initialised with space to store a tie of 2 values.
  • Constructor Details

    • IntList

      IntList(int max)
      Parameters:
      max - Maximum size of array to allocate. Can use the length of the parent array for which this is used to track indices.
  • Method Details

    • add

      void add(int value)
      Adds the value to the list.
      Parameters:
      value - the value
    • get

      int get(int index)
      Gets the element at the specified index.
      Parameters:
      index - Element index
      Returns:
      the element
    • size

      int size()
      Gets the number of elements in the list.
      Returns:
      the size
    • clear

      void clear()
      Clear the list.
    • shuffle

      void shuffle(IntUnaryOperator randomIntFunction)
      Shuffle the list.
      Parameters:
      randomIntFunction - Function maps positive x randomly to [0, x).
    • swap

      private static void swap(int[] array, int i, int j)
      Swaps the two specified elements in the specified array.
      Parameters:
      array - Data array
      i - First index
      j - Second index