2 |
|
|
3 |
|
#include "Exclude.hpp" |
4 |
|
|
5 |
< |
double* Exclude::exPair; |
5 |
> |
int* Exclude::exPair |
6 |
> |
int Exclude::nExcludes; |
7 |
|
|
8 |
< |
Exclude::Exclude( int theIndex ){ |
8 |
> |
Exclude::Exclude( int theIndex ){ |
9 |
> |
exI = theIndex*2; |
10 |
> |
exJ = theIndex*2 + 1; |
11 |
> |
} |
12 |
> |
|
13 |
> |
void Exclude::createArray( int the_nExcludes ){ |
14 |
|
|
15 |
< |
exI = index*2; |
16 |
< |
exJ = index*2 + 1; |
15 |
> |
nExcludes = the_nExcludes; |
16 |
> |
exPairs = new int[nExcludes*2]; |
17 |
|
} |
18 |
|
|
19 |
< |
void Exclude::createArray( int nExcludes ){ |
19 |
> |
void Exclude::destroyArray( void ){ |
20 |
> |
delete[] exPairs; |
21 |
> |
} |
22 |
|
|
23 |
< |
exPair = new int[nExcludes*2]; |
23 |
> |
void Exclude::setPair( int i, int j ){ |
24 |
> |
exPairs[exI] = i; |
25 |
> |
exPairs[exJ] = j; |
26 |
|
} |
27 |
|
|
28 |
< |
void destroyArray( void ){ |
29 |
< |
delete[] exPair; |
28 |
> |
void Exclude::addExcludePairs(int nAdded, int* AexPairs) { |
29 |
> |
int nNew = nExcludes + nAdded; |
30 |
> |
|
31 |
> |
int* new_exPairs = new int[nNew*2]; |
32 |
> |
int i, j; |
33 |
> |
|
34 |
> |
for (i = 0; i < 2*nExcludes; i++) { |
35 |
> |
new_exPairs[i] = exPairs[i]; |
36 |
> |
} |
37 |
> |
|
38 |
> |
for (i=0; i < 2*nAdded; i++) { |
39 |
> |
j = i + 2*nExcludes; |
40 |
> |
new_exPairs[j] = AexPairs[i]; |
41 |
> |
} |
42 |
> |
|
43 |
> |
delete[] exPairs; |
44 |
> |
|
45 |
> |
exPairs = new_exPairs; |
46 |
> |
|
47 |
> |
nExcludes = nNew; |
48 |
|
} |
49 |
|
|
50 |
< |
void Exclude::setPair( int i, int j ){ |
50 |
> |
void Exclude::deleteExcludePair(int theIndex) { |
51 |
> |
deleteRange(theIndex, theIndex); |
52 |
> |
} |
53 |
|
|
54 |
< |
exPair[exI] = i; |
55 |
< |
exPair[exJ] = j; |
54 |
> |
void Exclude::deleteRange(int startIndex, int stopIndex) { |
55 |
> |
|
56 |
> |
int nNew = nExcludes - (stopIndex - startIndex + 1); |
57 |
> |
int* new_exPairs = new int[nNew*2]; |
58 |
> |
int i, j; |
59 |
> |
|
60 |
> |
for (i=0; i < 2*startIndex; i++) { |
61 |
> |
new_exPairs[i] = exPairs[i]; |
62 |
> |
} |
63 |
> |
for(i=2*(stopIndex+1); i < 2*nExcludes; i++) { |
64 |
> |
j = i-2*startIndex + 1; |
65 |
> |
new_exPairs[j] = exPairs[i]; |
66 |
> |
} |
67 |
> |
|
68 |
> |
delete[] exPairs; |
69 |
> |
|
70 |
> |
exPairs = new_exPairs; |
71 |
> |
nExcludes = nNew; |
72 |
|
} |