ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/libmdtools/Exclude.cpp
(Generate patch)

Comparing trunk/OOPSE/libmdtools/Exclude.cpp (file contents):
Revision 408 by mmeineke, Wed Mar 26 20:45:07 2003 UTC vs.
Revision 431 by mmeineke, Thu Mar 27 22:16:27 2003 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines