Kicking it Olde Sküül! Burgerlib on Github Follow Olde Sküül on Twitter Burgerbecky on LinkedIn Burgerbecky on LinkedIn
Loading...
Searching...
No Matches
Classes | Public Member Functions | Private Attributes | List of all members
Burger::GridIndexPoints Class Reference

Manager to handle a grid with singly linked lists with values. More...

Collaboration diagram for Burger::GridIndexPoints:
Collaboration graph
[legend]

Classes

struct  Entry_t
 Singly linked data chunk for GridIndexPoints. More...
 
struct  iterator
 STL compatible iterator. More...
 

Public Member Functions

Entry_tGetCell (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_tGetBoundsRect (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.
 

Detailed Description

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.

See also
GridIndexBox

Constructor & Destructor Documentation

◆ GridIndexPoints() [1/2]

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.

Parameters
pBoundsPointer to the bounds rectangle
uXCellsWidth of the grid in cells
uYCellsHeight of the grid in cells
See also
GridIndexPoints(const Vector4D_t *,uintptr_t,float)

◆ GridIndexPoints() [2/2]

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.

Parameters
pBoundsPointer to the bounds rectangle
uItemCountEstimateNumber of total elements in the grid
fGridScaleScale value to increase precision on the grid for the bounds rect
See also
GridIndexPoints(const Vector4D_t *,uint_t,uint_t)

◆ ~GridIndexPoints()

Burger::GridIndexPoints::~GridIndexPoints ( )

Dispose of all allocated memory.


Standard destructor

Member Function Documentation

◆ add()

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.

Parameters
pPointPointer to the location in the grid to insert uValue
uValueData to place in the location in the grid.
See also
remove(Entry_t *)

◆ begin()

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.

Returns
An iterator set up to the requested data.
See also
end(void) const

◆ end()

Burger::GridIndexPoints::iterator Burger::GridIndexPoints::end ( void ) const
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.

Returns
Iterator that is pointing past the end of the data.
See also
begin(const Vector4D_t *) const

◆ find()

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.

Parameters
pPointPointer to the location in the grid to start searching.
uValueValue to match.
See also
add(const Vector2D_t *,uint_t) or remove(Entry_t *)

◆ GetBoundsRect()

const Vector4D_t * Burger::GridIndexPoints::GetBoundsRect ( void ) const
inline

Return a pointer to the bounds rectangle.


Retrieve a pointer to the bounds rectangle used by the class.

Returns
Constant pointer to the rectangle that encompasses the grid

◆ GetCell()

Burger::GridIndexPoints::Entry_t Burger::GridIndexPoints::GetCell ( uint_t uX,
uint_t uY ) const
inline

Get the entry at a location in the grid.


Retrieve the root entry, if any, at the requested location in the grid

Parameters
uXX coordinate in the grid
uYY coordinate in the grid
Returns
Pointer to a data entry or NULL if no data is present in the location.
See also
GetCellIndex(const Vector2D_t *) const or GridIndexPoints::Entry_t

◆ GetCellIndex()

uintptr_t Burger::GridIndexPoints::GetCellIndex ( const Vector2D_t * pInput) const
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.

Parameters
pInputPointer to the high resolution location
Returns
One dimensional index into the array
See also
GetCell(uint_t,uint_t) const

◆ GetContainingCellClamped()

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

Parameters
pOutputPointer to store the adjusted location.
pInputPointer to the high resolution location
See also
GetCell(uint_t,uint_t) const

◆ remove()

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.

Parameters
pEntryPointer to the Entry_t to dispose of.
See also
add(const Vector2D_t *,uint_t)

Member Data Documentation

◆ m_BoundsRect

Vector4D_t Burger::GridIndexPoints::m_BoundsRect
private

Rectangle encompassing the area of the grid.

◆ m_fXCells

float Burger::GridIndexPoints::m_fXCells
private

Number of cells wide as a float.

◆ m_fYCells

float Burger::GridIndexPoints::m_fYCells
private

Number of cells high as a float.

◆ m_ppGrid

Entry_t** Burger::GridIndexPoints::m_ppGrid
private

Array of pointers for grid objects.

◆ m_uXCells

uint_t Burger::GridIndexPoints::m_uXCells
private

Number of cells wide.

◆ m_uYCells

uint_t Burger::GridIndexPoints::m_uYCells
private

Number of cells high.