| ## Public API Reference

- Main Page
- Modules
- Namespaces
- Classes
- Files
- Related Pages

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# csSubRectangles Class Reference
[Geometry utilities]

A class managing allocations of sub-rectangles. More...

`#include <csgeom/subrec.h>`

List of all members.

## Public Member Functions
SubRect * | Alloc (int w, int h, csRect &rect)
| Allocate a new rectangle.
void | Clear ()
| Free all rectangles in this region.
| csSubRectangles (const csRect &region)
| Allocate a new empty region with the given size.
void | Dump ()
| For debugging: dump all free rectangles.
const csRect & | GetRectangle () const
| Get the rectangle for this region.
bool | Grow (int newWidth, int newHeight)
| Increase the size of the region.
void | Reclaim (SubRect *subrect)
| Reclaim a subrectangle, meaning, the space occupied by the subrect can be reused by subsequent Alloc() calls.
| ~csSubRectangles ()
| Remove this region and sub-regions.
## Protected Member Functions
void | AddLeaf (SubRect *sr)
SubRect * | AllocSubrect ()
void | RemoveLeaf (SubRect *sr)
## Protected Attributes
SubRect::SubRectAlloc | alloc
csArray< SubRect * > | leaves
| Leaves of the region tree.
csRect | region
| Dimensions of this region.
SubRect * | root
| Root of the region tree.
## Friends
class | SubRect
## Classes
class | SubRect
| Sub-rectangle. More...

## Detailed Description

A class managing allocations of sub-rectangles.

i.e. this class represents a rectangular region from which a client can allocate smaller rectangles until the region is full.

Definition at line 42 of file subrec.h.

## Constructor & Destructor Documentation

csSubRectangles::csSubRectangles | ( | const csRect & | region | ) |

Allocate a new empty region with the given size.

csSubRectangles::~csSubRectangles | ( |  | ) |

Remove this region and sub-regions.

## Member Function Documentation

SubRect* csSubRectangles::Alloc | ( | int | w,
|  | int | h,
|  | csRect & | rect |
| ) |  |  |

Allocate a new rectangle.

Returns 0 if there is no room

void csSubRectangles::Clear | ( |  | ) |

Free all rectangles in this region.

void csSubRectangles::Dump | ( |  | ) |

For debugging: dump all free rectangles.

const csRect& csSubRectangles::GetRectangle | ( |  | ) | const`[inline]`

Get the rectangle for this region.

Definition at line 141 of file subrec.h.

bool csSubRectangles::Grow | ( | int | newWidth,
|  | int | newHeight |
| ) |  |  |

Increase the size of the region.

You can only grow upwards.

void csSubRectangles::Reclaim | ( | SubRect * | subrect | ) |

Reclaim a subrectangle, meaning, the space occupied by the subrect can be reused by subsequent Alloc() calls.

## Member Data Documentation

csArray<SubRect*> csSubRectangles::leaves`[protected]`

Leaves of the region tree.

Definition at line 119 of file subrec.h.

csRect csSubRectangles::region`[protected]`

Dimensions of this region.

Definition at line 109 of file subrec.h.

SubRect* csSubRectangles::root`[protected]`

Root of the region tree.

Definition at line 111 of file subrec.h.

The documentation for this class was generated from the following file:

- csgeom/subrec.h