Gadget
intvector.h
Go to the documentation of this file.
1 #ifndef intvector_h
2 #define intvector_h
3 
4 #include "commentstream.h"
5 #include "gadget.h"
6 
11 class IntVector {
12 public:
16  IntVector() { size = 0; v = 0; };
22  IntVector(int sz, int initial);
27  IntVector(const IntVector& initial);
32  ~IntVector();
38  void resize(int addsize, int value);
44  void Delete(int pos);
49  int Size() const { return size; };
55  int& operator [] (int pos) { return v[pos]; };
61  const int& operator [] (int pos) const { return v[pos]; };
66  void Reset();
70  void setToZero();
75  IntVector& operator = (const IntVector& iv);
76 protected:
80  int* v;
84  int size;
85 };
86 
87 #endif
This class implements a dynamic vector of int values.
Definition: intvector.h:11
~IntVector()
This is the IntVector destructor.
Definition: intvector.cc:26
IntVector & operator=(const IntVector &iv)
This operator will set the vector equal to an existing IntVector.
Definition: intvector.cc:74
void resize(int addsize, int value)
This will add new entries to the vector.
Definition: intvector.cc:33
IntVector()
This is the default IntVector constructor.
Definition: intvector.h:16
void Reset()
This will reset the vector.
Definition: intvector.cc:95
int size
This is the size of the vector.
Definition: intvector.h:84
int & operator[](int pos)
This will return the value of an element of the vector.
Definition: intvector.h:55
void Delete(int pos)
This will delete an entry from the vector.
Definition: intvector.cc:56
int * v
This is the vector of int values.
Definition: intvector.h:80
void setToZero()
This function will set all of the entries of the vector to zero.
Definition: intvector.cc:103
int Size() const
This will return the size of the vector.
Definition: intvector.h:49