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)
T & operator[] (unsigned int i)
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 575 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 580 of file cklists.h.


Constructor & Destructor Documentation

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

Definition at line 595 of file cklists.h.

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

Definition at line 596 of file cklists.h.

References CkPagedVector< T >::init().

Here is the call graph for this function:

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

Definition at line 597 of file cklists.h.

References CkPagedVector< T >::nPages, and CkPagedVector< T >::pages.


Member Function Documentation

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

Definition at line 583 of file cklists.h.

References CkPagedVector< T >::nPages, CkPagedVector< T >::pages, and CkPagedVector< T >::pageSize.

Referenced by CkPagedVector< T >::init(), and CkPagedVector< T >::pup().

Here is the caller graph for this function:

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

Definition at line 588 of file cklists.h.

References CkPagedVector< T >::pages, and CkPagedVector< T >::pageSize.

Referenced by CkPagedVector< T >::operator[](), and CkPagedVector< T >::pupPage().

Here is the caller graph for this function:

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

Definition at line 603 of file cklists.h.

References CkPagedVector< T >::allocatePages().

Referenced by CkPagedVector< T >::CkPagedVector().

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 607 of file cklists.h.

References CkPagedVector< T >::allocatePage(), CkPagedVector< T >::pages, and CkPagedVector< T >::pageSize.

Here is the call graph for this function:

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

Definition at line 616 of file cklists.h.

References CkPagedVector< T >::pages, and CkPagedVector< T >::pageSize.

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

Definition at line 622 of file cklists.h.

References CkPagedVector< T >::allocatePage(), PUP::er::isUnpacking(), CkPagedVector< T >::pages, and CkPagedVector< T >::pageSize.

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

Here is the call graph for this function:

Here is the caller graph for this function:

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


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 Mon Sep 21 08:21:10 2020 for Charm++ by  doxygen 1.5.5