QMCPACK
PointerPool< CONT > Class Template Reference
+ Collaboration diagram for PointerPool< CONT >:

Public Types

using buffer_type = CONT
 
using pointer = typename CONT::pointer
 

Public Member Functions

pointer getPointer (int index, buffer_type &buffer)
 
void allocate (buffer_type &buffer)
 
size_t reserve (size_t size)
 
void reset ()
 
size_t getTotalSize ()
 
 PointerPool ()
 

Protected Attributes

size_t totalSize
 
std::vector< size_t > offsets
 

Detailed Description

template<typename CONT>
class PointerPool< CONT >

Definition at line 21 of file PointerPool.h.

Member Typedef Documentation

◆ buffer_type

using buffer_type = CONT

Definition at line 24 of file PointerPool.h.

◆ pointer

using pointer = typename CONT::pointer

Definition at line 25 of file PointerPool.h.

Constructor & Destructor Documentation

◆ PointerPool()

PointerPool ( )
inline

Definition at line 57 of file PointerPool.h.

57 : totalSize(0) {}
size_t totalSize
Definition: PointerPool.h:60

Member Function Documentation

◆ allocate()

void allocate ( buffer_type buffer)
inline

Definition at line 30 of file PointerPool.h.

References PointerPool< CONT >::totalSize.

30 { buffer.resize(totalSize); }
size_t totalSize
Definition: PointerPool.h:60

◆ getPointer()

pointer getPointer ( int  index,
buffer_type buffer 
)
inline

Definition at line 28 of file PointerPool.h.

References PointerPool< CONT >::offsets.

28 { return &(buffer[offsets[index]]); }
std::vector< size_t > offsets
Definition: PointerPool.h:61

◆ getTotalSize()

size_t getTotalSize ( )
inline

Definition at line 55 of file PointerPool.h.

References PointerPool< CONT >::totalSize.

55 { return totalSize; }
size_t totalSize
Definition: PointerPool.h:60

◆ reserve()

size_t reserve ( size_t  size)
inline

Definition at line 36 of file PointerPool.h.

References PointerPool< CONT >::offsets, and PointerPool< CONT >::totalSize.

37  {
38  if (size % 32)
39  {
40  std::cerr << "Unaligned reservation in PointerPool. size = " << size << std::endl;
41  size += 32 - (size % 32);
42  }
43  size_t off = totalSize;
44  offsets.push_back(off);
45  totalSize += size;
46  return off;
47  }
std::vector< size_t > offsets
Definition: PointerPool.h:61
size_t totalSize
Definition: PointerPool.h:60

◆ reset()

void reset ( )
inline

Definition at line 49 of file PointerPool.h.

References PointerPool< CONT >::offsets, and PointerPool< CONT >::totalSize.

50  {
51  offsets.resize(0);
52  totalSize = 0;
53  }
std::vector< size_t > offsets
Definition: PointerPool.h:61
size_t totalSize
Definition: PointerPool.h:60

Member Data Documentation

◆ offsets

std::vector<size_t> offsets
protected

◆ totalSize


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