Class ByteList


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

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

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

    factor, size
  • Constructor Summary

    Constructors
    Constructor
    Description
    Default constructor.
    ByteList(long capacity)
    Constructor with initial array capacity.
  • Method Summary

    Modifier and Type
    Method
    Description
    add(byte[] elements)
    Adds elements to the container.
    add(byte[] elements, int start, int end)
    Adds a part of the specified elements to the container.
    add(int element)
    Adds an element to the array.
    boolean
     
    byte[]
    Returns an array with all elements and invalidates the internal array.
    final byte
    get(int index)
    Returns the element at the specified index position.
    final byte[]
    Returns an array with all elements and resets the array size.
    Reverses the order of the elements.
    byte[]
    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 byte[] list
      Element container.
  • Constructor Details

    • ByteList

      public ByteList()
      Default constructor.
    • ByteList

      public ByteList(long capacity)
      Constructor with initial array capacity.
      Parameters:
      capacity - array capacity 3
  • Method Details

    • add

      public ByteList add(int element)
      Adds an element to the array.
      Parameters:
      element - element to be added; will be cast to a byte
      Returns:
      self reference
    • add

      public ByteList add(byte[] elements)
      Adds elements to the container.
      Parameters:
      elements - elements to be added
      Returns:
      self reference
    • add

      public ByteList add(byte[] elements, int start, int end)
      Adds a part of the specified elements to the container.
      Parameters:
      elements - elements to be added
      start - start position
      end - end position
      Returns:
      self reference
    • get

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

      public byte[] toArray()
      Returns an array with all elements.
      Returns:
      array
    • next

      public final byte[] next()
      Returns an array with all elements and resets the array size.
      Returns:
      array
    • finish

      public byte[] 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!)
    • reverse

      public ByteList reverse()
      Reverses the order of the elements.
      Returns:
      self reference
    • equals

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

      public String toString()
      Overrides:
      toString in class Object