ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/libmdtools/Exclude.cpp
Revision: 413
Committed: Wed Mar 26 21:54:49 2003 UTC (21 years, 3 months ago) by mmeineke
File size: 1330 byte(s)
Log Message:
fixed a couple of the "static" bugs in  Atom and Exclude

File Contents

# Content
1 #include <cstdlib>
2
3 #include "Exclude.hpp"
4
5 int* Exclude::exPair
6 int Exclude::nExcludes;
7
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 nExcludes = the_nExcludes;
16 exPairs = new int[nExcludes*2];
17 }
18
19 void Exclude::destroyArray( void ){
20 delete[] exPairs;
21 }
22
23 void Exclude::setPair( int i, int j ){
24 exPairs[exI] = i;
25 exPairs[exJ] = j;
26 }
27
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::deleteExcludePair(int theIndex) {
51 deleteRange(theIndex, theIndex);
52 }
53
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 }