Class ShortArrayBuffer

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

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

 ShortArrayBuffer buf = new ShortArrayBuffer();
 List<short[]> results = new ArrayList<>();
 for (Object obj : listOfThingsToProcess) {
     for (Object x : obj.thingsThatShouldBecomeShorts()) {
         buf.add(someCalculation(x));
     }
     results.add(buf.toArray());
     buf.clear();
 }
 
  • Constructor Details

    • ShortArrayBuffer

      public ShortArrayBuffer()
    • ShortArrayBuffer

      public ShortArrayBuffer(int initialSize)
  • Method Details

    • get

      public short get(int i)
    • add

      public void add(short s)
    • addAll

      public void addAll(short[] values, int valuesLength)
    • peek

      public Object peek()
    • pop

      public Object pop()
    • toArray

      public short[] toArray()
    • iterator

      public PrimitiveIterator.OfInt iterator()
      Specified by:
      iterator in interface Iterable<Integer>