A platform for high-performance distributed tool and library development written in C++. It can be deployed in two different cluster modes: standalone or distributed. API for v0.5.0, released on June 13, 2018.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
PDBVector.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * *
3  * Copyright 2018 Rice University *
4  * *
5  * Licensed under the Apache License, Version 2.0 (the "License"); *
6  * you may not use this file except in compliance with the License. *
7  * You may obtain a copy of the License at *
8  * *
9  * http://www.apache.org/licenses/LICENSE-2.0 *
10  * *
11  * Unless required by applicable law or agreed to in writing, software *
12  * distributed under the License is distributed on an "AS IS" BASIS, *
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
14  * See the License for the specific language governing permissions and *
15  * limitations under the License. *
16  * *
17  *****************************************************************************/
18 
19 #include "Object.h"
20 #include "PDBTemplateBase.h"
21 #include "Handle.h"
22 #include "Array.h"
23 
24 #ifndef VECTOR_H
25 #define VECTOR_H
26 
27 #include <cstddef>
28 #include <iostream>
29 #include <iterator>
30 #include <cstring>
31 
32 // PRELOAD %Vector <Nothing>%
33 
34 namespace pdb {
35 
36 // This is the basic Vector type that works correcrly with Objects and Handles.
37 // The operations have exactly the same interface as std :: vector, except that
38 // not all operations are implemented.
39 
40 template <class TypeContained>
41 class Vector : public Object {
42 
43 private:
44  // this is where the data are actually stored
46 
47 public:
49 
50  // this constructor pre-allocates initSize slots, and then initializes
51  // numUsed of them, calling a no-arg constructor on each. Thus, after
52  // this call, size () will return numUsed
53  Vector(uint32_t initSize, uint32_t numUsed);
54 
55  // this constructor pre-allocates initSize slots, but does not do anything
56  // to them. Thus, after this call, size () will return zero
57  Vector(uint32_t initSize);
58 
59  // these operations all have the same semantics as in std :: vector
60  Vector();
61  size_t size() const;
62  TypeContained& operator[](uint32_t which);
63  TypeContained& operator[](uint32_t which) const;
64  void assign(uint32_t which, const TypeContained& val);
65  void push_back(const TypeContained& val);
66  void push_back();
67  void pop_back();
68  void clear();
69  TypeContained* c_ptr() const;
70  void resize(uint32_t toMe);
71 
72  // added by Shangyu
73  void print() const;
74  void fill(const TypeContained& val);
75 
76  // beause the communicator needs to see inside to do efficient sends
77  friend class PDBCommunicator;
78 };
79 }
80 
81 #include "PDBVector.cc"
82 
83 #endif
#define ENABLE_DEEP_COPY
Definition: DeepCopy.h:52
TypeContained * c_ptr() const
Definition: PDBVector.cc:118
Handle< Array< TypeContained > > myArray
Definition: PDBVector.h:45
void resize(uint32_t toMe)
Definition: PDBVector.cc:113
void print() const
Definition: PDBVector.cc:125
void push_back()
Definition: PDBVector.cc:87
void pop_back()
Definition: PDBVector.cc:103
void assign(uint32_t which, const TypeContained &val)
Definition: PDBVector.cc:82
TypeContained & operator[](uint32_t which)
Definition: PDBVector.cc:72
size_t size() const
Definition: PDBVector.cc:67
void clear()
Definition: PDBVector.cc:108
void fill(const TypeContained &val)
Definition: PDBVector.cc:135