ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/libmdtools/Exclude.cpp
Revision: 412
Committed: Wed Mar 26 21:50:33 2003 UTC (21 years, 3 months ago) by mmeineke
File size: 1286 byte(s)
Log Message:
still working on the SimSetup routine. also fixed some things in Exclude.hpp

File Contents

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