Debian Codegraph @

Source/Parser/Expressions/COrderedListVariableAssociator.cpp

raw
1 /*
2 * Copyright (C) 2013-2015, 2019 by the Konclude Developer Team.
3 *
4 * This file is part of the reasoning system Konclude.
5 * For details and support, see <http://konclude.com/>.
6 *
7 * Konclude is free software: you can redistribute it and/or modify
8 * it under the terms of version 3 of the GNU Lesser General Public
9 * License (LGPLv3) as published by the Free Software Foundation.
10 *
11 * Konclude is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU (Lesser) General Public License for more details.
15 *
16 * You should have received a copy of the GNU (Lesser) General Public
17 * License along with Konclude. If not, see <http://www.gnu.org/licenses/>.
18 *
19 */
20
21 #include "COrderedListVariableAssociator.h"
22
23
24 namespace Konclude {
25
26 namespace Parser {
27
28 namespace Expression {
29
30
31 COrderedListVariableAssociator::COrderedListVariableAssociator(CExpressionVariable *variable1, CExpressionVariable *variable2, CExpressionVariable *variable3)
32 : CListVariableAssociator(variable1,variable2,variable3) {
33 }
34
35
36 COrderedListVariableAssociator::COrderedListVariableAssociator(const CEXPRESSIONLIST<CExpressionVariable*>& variableList) : CListVariableAssociator(*(CEXPRESSIONLIST<CExpressionVariable*>*)&variableList) {
37 }
38
39
40 COrderedListVariableAssociator::~COrderedListVariableAssociator() {
41 }
42
43
44 cint64 COrderedListVariableAssociator::getStructuralHashValue() {
45 cint64 hashValue = 0;
46 FOREACHIT (CExpressionVariable* variable, mVariableList) {
47 hashValue += CExpressionHashMixer::getHashValueMixed(hashValue,cint64(variable));
48 }
49 return hashValue;
50 }
51
52 bool COrderedListVariableAssociator::compareStructuralEquivalence(const CListVariableAssociator& listExpressionAssociator) {
53 const CEXPRESSIONLIST<CExpressionVariable*>* otherListExp = listExpressionAssociator.getConstVariableList();
54 if (mVariableList.count() != otherListExp->count()) {
55 return false;
56 }
57 for (CEXPRESSIONLIST<CExpressionVariable*>::const_iterator it1 = mVariableList.constBegin(), it1End = mVariableList.constEnd(),
58 it2 = otherListExp->constBegin(), it2End = otherListExp->constEnd(); it1 != it1End && it2 != it2End; ++it1,++it2) {
59 if (*it1 != *it2) {
60 return false;
61 }
62 }
63 return true;
64 }
65
66 bool COrderedListVariableAssociator::compareStructuralEquivalence(const COrderedListVariableAssociator& orderedListExpressionAssociator) {
67 const CEXPRESSIONLIST<CExpressionVariable*>* otherListExp = orderedListExpressionAssociator.getConstVariableList();
68 if (mVariableList.count() != otherListExp->count()) {
69 return false;
70 }
71 for (CEXPRESSIONLIST<CExpressionVariable*>::const_iterator it1 = mVariableList.constBegin(), it1End = mVariableList.constEnd(),
72 it2 = otherListExp->constBegin(), it2End = otherListExp->constEnd(); it1 != it1End && it2 != it2End; ++it1,++it2) {
73 if (*it1 != *it2) {
74 return false;
75 }
76 }
77 return true;
78 }
79
80 CEXPRESSIONLIST<CExpressionVariable*>* COrderedListVariableAssociator::getOrderedVariableList() {
81 return &mVariableList;
82 }
83
84
85 }; // end namespace Expression
86
87 }; // end namespace Parser
88
89 }; // end namespace Konclude