PPL Logo

CkPagedVector< T > Class Template Reference

An array that is broken up into "pages" which are separately allocated. More...

#include <cklists.h>

Inheritance diagram for CkPagedVector< T >:

Inheritance graph
[legend]
Collaboration diagram for CkPagedVector< T >:

Collaboration graph
[legend]

Public Member Functions

 CkPagedVector ()
 CkPagedVector (int nEntries)
 ~CkPagedVector ()
void init (int nEntries)
Toperator[] (unsigned int i)
T get (unsigned int i)
void pupPage (PUP::er &p, int pg)
void pup (PUP::er &p)

Private Types

enum  { pageSize = 256u }
 This is the number of array entries per page. More...

Private Member Functions

void allocatePages (int nEntries)
void allocatePage (int pg)

Private Attributes

T ** pages
int nPages

Detailed Description

template<class T>
class CkPagedVector< T >

An array that is broken up into "pages" which are separately allocated.

Useful for saving memory when storing a long array with few used entries. Should be almost as fast as a regular vector.

When nothing is used, this reduces storage space by a factor of pageSize*sizeof(T)/sizeof(T*). For example, an array of 64-bit ints of length 1M takes 8MB; with paging it takes just 32KB, plus 2KB for each used block.

The class T must have a pup routine, a default constructor, and a copy constructor.

Definition at line 571 of file cklists.h.


Member Enumeration Documentation

template<class T>
anonymous enum [private]

This is the number of array entries per page.

For any kind of efficiency, it must be a power of 2, which lets the compiler turn divides and mods into bitwise operations.

Enumerator:
pageSize 

Definition at line 576 of file cklists.h.


Constructor & Destructor Documentation

template<class T>
CkPagedVector< T >::CkPagedVector (  )  [inline]

Definition at line 591 of file cklists.h.

template<class T>
CkPagedVector< T >::CkPagedVector ( int  nEntries  )  [inline]

Definition at line 592 of file cklists.h.

template<class T>
CkPagedVector< T >::~CkPagedVector (  )  [inline]

Definition at line 593 of file cklists.h.


Member Function Documentation

template<class T>
void CkPagedVector< T >::allocatePages ( int  nEntries  )  [inline, private]

template<class T>
void CkPagedVector< T >::allocatePage ( int  pg  )  [inline, private]

template<class T>
void CkPagedVector< T >::init ( int  nEntries  )  [inline]

Definition at line 599 of file cklists.h.

Referenced by CkPagedVector< AmpiOtherElement >::CkPagedVector(), and AmpiSeqQ::init().

template<class T>
T& CkPagedVector< T >::operator[] ( unsigned int  i  )  [inline]

Definition at line 603 of file cklists.h.

template<class T>
T CkPagedVector< T >::get ( unsigned int  i  )  [inline]

Definition at line 612 of file cklists.h.

template<class T>
void CkPagedVector< T >::pupPage ( PUP::er p,
int  pg 
) [inline]

Definition at line 618 of file cklists.h.

Referenced by CkPagedVector< AmpiOtherElement >::pup().

template<class T>
void CkPagedVector< T >::pup ( PUP::er p  )  [inline]

Definition at line 623 of file cklists.h.


Field Documentation

template<class T>
T** CkPagedVector< T >::pages [private]

template<class T>
int CkPagedVector< T >::nPages [private]


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

Generated on Thu May 24 07:57:29 2012 for Charm++ by  doxygen 1.5.5