Manager to handle a grid with singly linked lists with values. More...
Classes | |
struct | Entry_t |
Singly linked data chunk for GridIndexPoints. More... | |
struct | iterator |
STL compatible iterator. More... | |
Public Member Functions | |
Entry_t * | GetCell (uint_t uX, uint_t uY) const |
Get the entry at a location in the grid. | |
uintptr_t | GetCellIndex (const Vector2D_t *pInput) const |
Get the offset into the grid from a coordinate. | |
void | GetContainingCellClamped (Vector2D_t *pOutput, const Vector2D_t *pInput) const |
Get the high precision location that contains a specific point. | |
GridIndexPoints (const Vector4D_t *pBounds, uint_t uXCells, uint_t uYCells) | |
Construct a grid of a specific size. | |
GridIndexPoints (const Vector4D_t *pBounds, uintptr_t uItemCountEstimate, float fGridScale=0.707f) | |
Construct a grid of an optimum size. | |
~GridIndexPoints () | |
Dispose of all allocated memory. | |
const Vector4D_t * | GetBoundsRect (void) const |
Return a pointer to the bounds rectangle. | |
iterator | begin (const Vector4D_t *pInput) const |
Create an iterator for a sub-rectangle of the grid. | |
iterator | end (void) const |
Create an iterator with no data. | |
void | add (const Vector2D_t *pPoint, uint_t uValue) |
Insert data into the grid. | |
void | remove (Entry_t *pEntry) |
Remove an entry from the grid. | |
iterator | find (const Vector2D_t *pPoint, uint_t uValue) |
Find an entry on the grid. | |
Private Attributes | |
Vector4D_t | m_BoundsRect |
Rectangle encompassing the area of the grid. | |
Entry_t ** | m_ppGrid |
Array of pointers for grid objects. | |
uint_t | m_uXCells |
Number of cells wide. | |
uint_t | m_uYCells |
Number of cells high. | |
float | m_fXCells |
Number of cells wide as a float. | |
float | m_fYCells |
Number of cells high as a float. | |
Manager to handle a grid with singly linked lists with values.
This class will create a 2D grid where data can be quickly added and removed at will.
Burger::GridIndexPoints::GridIndexPoints | ( | const Vector4D_t * | pBounds, |
uint_t | uXCells, | ||
uint_t | uYCells ) |
Construct a grid of a specific size.
Given a grid size and a bounds rect that encompasses it, allocate memory for the grid and initialize it to NULL entries.
pBounds | Pointer to the bounds rectangle |
uXCells | Width of the grid in cells |
uYCells | Height of the grid in cells |
Burger::GridIndexPoints::GridIndexPoints | ( | const Vector4D_t * | pBounds, |
uintptr_t | uItemCountEstimate, | ||
float | fGridScale = 0.707f ) |
Construct a grid of an optimum size.
Given a grid size in elements and a bounds rect that encompasses it, allocate memory for the grid and initialize it to NULL entries.
The actual size will be generated to be as close to square that will hold as many elements as uItemCountEstimate requests.
pBounds | Pointer to the bounds rectangle |
uItemCountEstimate | Number of total elements in the grid |
fGridScale | Scale value to increase precision on the grid for the bounds rect |
Burger::GridIndexPoints::~GridIndexPoints | ( | ) |
Dispose of all allocated memory.
Standard destructor
void BURGER_API Burger::GridIndexPoints::add | ( | const Vector2D_t * | pPoint, |
uint_t | uValue ) |
Insert data into the grid.
At the location indicated by pPoint, create an entry with the data and insert it into the grid.
pPoint | Pointer to the location in the grid to insert uValue |
uValue | Data to place in the location in the grid. |
Burger::GridIndexPoints::iterator Burger::GridIndexPoints::begin | ( | const Vector4D_t * | pInput | ) | const |
Create an iterator for a sub-rectangle of the grid.
Clip a high resolution rectangle from the grid and set up an iterator that will traverse only the requested data.
|
inline |
Create an iterator with no data.
This iterator is used for comparisons to determine if the iterator returned by begin() has reached the end of the data.
Burger::GridIndexPoints::iterator Burger::GridIndexPoints::find | ( | const Vector2D_t * | pPoint, |
uint_t | uValue ) |
Find an entry on the grid.
Scan the grid if an entry if present, if so, return an iterator pointing to the requested entry. Otherwise, the iterator is set to point to the end of the data.
pPoint | Pointer to the location in the grid to start searching. |
uValue | Value to match. |
|
inline |
Return a pointer to the bounds rectangle.
Retrieve a pointer to the bounds rectangle used by the class.
Get the entry at a location in the grid.
Retrieve the root entry, if any, at the requested location in the grid
uX | X coordinate in the grid |
uY | Y coordinate in the grid |
|
inline |
Get the offset into the grid from a coordinate.
Given a high precision location in the grid, get the 1 dimensional index into the 2 dimensional array.
pInput | Pointer to the high resolution location |
void BURGER_API Burger::GridIndexPoints::GetContainingCellClamped | ( | Vector2D_t * | pOutput, |
const Vector2D_t * | pInput ) const |
Get the high precision location that contains a specific point.
Given a high precision location in the grid, clamp it onto the grid
pOutput | Pointer to store the adjusted location. |
pInput | Pointer to the high resolution location |
void BURGER_API Burger::GridIndexPoints::remove | ( | Entry_t * | pEntry | ) |
Remove an entry from the grid.
Check if the entry is in the grid, and if so, removes it and then deletes the memory for the entry.
pEntry | Pointer to the Entry_t to dispose of. |
|
private |
Rectangle encompassing the area of the grid.
|
private |
Number of cells wide as a float.
|
private |
Number of cells high as a float.
|
private |
Array of pointers for grid objects.
|
private |
Number of cells wide.
|
private |
Number of cells high.