Class Memory

    • Constructor Detail

      • Memory

        public Memory()
        Construct a memory. Initialize the internal buffer.
    • Method Detail

      • allocate

        public PtrToken allocate​(int size)
        Allocate a slot in the memory (currently at the end).
        Parameters:
        size - The size of the slot to be allocated.
        Returns:
        A pointer to the address allocated in the memory.
      • clear

        public void clear()
        Remove all entries from the memory.
      • read

        public Token read​(int index)
        Read a token from the given address in this memory.
        Parameters:
        index - The address to be read.
        Returns:
        The token, if there is one located at that address. If not or index is exceeding the memory capacity, then null is returned.
      • write

        public void write​(int index,
                          Token token)
        Write a token into the specified memory address given by index. If memory capacity is smaller than the given address, the memory is extended automatically.
        Parameters:
        index - The address to be written.
        token - The token to be written.