CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PVector.h
Go to the documentation of this file.
1 #ifndef INCLUDE_ORA_PVECTOR_H
2 #define INCLUDE_ORA_PVECTOR_H
3 
4 //
5 #include <vector>
6 
7 namespace ora {
8 
9 
17  template <typename Tp> class PVector
18  {
19 
20  public:
21 
22  // typedefs forwarded to std::vector
24 
25  typedef typename std::vector<Tp>::const_reference const_reference;
26 
28 
29  typedef typename std::vector<Tp>::const_iterator const_iterator;
30 
31  typedef typename std::vector<Tp>::iterator iterator;
32 
33  typedef typename std::vector<Tp>::const_reverse_iterator const_reverse_iterator;
34 
35  typedef typename std::vector<Tp>::reverse_iterator reverse_iterator;
36 
38 
39  // ora specific typedef
40  typedef typename std::vector<Tp> store_type;
41 
42  public:
43 
44  // default constructor
45  PVector();
46 
47  // constructor
48  explicit PVector(size_type n, const Tp& value=Tp());
49 
50  // copy constructor
51  PVector(const PVector<Tp>&);
52 
53  // destructor
54  virtual ~PVector(){
55  }
56 
57  // assignment operator
59 
60  public:
61  // methods forwarded to std::vector
63  {
64  return m_vec.begin();
65  }
66 
68  {
69  return m_vec.end();
70  }
71 
73  {
74  return m_vec.begin();
75  }
76 
78  {
79  return m_vec.end();
80  }
81 
83  {
84  return m_vec.rbegin();
85  }
86 
88  {
89  return m_vec.rend();
90  }
91 
93  {
94  return m_vec.rbegin();
95  }
96 
98  {
99  return m_vec.rend();
100  }
101 
102  size_type size() const
103  {
104  return m_vec.size();
105  }
106 
108  {
109  return m_vec.max_size();
110  }
111 
112  void resize(size_type n, const Tp& value=Tp())
113  {
114  m_vec.resize(n,value);
115  }
116 
118  {
119  return m_vec.capacity();
120  }
121 
122  bool empty() const
123  {
124  return m_vec.empty();
125  }
126 
128  {
129  m_vec.reserve(n);
130  }
131 
133  {
134  return m_vec[n];
135  }
136 
138  {
139  return m_vec[n];
140  }
141 
143  {
144  return m_vec.at(n);
145  }
146 
148  {
149  return m_vec.at(n);
150  }
151 
153  {
154  return m_vec.front();
155  }
156 
158  {
159  return m_vec.front();
160  }
161 
163  {
164  return m_vec.back();
165  }
166 
168  {
169  return m_vec.back();
170  }
171 
172  void assign ( size_type n, const Tp& u )
173  {
174  m_vec.assign(n,u);
175  }
176 
177  void push_back ( const Tp& x )
178  {
179  m_vec.push_back(x);
180  }
181 
182  void pop_back ()
183  {
184  m_vec.pop_back();
185  }
186 
187  void clear ( )
188  {
189  m_vec.clear();
190  }
191 
192  // equals operator
193  bool operator==(const PVector& vec) const
194  {
195  return m_vec==vec.m_vec;
196  }
197 
198  bool operator!=(const PVector& vec) const
199  {
200  return m_vec!=vec.m_vec;
201  }
202 
203  // ORA specific methods
204  public:
205 
206  const void* storageAddress() const
207  {
208  return &m_vec;
209  }
210 
211  // access to persistent size
213  {
214  return m_persistentSize;
215  }
216 
217  // ORA specific attributes
218  private:
219 
220  // private std::vector instance
221  std::vector<Tp> m_vec;
222 
223  // persistent size
225 
226  };
227 }
228 
229 
230 template <class Tp> ora::PVector<Tp>::PVector():m_vec(),m_persistentSize(0){
231 }
232 
233 template <class Tp> ora::PVector<Tp>::PVector(size_type n, const Tp& value):m_vec(n,value),m_persistentSize(0){
234 }
235 
236 template <class Tp> ora::PVector<Tp>::PVector(const PVector<Tp>& v):m_vec(v.m_vec),m_persistentSize(v.m_persistentSize){
237 }
238 
240 
241  m_vec = v.m_vec;
242  m_persistentSize = v.m_persistentSize;
243  return *this;
244 }
245 
246 #endif
247 
void push_back(const Tp &x)
Definition: PVector.h:177
reverse_iterator rend()
Definition: PVector.h:87
reference at(size_type n)
Definition: PVector.h:147
iterator end()
Definition: PVector.h:67
const_reference at(size_type n) const
Definition: PVector.h:142
const_iterator end() const
Definition: PVector.h:77
std::vector< Tp >::size_type size_type
Definition: PVector.h:23
void resize(size_type n, const Tp &value=Tp())
Definition: PVector.h:112
void clear()
Definition: PVector.h:187
std::vector< Tp >::reverse_iterator reverse_iterator
Definition: PVector.h:35
bool operator!=(const PVector &vec) const
Definition: PVector.h:198
iterator begin()
Definition: PVector.h:62
const_reverse_iterator rbegin() const
Definition: PVector.h:92
size_type max_size() const
Definition: PVector.h:107
const_reference back() const
Definition: PVector.h:167
reference back()
Definition: PVector.h:162
std::vector< Tp > m_vec
Definition: PVector.h:221
size_type persistentSize() const
Definition: PVector.h:212
virtual ~PVector()
Definition: PVector.h:54
bool empty() const
Definition: PVector.h:122
uint16_t size_type
std::vector< Tp >::value_type value_type
Definition: PVector.h:37
void pop_back()
Definition: PVector.h:182
const void * storageAddress() const
Definition: PVector.h:206
reverse_iterator rbegin()
Definition: PVector.h:82
const_reference front() const
Definition: PVector.h:157
reference front()
Definition: PVector.h:152
void assign(size_type n, const Tp &u)
Definition: PVector.h:172
Container::value_type value_type
bool operator==(const PVector &vec) const
Definition: PVector.h:193
std::vector< Tp >::iterator iterator
Definition: PVector.h:31
const_iterator begin() const
Definition: PVector.h:72
std::vector< Tp >::const_reverse_iterator const_reverse_iterator
Definition: PVector.h:33
size_type size() const
Definition: PVector.h:102
std::vector< Tp >::const_reference const_reference
Definition: PVector.h:25
std::vector< Tp >::const_iterator const_iterator
Definition: PVector.h:29
reference operator[](size_type n)
Definition: PVector.h:132
PVector< Tp > & operator=(const PVector< Tp > &)
Definition: PVector.h:239
std::vector< Tp > store_type
Definition: PVector.h:40
std::vector< Tp >::reference reference
Definition: PVector.h:27
void reserve(size_type n)
Definition: PVector.h:127
size_type capacity() const
Definition: PVector.h:117
x
Definition: VDTMath.h:216
mathSSE::Vec4< T > v
size_type m_persistentSize
Definition: PVector.h:224
const_reverse_iterator rend() const
Definition: PVector.h:97