Debian Codegraph @

Source/Reasoner/Kernel/Process/CSuccessorRoleIterator.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 "CSuccessorRoleIterator.h"
22
23
24 namespace Konclude {
25
26 namespace Reasoner {
27
28 namespace Kernel {
29
30 namespace Process {
31
32 CSuccessorRoleIterator::CSuccessorRoleIterator() {
33 mIterator1 = false;
34 mIterator2 = false;
35 }
36
37 CSuccessorRoleIterator::CSuccessorRoleIterator(cint64 indi, const CPROCESSHASH<cint64,CIndividualLinkEdge*>::iterator& beginIt, const CPROCESSHASH<cint64,CIndividualLinkEdge*>::iterator& endIt)
38 : mIndi(indi),mBeginIt1(beginIt),mEndIt1(endIt) {
39 mIterator1 = true;
40 mIterator2 = false;
41 }
42
43
44 CSuccessorRoleIterator::CSuccessorRoleIterator(cint64 indi, const CPROCESSHASH<cint64, CIndividualLinkEdge*>::iterator& beginIt1, const CPROCESSHASH<cint64, CIndividualLinkEdge*>::iterator& endIt1, const CPROCESSHASH<cint64, CIndividualLinkEdge*>::iterator& beginIt2, const CPROCESSHASH<cint64, CIndividualLinkEdge*>::iterator& endIt2)
45 : mIndi(indi), mBeginIt1(beginIt1), mEndIt1(endIt1), mBeginIt2(beginIt2), mEndIt2(endIt2) {
46 mIterator1 = true;
47 mIterator2 = true;
48 }
49
50
51 bool CSuccessorRoleIterator::hasNext() {
52 return mIterator1 && mBeginIt1 != mEndIt1 && mBeginIt1.key() == mIndi && mBeginIt1.value() != nullptr || mIterator2 && mBeginIt2 != mEndIt2 && mBeginIt2.key() == mIndi && mBeginIt2.value() != nullptr;
53 }
54
55 CIndividualLinkEdge* CSuccessorRoleIterator::next(bool moveNext) {
56 CIndividualLinkEdge* link = nullptr;
57 if (mIterator1 && mBeginIt1 != mEndIt1 && mBeginIt1.key() == mIndi) {
58 link = mBeginIt1.value();
59 if (moveNext) {
60 ++mBeginIt1;
61 }
62 } else if (mIterator2 && mBeginIt2 != mEndIt2 && mBeginIt2.key() == mIndi) {
63 link = mBeginIt2.value();
64 if (moveNext) {
65 ++mBeginIt2;
66 }
67 }
68 return link;
69 }
70
71
72
73 }; // end namespace Process
74
75 }; // end namespace Kernel
76
77 }; // end namespace Reasoner
78
79 }; // end namespace Konclude