Class Struct<T extends Struct<T>>

All Implemented Interfaces:
Iterable<T>
Direct Known Subclasses:
BooleanPtr, BytePtr, CharPtr, DoublePtr, FloatPtr, FunctionPtr, IntPtr, LongPtr, MachineSizedFloatPtr, MachineSizedSIntPtr, MachineSizedUIntPtr, Ptr, ShortPtr, VoidPtr

public abstract class Struct<T extends Struct<T>>
extends NativeObject
implements Iterable<T>
Version:
$Id$
  • Constructor Details

    • Struct

      protected Struct()
    • Struct

      protected Struct​(long handle)
  • Method Details

    • copy

      public T copy()
    • copy

      public T copy​(int n)
    • copyWithMalloc

      public T copyWithMalloc()
    • copyWithMalloc

      public T copyWithMalloc​(int n)
    • as

      public <U extends NativeObject> U as​(Class<U> type)
      Description copied from class: NativeObject
      Casts this NativeObject to another NativeObject type.
      Overrides:
      as in class NativeObject
      Parameters:
      type - the type to cast to.
      Returns:
      a NativeObject that points to the same memory location as this NativeObject.
    • _sizeOf

      protected int _sizeOf()
    • clear

      public void clear()
    • clear

      public void clear​(int n)
    • free

      public void free()
    • iterator

      public Iterator<T> iterator()
      Description copied from interface: Iterable
      Returns an Iterator for the elements in this object.
      Specified by:
      iterator in interface Iterable<T extends Struct<T>>
      Returns:
      An Iterator instance.
    • iterator

      public Iterator<T> iterator​(int n)
    • wrap

      protected T wrap​(long address)
    • next

      public T next()
    • next

      public T next​(long delta)
    • previous

      public T previous()
    • previous

      public T previous​(long delta)
    • toArray

      public T[] toArray​(int n)
    • update

      public void update​(T o)
      Updates the memory starting at this Struct with the Struct starting at the specified instance.
      Parameters:
      o - the Struct to write to the address of this Struct.
      Throws:
      NullPointerException - if o is null.
      IllegalArgumentException - if the class of o is not the same as this Struct's class.
    • update

      public void update​(T o, int n)
      Updates the memory starting at this Struct with the Structs starting at the specified instance.
      Parameters:
      o - the first Struct to write to the address of this Struct.
      n - the number of Structs to write.
      Throws:
      NullPointerException - if o is null.
      IllegalArgumentException - if the class of o is not the same as this Struct's class.
    • update

      public void update​(T[] array)
      Updates the memory starting at this Struct with the Structs in the specified array.
      Parameters:
      array - the array of Structs to write.
      Throws:
      NullPointerException - if array or any of the objects in array are null.
      IllegalArgumentException - if the class of any of the objects in the array is not the same as this Struct's class.
    • toList

      public List<T> toList​(int n)
    • sizeOf

      public static int sizeOf()
    • sizeOf

      public static int sizeOf​(Struct<?> struct)
    • offsetOf

      public static int offsetOf​(int index)
    • allocate

      public static <T extends Struct<T>> T allocate​(Class<T> cls)
    • allocate

      public static <T extends Struct<T>> T allocate​(Class<T> cls, int n)
    • malloc

      public static <T extends Struct<T>> T malloc​(Class<T> cls)
    • malloc

      public static <T extends Struct<T>> T malloc​(Class<T> cls, int n)
    • toStruct

      public static <T extends Struct<T>> T toStruct​(Class<T> cls, long handle)