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