ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/libmdtools/Exclude.cpp
Revision: 829
Committed: Tue Oct 28 16:03:37 2003 UTC (20 years, 8 months ago) by gezelter
File size: 1507 byte(s)
Log Message:
replace c++ header stuff with more portable c header stuff
Also, mod file fixes and portability changes
Some fortran changes will need to be reversed.

File Contents

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