Xmipp  v3.23.11-Nereus
VectorInt.h
Go to the documentation of this file.
1 /*
2 
3 CONDOR 1.06 - COnstrained, Non-linear, Direct, parallel Optimization
4  using trust Region method for high-computing load,
5  noisy functions
6 Copyright (C) 2004 Frank Vanden Berghen
7 
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 as published by the Free Software Foundation version 2
11 of the License.
12 
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17 
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 
22 If you want to include this tools in any commercial product,
23 you can contact the author at fvandenb@iridia.ulb.ac.be
24 
25 */
26 #ifndef _INCLUDE_VectorIntINT_H
27 #define _INCLUDE_VectorIntINT_H
28 
29 #include <stdlib.h>
30 
31 class VectorInt
32 {
33  public:
34  typedef struct VectorIntDataTag
35  {
36  int n,extention;
37  int ref_count;
38  int *p;
39  } VectorIntData;
41 
42  VectorInt(int _n=0);
43  VectorInt(int _n, int _ext);
44  VectorInt(int _n, int *d);
45 
46 // allow shallow copy:
47  VectorInt clone();
48  void copyFrom(VectorInt r);
49  VectorInt( const VectorInt& P );
50  VectorInt& operator=( const VectorInt& P );
51  void destroyCurrentBuffer();
52  ~VectorInt();
53 
54  void extend();
55  void setSize(int _n);
56  void exactshape();
57  void print();
58 
59  // only use the following method at your own risks!
60  void prepareExtend(int new_extention);
61 
62 // int &operator [](int i) { return p[i]; };
63  inline int sz() {return d->n;};
64  int operator==( const VectorInt& P) {return (d==P.d);}
65  operator int*() const { return d->p; };
66 // operator unsigned*() const { return (unsigned*)p; };
67 // int &operator[]( unsigned i) {return p[i];};
68  int equals( const VectorInt& Q );
69 
71 
72 private:
73  void alloc(int, int);
74 
75 };
76 
77 #endif
78 
int sz()
Definition: VectorInt.h:63
void print()
Definition: VectorInt.cpp:165
void destroyCurrentBuffer()
Definition: VectorInt.cpp:80
int equals(const VectorInt &Q)
Definition: VectorInt.cpp:148
VectorInt(int _n=0)
Definition: VectorInt.cpp:46
void setSize(int _n)
Definition: VectorInt.cpp:126
struct VectorInt::VectorIntDataTag VectorIntData
void copyFrom(VectorInt r)
Definition: VectorInt.cpp:118
void exactshape()
Definition: VectorInt.cpp:139
int operator==(const VectorInt &P)
Definition: VectorInt.h:64
void prepareExtend(int new_extention)
Definition: VectorInt.cpp:65
VectorIntData * d
Definition: VectorInt.h:40
void extend()
Definition: VectorInt.cpp:133
VectorInt & operator=(const VectorInt &P)
Definition: VectorInt.cpp:98
static VectorInt emptyVectorInt
Definition: VectorInt.h:70
VectorInt clone()
Definition: VectorInt.cpp:110