Class IntList


public class IntList extends ElementList
Resizable-array implementation for native int values.
Author:
BaseX Team 2005-21, BSD License, Christian Gruen
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected int[]
    Element container.

    Fields inherited from class org.basex.util.list.ElementList

    factor, size
  • Constructor Summary

    Constructors
    Constructor
    Description
    Default constructor.
    IntList(double factor)
    Constructor, specifying a resize factor.
    IntList(int[] elements)
    Lightweight constructor, adopting the specified elements.
    IntList(long capacity)
    Constructor with initial capacity.
  • Method Summary

    Modifier and Type
    Method
    Description
    final IntList
    add(int element)
    Adds an element to the array.
    final IntList
    add(int... elements)
    Adds elements to the array.
    final boolean
    contains(int element)
    Checks if the specified element is found in the list.
    final int[]
    createOrder(boolean asc)
    Sorts the data and returns an array with offsets to the sorted array.
    final IntList
    ddo()
    Sorts the data and removes distinct values.
    boolean
     
    final int[]
    Returns an array with all elements and invalidates the internal array.
    final int
    get(int index)
    Returns the element at the specified position.
    final void
    incFrom(int diff, int index)
    Adds a difference to all elements starting from the specified index.
    final void
    insert(int index, int... elements)
    Inserts elements at the specified index position.
    final int
    Returns the uppermost element from the stack.
    final int
    pop()
    Pops the uppermost element from the stack.
    final void
    push(int element)
    Pushes an element onto the stack.
    final int
    remove(int index)
    Removes the element at the specified position.
    final void
    removeAll(int element)
    Removes all occurrences of the specified element from the list.
    Reverses the order of the elements.
    final void
    set(int index, int element)
    Stores an element at the specified position.
    Sorts the data.
    final void
    sort(byte[][] values, boolean asc, boolean num)
    Sorts the data in the order of the specified token array.
    final void
    sort(double[] values, boolean asc)
    Sorts the data in the order of the specified numeric array.
    final void
    sort(int[] values, boolean asc)
    Sorts the data in the order of the specified numeric array.
    final void
    sort(long[] values, boolean asc)
    Sorts the data in the order of the specified numeric array.
    final int
    sortedIndexOf(int element)
    Searches the specified element via binary search.
    final int[]
    Returns an array with all elements.
     

    Methods inherited from class org.basex.util.list.ElementList

    isEmpty, newCapacity, newCapacity, reset, size, size

    Methods inherited from class java.lang.Object

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

    • list

      protected int[] list
      Element container.
  • Constructor Details

    • IntList

      public IntList()
      Default constructor.
    • IntList

      public IntList(long capacity)
      Constructor with initial capacity.
      Parameters:
      capacity - array capacity
    • IntList

      public IntList(double factor)
      Constructor, specifying a resize factor. Smaller values are more memory-saving, while larger values will provide better performance.
      Parameters:
      factor - resize factor
    • IntList

      public IntList(int[] elements)
      Lightweight constructor, adopting the specified elements.
      Parameters:
      elements - initial array
  • Method Details

    • add

      public final IntList add(int element)
      Adds an element to the array.
      Parameters:
      element - element to be added
      Returns:
      self reference
    • add

      public final IntList add(int... elements)
      Adds elements to the array.
      Parameters:
      elements - elements to be added
      Returns:
      self reference
    • get

      public final int get(int index)
      Returns the element at the specified position.
      Parameters:
      index - index of the element to return
      Returns:
      element
    • set

      public final void set(int index, int element)
      Stores an element at the specified position.
      Parameters:
      index - index of the element to replace
      element - element to be stored
    • contains

      public final boolean contains(int element)
      Checks if the specified element is found in the list.
      Parameters:
      element - element to be found
      Returns:
      result of check
    • insert

      public final void insert(int index, int... elements)
      Inserts elements at the specified index position.
      Parameters:
      index - inserting position
      elements - elements to be inserted
    • removeAll

      public final void removeAll(int element)
      Removes all occurrences of the specified element from the list.
      Parameters:
      element - element to be removed
    • remove

      public final int remove(int index)
      Removes the element at the specified position.
      Parameters:
      index - index of the element to remove
      Returns:
      removed element
    • incFrom

      public final void incFrom(int diff, int index)
      Adds a difference to all elements starting from the specified index.
      Parameters:
      diff - difference
      index - index of the first element
    • peek

      public final int peek()
      Returns the uppermost element from the stack.
      Returns:
      the uppermost element
    • pop

      public final int pop()
      Pops the uppermost element from the stack.
      Returns:
      the popped element
    • push

      public final void push(int element)
      Pushes an element onto the stack.
      Parameters:
      element - element
    • sortedIndexOf

      public final int sortedIndexOf(int element)
      Searches the specified element via binary search. Note that all elements must be sorted.
      Parameters:
      element - element to be found
      Returns:
      index of the search key, or the negative insertion point - 1
    • toArray

      public final int[] toArray()
      Returns an array with all elements.
      Returns:
      array
    • finish

      public final int[] finish()
      Returns an array with all elements and invalidates the internal array. Warning: the function must only be called if the list is discarded afterwards.
      Returns:
      array (internal representation!)
    • ddo

      public final IntList ddo()
      Sorts the data and removes distinct values.
      Returns:
      self reference
    • reverse

      public IntList reverse()
      Reverses the order of the elements.
      Returns:
      self reference
    • createOrder

      public final int[] createOrder(boolean asc)
      Sorts the data and returns an array with offsets to the sorted array. See Array.createOrder(int[], boolean)
      Parameters:
      asc - ascending order
      Returns:
      array with new order
    • sort

      public IntList sort()
      Sorts the data.
      Returns:
      self reference
    • sort

      public final void sort(byte[][] values, boolean asc, boolean num)
      Sorts the data in the order of the specified token array. Note that the input array will be resorted as well. The algorithm is derived from Arrays.sort(int[]).
      Parameters:
      values - values to sort by
      asc - ascending order
      num - numeric sort
    • sort

      public final void sort(double[] values, boolean asc)
      Sorts the data in the order of the specified numeric array. Note that the input array will be resorted as well. The algorithm is derived from Arrays.sort(int[]).
      Parameters:
      values - values to sort by
      asc - ascending order
    • sort

      public final void sort(int[] values, boolean asc)
      Sorts the data in the order of the specified numeric array. Note that the input array will be resorted as well. The algorithm is derived from Arrays.sort(int[]).
      Parameters:
      values - values to sort by
      asc - ascending order
    • sort

      public final void sort(long[] values, boolean asc)
      Sorts the data in the order of the specified numeric array. Note that the input array will be resorted as well. The algorithm is derived from Arrays.sort(int[]).
      Parameters:
      values - values to sort by
      asc - ascending order
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object