MINT2
Public Member Functions | Private Attributes | List of all members
RememberAnythingFast< T > Class Template Reference

#include <RememberAnythingFast.h>

Public Member Functions

unsigned int size ()
 
void resize (unsigned int newSize)
 
void set (unsigned int i, const T &value, long int configNumber=1)
 
 RememberAnythingFast ()
 
 RememberAnythingFast (const RememberAnythingFast &other)
 
 ~RememberAnythingFast ()
 
bool valid (long int i)
 
bool get (int i, T &value, long int configNumber=1)
 

Private Attributes

std::vector< std::pair< T, long int > > _anyVector
 

Detailed Description

template<typename T>
class RememberAnythingFast< T >

Definition at line 14 of file RememberAnythingFast.h.

Constructor & Destructor Documentation

◆ RememberAnythingFast() [1/2]

template<typename T>
RememberAnythingFast< T >::RememberAnythingFast ( )
inline

Definition at line 50 of file RememberAnythingFast.h.

50  {
51  _anyVector.clear();
52  }
std::vector< std::pair< T, long int > > _anyVector

◆ RememberAnythingFast() [2/2]

template<typename T>
RememberAnythingFast< T >::RememberAnythingFast ( const RememberAnythingFast< T > &  other)
inline

Definition at line 53 of file RememberAnythingFast.h.

54  : _anyVector(other._anyVector){
55  }
std::vector< std::pair< T, long int > > _anyVector

◆ ~RememberAnythingFast()

template<typename T>
RememberAnythingFast< T >::~RememberAnythingFast ( )
inline

Definition at line 57 of file RememberAnythingFast.h.

57  {
58  _anyVector.clear();
59  }
std::vector< std::pair< T, long int > > _anyVector

Member Function Documentation

◆ get()

template<typename T>
bool RememberAnythingFast< T >::get ( int  i,
T &  value,
long int  configNumber = 1 
)
inline

Definition at line 67 of file RememberAnythingFast.h.

67  {
68  /*std::cout << "my contents, now " << std::endl;
69  for(unsigned int i=0; i < _anyVector.size(); i++){
70  std::cout << _anyVector[i].first
71  << ", " << _anyVector[i].second << std::endl;
72 
73  }
74  std::cout << "called with: " << i << ", " << configNumber << std::endl;
75  */
76  if(! valid(i)) return false;
77  //std::cout << "I'm valid! " << std::endl;
78  if(_anyVector[i].second != configNumber) return false;
79  value = _anyVector[i].first;
80  //std::cout << "set value to " << value <<std::endl;
81  return true;
82  }
std::vector< std::pair< T, long int > > _anyVector
static const double second

◆ resize()

template<typename T>
void RememberAnythingFast< T >::resize ( unsigned int  newSize)
inline

Definition at line 22 of file RememberAnythingFast.h.

22  {
23  if(newSize < this->size()) return;
24  std::pair< T, long int> empty(0, 0);
25  _anyVector.resize(newSize, empty);
26  }
std::vector< std::pair< T, long int > > _anyVector

◆ set()

template<typename T>
void RememberAnythingFast< T >::set ( unsigned int  i,
const T &  value,
long int  configNumber = 1 
)
inline

Definition at line 28 of file RememberAnythingFast.h.

28  {
29  //std::cout << "RememberAnythingFast called with "
30  // << value << ", " << configNumber << std::endl;
31  if(i >= _anyVector.size()){
32  resize(i+1);
33  }
34  std::pair< T, long int> trueValue(value, configNumber);
35  //std::cout << "trueValue = " << trueValue.first
36  // << ", " << trueValue.second << std::endl;
37  _anyVector[i] = trueValue;
38 
39  /*
40  std::cout << "my contents, now " << std::endl;
41  for(unsigned int i=0; i < _anyVector.size(); i++){
42  std::cout << _anyVector[i].first
43  << ", " << _anyVector[i].second << std::endl;
44  }
45  */
46  }
std::vector< std::pair< T, long int > > _anyVector
void resize(unsigned int newSize)

◆ size()

template<typename T>
unsigned int RememberAnythingFast< T >::size ( )
inline

Definition at line 18 of file RememberAnythingFast.h.

18  {
19  return _anyVector.size();
20  }
std::vector< std::pair< T, long int > > _anyVector

◆ valid()

template<typename T>
bool RememberAnythingFast< T >::valid ( long int  i)
inline

Definition at line 61 of file RememberAnythingFast.h.

61  {
62  if(i < 0) return false;
63  if(i >= (long int) this->size()) return false;
64  if(!(_anyVector[i].second)) return false;
65  return true;
66  }
std::vector< std::pair< T, long int > > _anyVector
static const double second

Member Data Documentation

◆ _anyVector

template<typename T>
std::vector< std::pair< T, long int> > RememberAnythingFast< T >::_anyVector
private

Definition at line 15 of file RememberAnythingFast.h.


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