UCommon
ucommon::sarray< T > Class Template Reference

Generate a typed sparse managed object array. More...

#include <object.h>

Inheritance diagram for ucommon::sarray< T >:
Collaboration diagram for ucommon::sarray< T >:

Public Member Functions

T & at (unsigned offset)
 
T * get (unsigned offset)
 Get typed member of array.
 
const T * operator() (unsigned offset) const
 
void operator() (unsigned offset, T value)
 
T & operator[] (unsigned offset)
 Array operation to access member object.
 
 sarray (unsigned size)
 Generate a sparse typed array of specified size.
 
- Public Member Functions inherited from ucommon::SparseObjects
unsigned count (void)
 Get count of array elements.
 

Additional Inherited Members

- Protected Member Functions inherited from ucommon::SparseObjects
ObjectProtocolget (unsigned offset)
 Get (reference) an object at a specified offset in the array.
 
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.
 
virtual ~SparseObjects ()
 Destroy sparse array and delete all generated objects.
 

Detailed Description

template<class T>
class ucommon::sarray< T >

Generate a typed sparse managed object array.

Members in the array are created when they are first referenced. The types for objects that are generated by sarray must have Object as a base class. Managed sparse arrays differ from standard arrays in that the member elements are not allocated from the heap when the array is created, but rather as they are needed.

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

Definition at line 264 of file object.h.

Constructor & Destructor Documentation

◆ sarray()

template<class T >
ucommon::sarray< T >::sarray ( unsigned size)
inline

Generate a sparse typed array of specified size.

Parameters
sizeof array to create.

Definition at line 274 of file object.h.

Member Function Documentation

◆ at()

template<class T >
T & ucommon::sarray< T >::at ( unsigned offset)
inline

Definition at line 296 of file object.h.

◆ get()

template<class T >
T * ucommon::sarray< T >::get ( unsigned offset)
inline

Get typed member of array.

If the object does not exist, it is created.

Parameters
offsetin array for object.
Returns
pointer to typed object.

Definition at line 282 of file object.h.

Here is the call graph for this function:

◆ operator()() [1/2]

template<class T >
const T * ucommon::sarray< T >::operator() ( unsigned offset) const
inline

Definition at line 300 of file object.h.

◆ operator()() [2/2]

template<class T >
void ucommon::sarray< T >::operator() ( unsigned offset,
T value )
inline

Definition at line 304 of file object.h.

◆ operator[]()

template<class T >
T & ucommon::sarray< T >::operator[] ( unsigned offset)
inline

Array operation to access member object.

If the object does not exist, it is created.

Parameters
offsetin array for object.
Returns
pointer to typed object.

Definition at line 292 of file object.h.

Here is the call graph for this function:

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