Interface ISettableGridView<T>
Interface designed to act as a standardized input/output format that defines minimal required data for algorithms that operate and make changes to a grid of some sort. For a concrete implementation to subclass for custom implementations, see SettableGridViewBase<T>.
Namespace: SadRogue.Primitives.GridViews
Assembly: TheSadRogue.Primitives.dll
Syntax
public interface ISettableGridView<T> : IGridView<T>
Type Parameters
Name | Description |
---|---|
T | The type of value being returned/set by the indexer functions. |
Remarks
See IGridView<T>. This interface serves the same purpose, but for cases when it is also necessary for an algorithm to be able to change the value at each location.
Like IGridView, a number of implementations of this interface to cover common needs are provided. For example, ArrayView<T> defines the interface such that the data is retrieved from and set to an array, and LambdaSettableGridView<T> defines the interface such that arbitrary callbacks are used to retrieve and set the data.
Properties
Item[Point]
Given a position, returns/sets the "value" associated with that location.
Declaration
T this[Point pos] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
Point | pos | Location to get/set the value for. |
Property Value
Type | Description |
---|---|
T | The "value" associated with the provided location. |
Item[Int32]
Given an 1-dimensional index, returns/sets the value associated with the corresponding position in the map view.
Declaration
T this[int index1D] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
Int32 | index1D | 1D index of location to get/set the "value" for. |
Property Value
Type | Description |
---|---|
T | The "value" associated with the given location. |
Remarks
Typically, this may be implemented in terms of Item[Point] by using FromIndex(Int32, Int32) to calculate the 2D position represented by that 1D index, and passing that position to the Item[Point] indexer to get/set the value associated with the position.
Item[Int32, Int32]
Given an X and Y value, returns/sets the "value" associated with that location.
Declaration
T this[int x, int y] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
Int32 | x | X-value of location. |
Int32 | y | Y-value of location. |
Property Value
Type | Description |
---|---|
T | The "value" associated with that location. |
Remarks
Typically, this can be implemented via Item[Point].
Methods
Clear()
Sets every location within the grid view to the default value for the type.
Declaration
virtual void Clear()
Remarks
This function can sometimes be implemented more efficiently than Fill(default), so it is provided as an interface function to enable dispatching.
Remember the default value of a non-nullable type is null for reference types; so use with caution if your element type is non-nullable!
Fill(T)
Sets every location within the grid view to the given value.
Declaration
virtual void Fill(T value)
Parameters
Type | Name | Description |
---|---|---|
T | value | Value to set to all locations in the grid view. |