ucommon  7.0.0
About: GNU uCommon C++ is a portable and optimized class framework for writing C++ applications that need to use threads and support concurrent synchronization, and that use sockets, XML parsing, object serialization, thread-optimized string and data structure classes, etc..
  Fossies Dox: ucommon-7.0.0.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

Loading...
Searching...
No Matches
ucommon::sarray< T > Class Template Reference

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

#include <object.h>

Inheritance diagram for ucommon::sarray< T >:
[legend]
Collaboration diagram for ucommon::sarray< T >:
[legend]

Public Member Functions

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

Private Member Functions

 __DELETE_DEFAULTS (sarray)
 
__LOCAL ObjectProtocolcreate (void) __FINAL
 Object factory for creating members of the spare array when they are initially requested. More...
 

Additional Inherited Members

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

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

◆ __DELETE_DEFAULTS()

template<class T >
ucommon::sarray< T >::__DELETE_DEFAULTS ( sarray< T >  )
private

◆ at()

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

Definition at line 296 of file object.h.

References ucommon::SparseObjects::get().

Referenced by ucommon::sarray< T >::operator()().

Here is the call graph for this function:

◆ create()

template<class T >
__LOCAL ObjectProtocol * ucommon::sarray< T >::create ( void  )
inlineprivatevirtual

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

Returns
new object.

Implements ucommon::SparseObjects.

Definition at line 310 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.

References ucommon::SparseObjects::get().

Referenced by ucommon::sarray< T >::operator()(), and ucommon::sarray< T >::operator[]().

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.

References ucommon::sarray< T >::get().

Here is the call graph for this function:

◆ operator()() [2/2]

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

Definition at line 304 of file object.h.

References ucommon::sarray< T >::at().

Here is the call graph for this function:

◆ 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.

References ucommon::sarray< T >::get().

Here is the call graph for this function:

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