1 |
mmeineke |
803 |
#include <string.h> |
2 |
|
|
|
3 |
|
|
#include "PairCorrList.hpp" |
4 |
|
|
|
5 |
|
|
|
6 |
|
|
PairCorrList::PairCorrList( pairCorrEnum type, char* atom1, char* atom2 ){ |
7 |
|
|
|
8 |
|
|
myType = type; |
9 |
|
|
strncpy( myAtom1, atom1, PCL_NAME_LENGTH ); |
10 |
|
|
strncpy( myAtom2, atom2, PCL_NAME_LENGTH ); |
11 |
|
|
} |
12 |
|
|
|
13 |
|
|
void PairCorrList::setAtomPair(char* atom1, char* atom2 ){ |
14 |
|
|
|
15 |
|
|
strncpy( myAtom1, atom1, PCL_NAME_LENGTH ); |
16 |
|
|
strncpy( myAtom2, atom2, PCL_NAME_LENGTH ); |
17 |
|
|
} |
18 |
|
|
|
19 |
|
|
void PairCorrList::getAtom1( char* outString ){ |
20 |
|
|
|
21 |
|
|
strcpy( outString, myAtom1 ); |
22 |
|
|
} |
23 |
|
|
|
24 |
|
|
void PairCorrList::getAtom2( char* outString ){ |
25 |
|
|
|
26 |
|
|
strcpy( outString, myAtom2 ); |
27 |
|
|
} |
28 |
|
|
|
29 |
|
|
|
30 |
|
|
bool operator<(PairCorrList a, PairCorrList b){ |
31 |
|
|
|
32 |
|
|
char nameA[PCL_NAME_LENGTH]; |
33 |
|
|
char nameB[PCL_NAME_LENGTH]; |
34 |
|
|
|
35 |
|
|
if( a.getType() < b.getType() ) |
36 |
|
|
return true; |
37 |
|
|
else if( a.getType() == b.getType() ){ |
38 |
|
|
|
39 |
|
|
a.getAtom1(nameA); |
40 |
|
|
b.getAtom1(nameB); |
41 |
|
|
|
42 |
|
|
if( strcmp(nameA, nameB) < 0 ) |
43 |
|
|
return true; |
44 |
|
|
else if( !strcmp(nameA, nameB) ){ |
45 |
|
|
|
46 |
|
|
a.getAtom2(nameA); |
47 |
|
|
b.getAtom2(nameB); |
48 |
|
|
|
49 |
|
|
if( strcmp(nameA, nameB) < 0 ) |
50 |
|
|
return true; |
51 |
|
|
} |
52 |
|
|
} |
53 |
|
|
return false; |
54 |
|
|
} |
55 |
|
|
|
56 |
|
|
bool operator==(PairCorrList a, PairCorrList b){ |
57 |
|
|
|
58 |
|
|
char nameA[PCL_NAME_LENGTH]; |
59 |
|
|
char nameB[PCL_NAME_LENGTH]; |
60 |
|
|
|
61 |
|
|
if( a.getType() == b.getType() ){ |
62 |
|
|
a.getAtom1(nameA); |
63 |
|
|
b.getAtom1(nameB); |
64 |
|
|
|
65 |
|
|
if( !strcmp(nameA, nameB) ){ |
66 |
|
|
|
67 |
|
|
a.getAtom2(nameA); |
68 |
|
|
b.getAtom2(nameB); |
69 |
|
|
|
70 |
|
|
if( !strcmp(nameA, nameB) ) |
71 |
|
|
return true; |
72 |
|
|
} |
73 |
|
|
} |
74 |
|
|
return false; |
75 |
|
|
|
76 |
|
|
} |