| 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 "CConnectionSuccessorSetIterator.h" |
| 22 |
|
| 23 |
|
| 24 |
namespace Konclude { |
| 25 |
|
| 26 |
namespace Reasoner { |
| 27 |
|
| 28 |
namespace Kernel { |
| 29 |
|
| 30 |
namespace Process { |
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
CConnectionSuccessorSetIterator::CConnectionSuccessorSetIterator(cint64 connID) { |
| 35 |
mConnID = connID; |
| 36 |
mIterator1 = false; |
| 37 |
mIterator2 = false; |
| 38 |
} |
| 39 |
|
| 40 |
|
| 41 |
CConnectionSuccessorSetIterator::CConnectionSuccessorSetIterator(const CPROCESSSET<cint64>::iterator& beginIt, const CPROCESSSET<cint64>::iterator& endIt) |
| 42 |
: mBeginIt1(beginIt),mEndIt1(endIt) { |
| 43 |
mConnID = CINT64_MIN; |
| 44 |
mIterator1 = true; |
| 45 |
mIterator2 = false; |
| 46 |
} |
| 47 |
|
| 48 |
CConnectionSuccessorSetIterator::CConnectionSuccessorSetIterator(const CPROCESSSET<cint64>::iterator& beginIt1, const CPROCESSSET<cint64>::iterator& endIt1, const CPROCESSSET<cint64>::iterator& beginIt2, const CPROCESSSET<cint64>::iterator& endIt2) |
| 49 |
: mBeginIt1(beginIt1), mEndIt1(endIt1), mBeginIt2(beginIt2), mEndIt2(endIt2) { |
| 50 |
mConnID = CINT64_MIN; |
| 51 |
mIterator1 = true; |
| 52 |
mIterator2 = true; |
| 53 |
} |
| 54 |
|
| 55 |
|
| 56 |
bool CConnectionSuccessorSetIterator::hasNext() { |
| 57 |
return mConnID != CINT64_MIN || mIterator1 && mBeginIt1 != mEndIt1 || mIterator2 && mBeginIt2 != mEndIt2; |
| 58 |
} |
| 59 |
|
| 60 |
cint64 CConnectionSuccessorSetIterator::nextSuccessorConnectionID(bool moveNext) { |
| 61 |
cint64 indiID = 0; |
| 62 |
if (mConnID != CINT64_MIN) { |
| 63 |
indiID = mConnID; |
| 64 |
if (moveNext) { |
| 65 |
mConnID = CINT64_MIN; |
| 66 |
} |
| 67 |
} |
| 68 |
if (mIterator1 && mBeginIt1 != mEndIt1) { |
| 69 |
indiID = *mBeginIt1; |
| 70 |
if (moveNext) { |
| 71 |
++mBeginIt1; |
| 72 |
} |
| 73 |
} else if (mIterator2 && mBeginIt2 != mEndIt2) { |
| 74 |
indiID = *mBeginIt2; |
| 75 |
if (moveNext) { |
| 76 |
++mBeginIt2; |
| 77 |
} |
| 78 |
} |
| 79 |
return indiID; |
| 80 |
} |
| 81 |
|
| 82 |
|
| 83 |
cint64 CConnectionSuccessorSetIterator::next(bool moveNext) { |
| 84 |
return nextSuccessorConnectionID(moveNext); |
| 85 |
} |
| 86 |
|
| 87 |
}; // end namespace Process |
| 88 |
|
| 89 |
}; // end namespace Kernel |
| 90 |
|
| 91 |
}; // end namespace Reasoner |
| 92 |
|
| 93 |
}; // end namespace Konclude |