COGS
Computer Graphics Structures library
cogs::Grid< Type > Class Template Reference

Organizational structure of values in a 2 dimensional grid. More...

Inheritance diagram for cogs::Grid< Type >:
[legend]

Public Member Functions

 Grid ()=default
 Creates grid with zero size.
 
 Grid (const cogs::Grid< Type > &source)
 Creates exact copy of provided grid.
 
 Grid (const size_t width, const size_t height)
 Creates grid with specified width and height.
 
 Grid (const size_t width, const size_t height, const Type &init_value)
 Creates grid with specified width and height and initializes elements to init_value.
 
void Resize (const size_t width, const size_t height, const Type &init_value)
 Sets width and height of a grid, and initializes new elements to init_value.
 
void Resize (const size_t width, const size_t height)
 Sets width and height of a grid, and initializes new elements to zeros.
 
void Clear ()
 Clears all elements and sets resolution to (0, 0).
 
void Fill (const Type value)
 Sets all elements of grid to a defined value.
 
void Fill (const geom::URect &area, const Type value)
 Sets specified area in grid to a defined value.
 
bool IsInBounds (const size_t x, const size_t y) const
 Checks whether a combination of xy correspond to valid grid cell.
 
Type & At (const size_t x, const size_t y)
 Returns a reference to the cell at position xy.
 
const Type & At (const size_t x, const size_t y) const
 Returns a reference to the cell at position xy.
 
Type & operator() (const size_t x, const size_t y)
 Returns a reference to the cell at position xy.
 
size_t GetWidth () const
 Returns current width of grid.
 
size_t GetHeight () const
 Returns current height of grid.
 
void FlipX ()
 Flips all values in x direction.
 
void FlipY ()
 Flips all values in y direction.
 
void Foreach (std::function< void(size_t x, size_t y, const Type &value)> func) const
 Executes a specified function for every element in the grid.
 
void Foreach (std::function< void(size_t x, size_t y, Type &value)> func)
 Executes a specified function for every element in the grid.
 

Detailed Description

template<typename Type>
class cogs::Grid< Type >

Organizational structure of values in a 2 dimensional grid.