Class Field

java.lang.Object
games.stendhal.common.memory.Field

public class Field extends Object
Author:
silvio
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static <T> T[]
    append​(T[] field, int size, T... values)
    Appends entries to an array.
    static byte[]
    expand​(byte[] field, int newSize, boolean keepData)
    This method will return a new allocated array of size newSize if newSize is greater than field.length.
    static float[]
    expand​(float[] field, int newSize, boolean keepData)
    This method will return a new allocated array of size newSize if newSize is greater than field.length.
    static int[]
    expand​(int[] field, int newSize, boolean keepData)
    This method will return a new allocated array of size newSize if newSize is greater than field.length.
    static <T> T[]
    expand​(T[] field, int newSize, boolean keepData)
    This method will return a new allocated array of size newSize if newSize is greater than field.length.
    static float[]
    insert​(float[] field, int index, int size, float... values)
    Inserts entries into an array at a specific position.
    static <T> T[]
    insert​(T[] field, int index, int size, T... values)
    Inserts entries into an array at a specific position.
    static float[]
    rshift​(float[] field, int offset, int size, int shiftCount, boolean expandIfNeeded)
    This method shifts a part of an array to the right
    static <T> T[]
    rshift​(T[] field, int offset, int size, int shiftCount, boolean expandIfNeeded)
    This method shifts a part of an array to the right

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Field

      public Field()
  • Method Details

    • expand

      public static byte[] expand(byte[] field, int newSize, boolean keepData)
      This method will return a new allocated array of size newSize if newSize is greater than field.length. It will return the same array otherwise Only if keepData is set to true, the data of the array will be copied to the new allocated array
      Parameters:
      field - original array (can be null)
      newSize -
      keepData -
      Returns:
      - new or old array
    • expand

      public static int[] expand(int[] field, int newSize, boolean keepData)
      This method will return a new allocated array of size newSize if newSize is greater than field.length. It will return the same array otherwise Only if keepData is set to true, the data of the array will be copied to the new allocated array
      Parameters:
      field - original array (can be null)
      newSize -
      keepData -
      Returns:
      - new or old array
    • expand

      public static float[] expand(float[] field, int newSize, boolean keepData)
      This method will return a new allocated array of size newSize if newSize is greater than field.length. It will return the same array otherwise Only if keepData is set to true, the data of the array will be copied to the new allocated array
      Parameters:
      field - original array (can be null)
      newSize -
      keepData -
      Returns:
      - new or old array
    • expand

      public static <T> T[] expand(T[] field, int newSize, boolean keepData)
      This method will return a new allocated array of size newSize if newSize is greater than field.length. It will return the same array otherwise Only if keepData is set to true, the data of the array will be copied to the new allocated array
      Type Parameters:
      T - any object
      Parameters:
      field - original array (must not be null)
      newSize -
      keepData -
      Returns:
      - new or old array
    • rshift

      public static float[] rshift(float[] field, int offset, int size, int shiftCount, boolean expandIfNeeded)
      This method shifts a part of an array to the right
      Parameters:
      field - the whole array
      offset - the starting offset of the data to be shifted
      size - the size of the part to be shifted
      shiftCount - how much entries the data is shifted
      expandIfNeeded - if true the array will be expanted to match the shifted data otherwise the shifted data will be truncated to match the array size
      Returns:
      the array
    • rshift

      public static <T> T[] rshift(T[] field, int offset, int size, int shiftCount, boolean expandIfNeeded)
      This method shifts a part of an array to the right
      Parameters:
      field - the whole array (must not be null)
      offset - the starting offset of the data to be shifted
      size - the size of the part to be shifted
      shiftCount - how much entries the data is shifted
      expandIfNeeded - if true the array will be expanded to match the shifted data otherwise the shifted data will be truncated to match the array size
      Returns:
      the array
    • append

      public static <T> T[] append(T[] field, int size, T... values)
      Appends entries to an array. The array will be expanded if needed
      Parameters:
      field - the array that gets entries appended (must not be null)
      size - indicates the size of the array (this can differ from field.length)
      values - the entries to get appended
      Returns:
      the array
    • insert

      public static float[] insert(float[] field, int index, int size, float... values)
      Inserts entries into an array at a specific position. The array will be expanded if needed
      Parameters:
      field - the array where the data should be inserted
      index - the position where the data should be inserted
      size - indicates the size of the array (this can differ from field.length)
      values - the entries to be inserted
      Returns:
      the array
    • insert

      public static <T> T[] insert(T[] field, int index, int size, T... values)
      Inserts entries into an array at a specific position. The array will be expanded if needed
      Parameters:
      field - the array where the data should be inserted (must not be null)
      index - the position where the data should be inserted
      size - indicates the size of the array (this can differ from field.length)
      values - the entries to be inserted
      Returns:
      the array