Class IntArrayBuilder

java.lang.Object
org.aesh.terminal.utils.IntArrayBuilder

public class IntArrayBuilder extends Object
A dynamically resizable int array builder similar to StringBuilder.
Author:
Ståle W. Pedersen
  • Constructor Details

    • IntArrayBuilder

      public IntArrayBuilder()
      Create an empty IntArrayBuilder with default initial capacity.
    • IntArrayBuilder

      public IntArrayBuilder(int size)
      Create an empty IntArrayBuilder with the specified initial capacity.
      Parameters:
      size - the initial capacity
    • IntArrayBuilder

      public IntArrayBuilder(int[] ints)
      Create an IntArrayBuilder initialized with a copy of the given array.
      Parameters:
      ints - the initial values to copy into this builder
  • Method Details

    • append

      public IntArrayBuilder append(int[] str)
      Append an array of integers to this builder.
      Parameters:
      str - the integers to append
      Returns:
      this builder for method chaining
    • append

      public IntArrayBuilder append(int c)
      Append a single integer to this builder.
      Parameters:
      c - the integer to append
      Returns:
      this builder for method chaining
    • toArray

      public int[] toArray()
      Return the contents of this builder as a new int array. If the internal buffer is exactly the right size, it is returned directly to avoid a copy. The builder should not be used after calling this method.
      Returns:
      an array containing all appended integers
    • size

      public int size()
      Return the number of integers currently in this builder.
      Returns:
      the current size
    • deleteLastEntry

      public void deleteLastEntry()
      Remove the last entry from this builder. If the builder is empty, this method does nothing.