Class Heap


  • public final class Heap
    extends Object
    A heap for CAS.

    This class is agnostic about what you store on the heap. It only copies values from integer arrays.

    • Field Detail

      • MIN_SIZE

        public static final int MIN_SIZE
        Minimum size of the heap. Currently set to 1000.
        See Also:
        Constant Field Values
      • DEFAULT_SIZE

        public static final int DEFAULT_SIZE
        Default size of the heap. Currently set to 500000(2 MB).
        See Also:
        Constant Field Values
    • Constructor Detail

      • Heap

        public Heap()
        Default constructor.
      • Heap

        public Heap​(int initialSize)
        Constructor lets you set initial heap size. Use only if you know what you're doing.
        Parameters:
        initialSize - The initial heap size. If this is smaller than the MIN_SIZE, the default will be used instead.
    • Method Detail

      • reset

        public void reset()
        Reset the temporary heap.
      • add

        public int add​(int[] fs)
        Add a structure to the heap.
        Parameters:
        fs - The input structure.
        Returns:
        The position where the structure was added, i.e., a pointer to the first element of the structure.
      • add

        public int add​(int len,
                       int val)
        Reserve space for len items on the heap and set the first item to val. The other items are set to 0.
        Parameters:
        len - The length of the new structure.
        val - The value of the first cell in the new structure.
        Returns:
        The position where the structure was added, i.e., a pointer to the first element of the structure.
      • getNextId

        public int getNextId()
      • grow

        public void grow​(int len)
      • getInitialSize

        public int getInitialSize()