containers.array2d - ICE 0.1 API documentation

ICE 0.1 API documentation

# containers.array2d

2D array struct.

struct Array2D(T);

  Fixed size 2D array struct with manually managed memory.

  If storing references to classes, arrays or pointers to garbage collected memory, it should be ensured that these don't accidentally get collected as the garbage collector does not see manually allocated memory. This could be done for instance by having other references to those classes/arrays/memory outside manually allocated memory.
  For simplicity and safety, Array2D can not be copied.

  Examples:

       //Construct a 4*4 2D array of uints. Contents will be default initialized,
       //i.e. 0 for uints.
       Array2D array = Array2D!(uint)(4, 4);
       //Destroy the array at exit.

       //Set element at coords X1,Y1 to 1
       array[1, 1] = 1;

       //Get the value at X1,Y1, to a, i.e. a is now 1.
       uint a = array[1, 1];

  T[] data_;

    Manually allocated data storage.

  uint x_;

    Array width.

  uint y_;

    Array height.

  this(const uint x, const uint y);

    Construct a 2D array.

    Contents of the array will be default-initialized, e.g., if the array stores uints, each element will be 0.

    Parameters:

    uint x | Array width.
    uint y | Array height.

  int opApply(int delegate(ref T) dg);

    Used by foreach.

    Foreach will iterate over all elements of the array, but in undefined order.

  inout pure inout(T) opIndex(const uint x, const uint y);

    Get a reference to an element of the array.

    Parameters:

    uint x | X coordinate of the element.
    uint y | Y coordinate of the element.

    Returns:
    Element at the specified coordinates.
  void opIndexAssign(T value, const uint x, const uint y);

    Set an element of the array.

    Parameters:

    uint x | X coordinate of the element.
    uint y | Y coordinate of the element.

  const pure uint width();

    Get width of the array.

  const pure uint height();

    Get height of the array.

void unittestArray2D();

  Unittest for Array2D.

Copyright © Ferdinand Majerech 2011. | Page generated by AutoDDoc and Ddoc.