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 438 by chuckv, Mon Mar 31 21:50:59 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    
12 +  index = theIndex;
13    exI = index*2;
14    exJ = index*2 + 1;
15   }
16  
17 < void Exclude::createArray( int nExcludes ){
17 > void Exclude::createArray( int the_nExcludes ){
18 >  
19 >  nExcludes = the_nExcludes;
20 >  std::cerr << "nExcludes = " << nExcludes << "\n";
21 >  exPairs = new int[nExcludes*2];
22 > }
23  
24 <  exPair = new int[nExcludes*2];
24 > void Exclude::destroyArray( void ){
25 >  delete[] exPairs;
26   }
27  
28 < void destroyArray( void ){
29 <  delete[] exPair;
28 > void Exclude::printMe( void ){
29 >  
30 >  std::cerr << "exclude[" << index << "] i, j: " << exPairs[exI] << " - " << exPairs[exJ] << "\n";
31   }
32  
33   void Exclude::setPair( int i, int j ){
34 +  exPairs[exI] = i;
35 +  exPairs[exJ] = j;
36 + }
37  
38 <  exPair[exI] = i;
39 <  exPair[exJ] = j;
38 > void Exclude::addExcludePairs(int nAdded, int* AexPairs) {
39 >  int nNew = nExcludes + nAdded;
40 >  
41 >  int* new_exPairs = new int[nNew*2];
42 >  int i, j;
43 >
44 >  for (i = 0; i < 2*nExcludes; i++) {
45 >    new_exPairs[i] = exPairs[i];
46 >  }
47 >
48 >  for (i=0; i < 2*nAdded; i++) {
49 >    j = i + 2*nExcludes;
50 >    new_exPairs[j] = AexPairs[i];
51 >  }
52 >
53 >  delete[] exPairs;
54 >
55 >  exPairs = new_exPairs;
56 >
57 >  nExcludes = nNew;
58   }
59 +
60 + void Exclude::deleteExcludePair(int theIndex) {
61 +  deleteRange(theIndex, theIndex);
62 + }
63 +
64 + void Exclude::deleteRange(int startIndex, int stopIndex) {
65 +
66 +  int nNew = nExcludes - (stopIndex - startIndex + 1);
67 +  int* new_exPairs = new int[nNew*2];
68 +  int i, j;
69 +
70 +  for (i=0; i < 2*startIndex; i++) {
71 +    new_exPairs[i] = exPairs[i];
72 +  }
73 +  for(i=2*(stopIndex+1); i < 2*nExcludes; i++) {
74 +    j = i-2*startIndex + 1;
75 +    new_exPairs[j] = exPairs[i];
76 +  }
77 +
78 +  delete[] exPairs;
79 +  
80 +  exPairs = new_exPairs;
81 +  nExcludes = nNew;
82 + }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines