Class FloatBufferWrapper

java.lang.Object
com.itextpdf.pdfocr.onnx.FloatBufferWrapper

public class FloatBufferWrapper extends Object
Wrapper class around FloatBuffer.
  • Constructor Details

  • Method Details

    • getFloatBuffer

      public FloatBuffer getFloatBuffer()
      Returns FloatBuffer that backs this buffer.

      Modifications to this buffer's content will cause the returned buffer's content to be modified, and vice versa.

      Returns:
      the array that backs this buffer
    • array

      public float[] array()
      Returns the float array that backs this buffer.

      Modifications to this buffer's content will cause the returned array's content to be modified, and vice versa.

      Returns:
      the array that backs this buffer
    • arrayOffset

      public int arrayOffset()
      Returns the offset within this buffer's backing array of the first element of the buffer.

      If this buffer is backed by an array then buffer position corresponds to array index position.

      Returns:
      the offset within this buffer's array of the first element of the buffer
    • get

      public float get()
      Relative get method. Reads the float at this buffer's current position, and then increments the position.
      Returns:
      the float at the buffer's current position
    • get

      public float get (int index)
      Absolute get method. Reads the float at the given index.
      Parameters:
      index - the index from which the float will be read
      Returns:
      the float at the given index
    • get

      public FloatBufferWrapper get (float[] dst)
      Relative bulk get method.

      This method transfers floats from this buffer into the given destination array.

      Parameters:
      dst - the destination array
      Returns:
      this buffer
    • rewind

      public FloatBufferWrapper rewind()
      Rewinds this buffer. The position is set to zero.

      Invoke this method before a sequence of channel-write or get operations, assuming that the limit has already been set appropriately.

      Returns:
      this buffer
    • put

      public FloatBufferWrapper put (float value)
      Relative put method.

      Writes the given float into this buffer at the current position, and then increments the position.

      Parameters:
      value - the float to be written
      Returns:
      this buffer
    • put

      public FloatBufferWrapper put (float[] src, int offset, int length)
      Relative bulk put method.

      This method transfers floats into this buffer from the given source array.

      Parameters:
      src - the array from which floats are to be read
      offset - the offset within the array of the first float to be read; must be non-negative and no larger than array.length
      length - the number of floats to be read from the given array; must be non-negative and no larger than array.length - offset
      Returns:
      this buffer
    • limit

      public int limit()
      Returns this buffer's limit.
      Returns:
      the limit of this buffer
    • limit

      public FloatBufferWrapper limit (int newLimit)
      Sets this buffer's limit. If the position is larger than the new limit then it is set to the new limit.
      Parameters:
      newLimit - the new limit value; must be non-negative and no larger than this buffer's capacity
      Returns:
      this buffer
    • duplicate

      public FloatBufferWrapper duplicate()
      Creates a new float buffer that shares this buffer's content.

      The content of the new buffer will be that of this buffer. Changes to this buffer's content will be visible in the new buffer, and vice versa; the two buffers' position and limit will be independent.

      The new buffer's capacity, limit, position and byte order will be identical to those of this buffer.

      Returns:
      the new float buffer
    • remaining

      public int remaining()
      Returns the number of elements between the current position and the limit.
      Returns:
      the number of elements remaining in this buffer
    • position

      public FloatBufferWrapper position (int newPosition)
      Sets this buffer's position.
      Parameters:
      newPosition - the new position value; must be non-negative and no larger than the current limit
      Returns:
      this buffer
    • slice

      public FloatBufferWrapper slice()
      Creates a new float buffer whose content is a shared subsequence of this buffer's content.

      The content of the new buffer will start at this buffer's current position. Changes to this buffer's content will be visible in the new buffer, and vice versa; the two buffers' position and limit values will be independent.

      The new buffer's position will be zero, its capacity and its limit will be the number of floats remaining in this buffer and its byte order will be identical to that of this buffer.

      Returns:
      the new float buffer
    • wrap

      public static FloatBufferWrapper wrap (float[] array)
      Wraps a float array into a buffer.

      The new buffer will be backed by the given float array; that is, modifications to the buffer will cause the array to be modified and vice versa. The new buffer's capacity and limit will be array.length, its position will be zero and its byte order will be the native order of the underlying hardware. Its backing array will be the given array, and its array offset will be zero.

      Parameters:
      array - the array that will back this buffer
      Returns:
      the new float buffer
    • allocate

      public static FloatBufferWrapper allocate (int capacity)
      Allocates a new float buffer.

      The new buffer's position will be zero, its limit will be its capacity, its mark will be undefined, each of its elements will be initialized to zero, and its byte order will be the native order of the underlying hardware. It will have a backing array, and its array offset will be zero.

      Parameters:
      capacity - the new buffer's capacity, in floats
      Returns:
      the new float buffer