Class StructureInfo

java.lang.Object
de.linusdev.lutils.struct.info.StructureInfo
All Implemented Interfaces:
MemorySizeable
Direct Known Subclasses:
ArrayStructureInfo, BBMatrixInfo, BBVectorInfo, ComplexStructureInfo

public class StructureInfo extends Object implements MemorySizeable
  • Field Details

    • alignment

      protected final int alignment
    • compressed

      protected final boolean compressed
    • size

      protected final int size
    • sizes

      protected final int @NotNull [] sizes
      array of item sizes. Always alternating between padding and item. First and last element are always a padding.

      Layout:
      [0]: pad, [1]: size, [2]: pad, [3]: size, [4]: pad, [5]: size, ...
  • Constructor Details

    • StructureInfo

      public StructureInfo(int alignment, boolean compressed, int prePadding, int size, int postPadding)
      Manually create StructureInfo.
      Parameters:
      alignment - alignment of the structure
      compressed - whether the structure is compressed, see isCompressed()
      prePadding - padding before the Structure
      size - size of the actual Structure (without any padding)
      postPadding - padding after the Structure
    • StructureInfo

      protected StructureInfo(int alignment, boolean compressed, int size, int @NotNull [] sizes)
  • Method Details

    • getRequiredSize

      public int getRequiredSize()
      Description copied from interface: MemorySizeable
      Required size including padding.
      Specified by:
      getRequiredSize in interface MemorySizeable
      Returns:
      the size required by this object in memory
    • getAlignment

      public int getAlignment()
      Description copied from interface: MemorySizeable
      The recommended alignment of this object in memory. Either 1, 2, 4, 8 or 16.
      Specified by:
      getAlignment in interface MemorySizeable
      Returns:
      recommended alignment
    • isCompressed

      public boolean isCompressed()
      Whether this StructureInfo is compressed. Compressed means, it should ignore the size of the individual elements when aligning the structure.
      Returns:
      true if it is compressed.
    • getSizes

      public int @NotNull [] getSizes()