Class ObjectArrayBuffer<T>

java.lang.Object
com.oracle.truffle.regex.tregex.buffer.AbstractArrayBuffer
com.oracle.truffle.regex.tregex.buffer.ObjectArrayBuffer<T>
All Implemented Interfaces:
Iterable<T>

public final class ObjectArrayBuffer<T> extends AbstractArrayBuffer implements Iterable<T>
This class is designed as a "scratchpad" for generating many Object arrays of unknown size. It will never shrink its internal buffer, so it should be disposed as soon as it is no longer needed.

Usage Example:

 SomeClass[] typedArray = new SomeClass[0];
 ObjectArrayBuffer buf = new ObjectArrayBuffer();
 List<SomeClass[]> results = new ArrayList<>();
 for (Object obj : listOfThingsToProcess) {
     for (Object x : obj.thingsThatShouldBecomeSomeClass()) {
         buf.add(someCalculation(x));
     }
     results.add(buf.toArray(typedArray));
     buf.clear();
 }
 
  • Constructor Details

    • ObjectArrayBuffer

      public ObjectArrayBuffer()
    • ObjectArrayBuffer

      public ObjectArrayBuffer(int initialSize)
  • Method Details

    • get

      public T get(int i)
    • set

      public void set(int i, T obj)
    • add

      public void add(T o)
    • addAll

      public void addAll(ObjectArrayBuffer<T> other)
    • addAll

      public void addAll(Object[] arr)
    • addAll

      public void addAll(Object[] arr, int fromIndex, int toIndex)
    • pop

      public Object pop()
    • peek

      public Object peek()
    • asFixedSizeArray

      public ObjectArrayBuffer<T> asFixedSizeArray(int size)
    • sort

      public void sort(Comparator<T> comparator)
    • toArray

      public <ST> ST[] toArray(ST[] a)
    • iterator

      public Iterator<T> iterator()
      Specified by:
      iterator in interface Iterable<T>