java.lang.Object
org.aspectj.org.eclipse.jdt.internal.core.nd.field.FieldList<T>
All Implemented Interfaces:
IDestructableField, IField

public class FieldList<T> extends Object implements IDestructableField
Stores a singly-linked list of blocks, each of which contains a variable number of embedded elements. Each block contains a header containing the size of the block and pointer to the next block, followed by the embedded elements themselves.
  • Field Details

    • FIRST_BLOCK

      public static final FieldPointer FIRST_BLOCK
      Pointer to the first block.
    • LAST_BLOCK_WITH_ELEMENTS

      public static final FieldPointer LAST_BLOCK_WITH_ELEMENTS
      Pointer to the block where insertions are currently happening. This is only null if there are no allocated blocks. If there are any blocks containing elements, this points to the last block with a nonzero number of elements.
    • offset

      protected int offset
  • Method Details

    • create

      public static <T> FieldList<T> create(StructDef<?> ownerStruct, StructDef<T> elementType)
      Creates a new FieldList in the given struct which contains elements of the given type. The resulting list will grow by 1 element each time it overflows.
      Parameters:
      ownerStruct - the struct to which the new list field will be added. Must not have had StructDef.done() invoked on it yet.
      elementType - the type of elements that will be contained in the struct.
      Returns:
      a newly-constructed list field in the given struct.
    • create

      public static <T> FieldList<T> create(StructDef<?> ownerStruct, StructDef<T> elementType, int elementsPerBlock)
      Creates a new FieldList in the given struct which contains elements of the given type. The resulting list will grow by the given number of elements each time it overflows.
      Parameters:
      ownerStruct - the struct to which the new list field will be added. Must not have had StructDef.done() invoked on it yet.
      elementType - the type of elements that will be contained in the struct.
      elementsPerBlock - the number of elements that will be allocated each time the list overflows.
      Returns:
      a newly-constructed list field in the given struct.
    • getRecordSize

      public int getRecordSize()
      Description copied from interface: IField
      Returns the size of the field, in bytes.
      Specified by:
      getRecordSize in interface IField
    • asList

      public List<T> asList(Nd nd, long address)
      Returns the contents of the receiver as a List.
      Parameters:
      nd - the database to be queried.
      address - the address of the parent struct
    • append

      public T append(Nd nd, long address)
    • allocate

      public void allocate(Nd nd, long address, int numElements)
      Ensures that the receiver will have space for the given number of elements without additional allocation. Callers should invoke this prior to a sequence of append(Nd, long) calls if they know in advance how many elements will be appended. Will create the minimum number of extra blocks needed to the given number of additional elements.
    • destruct

      public void destruct(Nd nd, long address)
      Specified by:
      destruct in interface IDestructableField
    • setFieldName

      protected final void setFieldName(String fieldName)
    • setOffset

      public final void setOffset(int offset)
      Description copied from interface: IField
      Sets the field offset (bytes from the start of the struct). This is invoked some time after field construction, after the sizes of all preceeding fields are known.
      Specified by:
      setOffset in interface IField
    • getOffset

      public final int getOffset()
      Description copied from interface: IField
      Returns the field offset, in bytes from the start of the struct.
      Specified by:
      getOffset in interface IField
    • getFieldName

      public final String getFieldName()
      Description copied from interface: IField
      Returns the name of the field. This is mainly used for error messages, debug output, and diagnostic tools. Meant to be programmer-readable but not user-readable.
      Specified by:
      getFieldName in interface IField