Class ConstantSizeMemory

java.lang.Object
dev.zemco.codegame.execution.memory.ConstantSizeMemory
All Implemented Interfaces:
IMemory

public class ConstantSizeMemory extends Object implements IMemory
Memory holding constant number of memory cells specified during its creation.
Author:
Erik Zemčík
  • Constructor Details

    • ConstantSizeMemory

      public ConstantSizeMemory(int size, IMemoryCellFactory memoryCellFactory)
      Creates an instance of ConstantSizeMemory that holds a specified number of memory cells created using the provided memoryCellFactory.
      Parameters:
      size - number of cells which memory should hold
      memoryCellFactory - factory to use to create new memory cells
      Throws:
      IllegalArgumentException - if size is not a positive non-zero integer or if memoryCellFactory is null
  • Method Details

    • getCellByAddress

      public IMemoryCell getCellByAddress(int address)
      Description copied from interface: IMemory
      Retrieves a cell at the specified address.
      Specified by:
      getCellByAddress in interface IMemory
      Parameters:
      address - address of the cell to return
      Returns:
      cell at the specified address
    • getWorkingCell

      public IMemoryCell getWorkingCell()
      Description copied from interface: IMemory
      Retrieves the working cell.
      Specified by:
      getWorkingCell in interface IMemory
      Returns:
      working cell