Class IntList

java.lang.Object
com.pnfsoftware.jeb.util.collect.IntList

@Ser public class IntList extends Object
A memory-efficient list of int primitives. Additions, retrieval, updates are supported. Deletes and insertions are not supported.

This class is not thread-safe.

Note: Object.hashCode() and Object.equals(Object) are not overridden.

Implementation note: internally, the primitives are stored in multiple buckets. The user may specify an initial bucket capacity and maximum capacity.

  • Constructor Summary

    Constructors
    Constructor
    Description
    Create a list with an initial capacity of 16 and bucket capacity of 65,536.
    IntList(int initialCapacity, int bucketCapacity)
    Create a list with custom bucket sizing.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(int val)
    Append a value.
    void
    Remove all elements.
    int
    get(int index)
    Retrieve an element.
    boolean
     
    void
    set(int index, int val)
    Update an element.
    int
     
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • IntList

      public IntList()
      Create a list with an initial capacity of 16 and bucket capacity of 65,536.
    • IntList

      public IntList(int initialCapacity, int bucketCapacity)
      Create a list with custom bucket sizing.
      Parameters:
      initialCapacity - initial bucket capacity
      bucketCapacity - maximum bucket capacity
  • Method Details

    • size

      public int size()
      Returns:
      number of elements
    • isEmpty

      public boolean isEmpty()
      Returns:
      true if this list has no elements
    • clear

      public void clear()
      Remove all elements.
    • get

      public int get(int index)
      Retrieve an element.
      Parameters:
      index - element index
      Returns:
      value at the index
    • add

      public void add(int val)
      Append a value.
      Parameters:
      val - value to append
    • set

      public void set(int index, int val)
      Update an element.
      Parameters:
      index - element index
      val - new value
    • toString

      public String toString()
      Overrides:
      toString in class Object