Debian Codegraph @

Source/Reasoner/Kernel/Process/CConceptLabelSetIterator.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 "CConceptLabelSetIterator.h"
22
23
24 namespace Konclude {
25
26 namespace Reasoner {
27
28 namespace Kernel {
29
30 namespace Process {
31
32
33
34 CConceptLabelSetIterator::CConceptLabelSetIterator(cint64 conceptCount, CConceptDescriptor* conceptDesLinker, const CPROCESSMAP<cint64,CConceptDescriptorDependencyPair>::iterator& beginIt, const CPROCESSMAP<cint64,CConceptDescriptorDependencyPair>::iterator& endIt)
35 : mConceptCount(conceptCount),mConceptDesLinkerIt(conceptDesLinker),mConDesDepBeginIt(beginIt),mConDesDepEndIt(endIt) {
36 }
37
38
39
40 cint64 CConceptLabelSetIterator::getRemainingConceptCount() {
41 return mConceptCount;
42 }
43
44
45 CConceptLabelSetIterator& CConceptLabelSetIterator::operator++() {
46 return *moveNext();
47 }
48
49 CConceptDescriptor* CConceptLabelSetIterator::operator*() {
50 return getConceptDescriptor();
51 }
52
53
54 CConceptLabelSetIterator* CConceptLabelSetIterator::moveNext() {
55 if (mConceptDesLinkerIt) {
56 mConceptDesLinkerIt = mConceptDesLinkerIt->getNext();
57 --mConceptCount;
58 } else {
59 if (mConDesDepBeginIt != mConDesDepEndIt) {
60 ++mConDesDepBeginIt;
61 --mConceptCount;
62 }
63 }
64 return this;
65 }
66
67 CConceptDescriptor* CConceptLabelSetIterator::getConceptDescriptor() {
68 if (mConceptDesLinkerIt) {
69 return mConceptDesLinkerIt;
70 } else {
71 return mConDesDepBeginIt.value().first;
72 }
73 }
74
75 CDependencyTrackPoint* CConceptLabelSetIterator::getDependencyTrackPoint() {
76 if (mConceptDesLinkerIt) {
77 return nullptr;
78 } else {
79 return mConDesDepBeginIt.value().second;
80 }
81 }
82
83
84 CConceptDescriptor* CConceptLabelSetIterator::next(bool moveToNext) {
85 CConceptDescriptor* conDes = getConceptDescriptor();
86 if (moveToNext) {
87 moveNext();
88 }
89 return conDes;
90 }
91
92 bool CConceptLabelSetIterator::hasValue() {
93 return mConceptDesLinkerIt || mConDesDepBeginIt != mConDesDepEndIt;
94 }
95
96 bool CConceptLabelSetIterator::hasNext() {
97 return mConceptDesLinkerIt || mConDesDepBeginIt != mConDesDepEndIt;
98 }
99
100 bool CConceptLabelSetIterator::operator!=(CConceptLabelSetIterator& iterator) {
101 return mConceptDesLinkerIt != iterator.mConceptDesLinkerIt || mConDesDepBeginIt != iterator.mConDesDepBeginIt;
102 }
103
104 bool CConceptLabelSetIterator::operator==(CConceptLabelSetIterator& iterator) {
105 return mConceptDesLinkerIt == iterator.mConceptDesLinkerIt && mConDesDepBeginIt == iterator.mConDesDepBeginIt;
106 }
107
108 }; // end namespace Process
109
110 }; // end namespace Kernel
111
112 }; // end namespace Reasoner
113
114 }; // end namespace Konclude