Class LongArrayBuffer

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

public class LongArrayBuffer extends AbstractArrayBuffer implements Iterable<Long>
This class is designed as a "scratchpad" for generating many long 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:

 LongArrayBuffer buf = new LongArrayBuffer();
 List<long[]> results = new ArrayList<>();
 for (Object obj : listOfThingsToProcess) {
     for (Object x : obj.thingsThatShouldBecomeLongs()) {
         buf.add(someCalculation(x));
     }
     results.add(buf.toArray());
     buf.clear();
 }
 
  • Field Details

    • buf

      protected long[] buf
  • Constructor Details

    • LongArrayBuffer

      public LongArrayBuffer(int initialSize)
  • Method Details

    • get

      public long get(int i)
    • add

      public void add(long v)
    • addAll

      public void addAll(long[] v)
    • pop

      public long pop()
    • peek

      public long peek()
    • asFixedSizeArray

      public LongArrayBuffer asFixedSizeArray(int size)
    • asFixedSizeArray

      public LongArrayBuffer asFixedSizeArray(int size, int initialValue)
    • toArray

      public long[] toArray()
    • iterator

      public PrimitiveIterator.OfLong iterator()
      Specified by:
      iterator in interface Iterable<Long>