UCommon
Public Member Functions | Protected Member Functions
ucommon::SparseObjects Class Referenceabstract

A sparse array of managed objects. More...

#include <object.h>

Inheritance diagram for ucommon::SparseObjects:
Inheritance graph
[legend]

Public Member Functions

unsigned count (void)
 Get count of array elements. More...
 

Protected Member Functions

virtual ObjectProtocolcreate (void)=0
 Object factory for creating members of the spare array when they are initially requested. More...
 
ObjectProtocolget (unsigned offset)
 Get (reference) an object at a specified offset in the array. More...
 
virtual ObjectProtocolinvalid (void) const
 
void purge (void)
 Purge the array by deleting all created objects.
 
 SparseObjects (unsigned size)
 Create a sparse array of known size. More...
 
virtual ~SparseObjects ()
 Destroy sparse array and delete all generated objects.
 

Detailed Description

A sparse array of managed objects.

This might be used as a simple array class for reference counted objects. This class assumes that objects in the array exist when assigned, and that gaps in the array are positions that do not reference any object. Objects are automatically created (create on access/modify when an array position is referenced for the first time. This is an abstract class because it is a type factory for objects who's derived class form constructor is not known in advance and is a helper class for the sarray template.

Author
David Sugar dyfet.nosp@m.@gnu.nosp@m.telep.nosp@m.hony.nosp@m..org

Definition at line 204 of file object.h.

Constructor & Destructor Documentation

◆ SparseObjects()

ucommon::SparseObjects::SparseObjects ( unsigned  size)
protected

Create a sparse array of known size.

No member objects are created until they are referenced.

Parameters
sizeof array.

Member Function Documentation

◆ count()

unsigned ucommon::SparseObjects::count ( void  )

Get count of array elements.

Returns
array elements.

◆ create()

virtual ObjectProtocol* ucommon::SparseObjects::create ( void  )
protectedpure virtual

Object factory for creating members of the spare array when they are initially requested.

Returns
new object.

◆ get()

ObjectProtocol* ucommon::SparseObjects::get ( unsigned  offset)
protected

Get (reference) an object at a specified offset in the array.

Parameters
offsetin array.
Returns
new or existing object.

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