Class NdRawLinkedList

java.lang.Object
org.aspectj.org.eclipse.jdt.internal.core.nd.NdRawLinkedList

public class NdRawLinkedList extends Object
NdRawLinkedList stores a list of fixed-sized records. Along with the records themselves, there is also a bit field associated with each record which can hold a small number of bits of metadata per record. The underlying format is as follows:
 Bytes       Content
 ----------------
 4           Pointer to the next block. If this is 0, this is the last block and it is not yet full. The number of
             elements will be stored at the position where the last element would normally start. If this points back
             to the start of the block, this is the last block and it is full. If this holds any other value, the
             block is full and this points to the next block.
 headerSize  Bit field for this block (the bits for each element are tightly packed)
 recordSize  The content of the first element in the block
 recordSize  The content of the second element in the block
 ...         repeated recordsPerBlock times
 recordSize  If the block is full, this holds the last
 
stored in linked blocks where each block is an array of record pointers. Each block contains a pointer to the subsequent block, so they can be chained.

The size of the blocks are generally hardcoded. All blocks are the same size except for the first block whose size may be configured independently. The size of the first block may be zero, in which case the first "block" is simply a pointer to the following block or null.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static interface 
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    NdRawLinkedList​(Nd nd, long address, int elementRecordSize, int firstBlockRecordCount, int recordsPerBlock, int metadataBitsPerRecord)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    long
    addMember​(short metadataBits)
    Adds a new element to the list and returns the record pointer to the start of the newly-allocated object
    void
     
    long
     
     
    static int
    recordSize​(int elementRecordSize, int recordsPerBlock, int metadataBitsPerRecord)
    Returns the record size for a linked list with the given element record size and number of records per block
    int
    Returns the number of elements in this list.

    Methods inherited from class java.lang.Object

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

    • NdRawLinkedList

      public NdRawLinkedList(Nd nd, long address, int elementRecordSize, int firstBlockRecordCount, int recordsPerBlock, int metadataBitsPerRecord)
      Parameters:
      nd - the Nd object
      address - pointer to the start of the linked list
      recordsPerBlock - number of records per block. This is normally a hardcoded value.
  • Method Details

    • recordSize

      public static int recordSize(int elementRecordSize, int recordsPerBlock, int metadataBitsPerRecord)
      Returns the record size for a linked list with the given element record size and number of records per block
    • getNd

      public Nd getNd()
    • getAddress

      public long getAddress()
    • addMember

      public long addMember(short metadataBits) throws IndexException
      Adds a new element to the list and returns the record pointer to the start of the newly-allocated object
      Parameters:
      metadataBits - the metadata bits to attach to the new member. Use 0 if this list does not use metadata.
      Throws:
      IndexException
    • accept

      public void accept(NdRawLinkedList.ILinkedListVisitor visitor) throws IndexException
      Throws:
      IndexException
    • destruct

      public void destruct() throws IndexException
      Throws:
      IndexException
    • size

      public int size() throws IndexException
      Returns the number of elements in this list. This is an O(n) operation.
      Throws:
      IndexException