Class IntArrayBuffer

java.lang.Object
com.oracle.truffle.regex.tregex.buffer.AbstractArrayBuffer
com.oracle.truffle.regex.tregex.buffer.IntArrayBuffer
All Implemented Interfaces:
Iterable<Integer>
Direct Known Subclasses:
IntRangesBuffer, StringBufferUTF32

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

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

    • buf

      protected int[] buf
  • Constructor Details

    • IntArrayBuffer

      public IntArrayBuffer()
    • IntArrayBuffer

      public IntArrayBuffer(int initialSize)
  • Method Details

    • getBuffer

      public int[] getBuffer()
    • add

      public void add(int c)
    • asFixedSizeArray

      public IntArrayBuffer asFixedSizeArray(int size, int initialValue)
    • get

      public int get(int index)
    • inc

      public void inc(int index)
    • set

      public void set(int index, int value)
    • addAll

      public void addAll(IntArrayBuffer o)
    • getLast

      public int getLast()
    • removeLast

      public int removeLast()
    • toArray

      public int[] toArray()
    • iterator

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