SparseArray< _Type > Class Template Reference

#include <SparseArray.h>

List of all members.


Detailed Description

template<typename _Type>
class SparseArray< _Type >

SparseArray defines a logical array of _Type which is expected to be sparse. SparseArray can be very smart, but right now is dumb but gets things right.

Definition at line 28 of file SparseArray.h.

Public Types

typedef std::list< BlockBlockList

Public Member Functions

 ~SparseArray ()
_Type operator[] (size_t offset) const
void range_write (size_t offset, size_t elts, const _Type *in)
size_t size () const
const BlockListblocks () const

Private Member Functions

_Type * allocate (size_t offset, size_t size)

Private Attributes

BlockList blocks_
 List of blocks_ sorted in ascending order by offset.

Classes

class  Block


Member Typedef Documentation

template<typename _Type>
typedef std::list<Block> SparseArray< _Type >::BlockList

Definition at line 49 of file SparseArray.h.


Constructor & Destructor Documentation

template<typename _Type>
SparseArray< _Type >::~SparseArray (  )  [inline]

Definition at line 51 of file SparseArray.h.

References SparseArray< _Type >::blocks_.


Member Function Documentation

template<typename _Type>
_Type SparseArray< _Type >::operator[] ( size_t  offset  )  const [inline]

In the empty sparse area, the SparseArray returns an element which is the default constructor of _Type.

Definition at line 65 of file SparseArray.h.

References SparseArray< _Type >::blocks_.

template<typename _Type>
void SparseArray< _Type >::range_write ( size_t  offset,
size_t  elts,
const _Type *  in 
) [inline]

Write into the sparse map. Allocates a block if needed.

Definition at line 88 of file SparseArray.h.

References SparseArray< _Type >::allocate(), and ASSERT.

template<typename _Type>
size_t SparseArray< _Type >::size (  )  const [inline]

Returns:
size of the SparseArray, which is from 0...last written to range.

Definition at line 103 of file SparseArray.h.

References SparseArray< _Type >::blocks_.

Referenced by SparseArray< _Type >::Block::Block().

template<typename _Type>
const BlockList& SparseArray< _Type >::blocks (  )  const [inline]

Returns:
List of the blocks.

Definition at line 119 of file SparseArray.h.

References SparseArray< _Type >::blocks_.

template<typename _Type>
_Type* SparseArray< _Type >::allocate ( size_t  offset,
size_t  size 
) [inline, private]

Allocate a block starting at offset with elts. Will merge blocks that it finds overlapping.

Returns:
Pointer to allocated region.

Definition at line 134 of file SparseArray.h.

References ASSERT, SparseArray< _Type >::blocks_, and NOTREACHED.

Referenced by SparseArray< _Type >::range_write().


Member Data Documentation

template<typename _Type>
BlockList SparseArray< _Type >::blocks_ [private]

List of blocks_ sorted in ascending order by offset.

Definition at line 126 of file SparseArray.h.

Referenced by SparseArray< _Type >::allocate(), SparseArray< _Type >::blocks(), SparseArray< _Type >::operator[](), SparseArray< _Type >::size(), and SparseArray< _Type >::~SparseArray().


The documentation for this class was generated from the following file:
Generated on Thu Jun 7 12:54:32 2007 for DTN Reference Implementation by  doxygen 1.5.1