| 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 "CReusingReviewData.h" |
| 22 |
|
| 23 |
|
| 24 |
namespace Konclude { |
| 25 |
|
| 26 |
namespace Reasoner { |
| 27 |
|
| 28 |
namespace Kernel { |
| 29 |
|
| 30 |
namespace Process { |
| 31 |
|
| 32 |
|
| 33 |
CReusingReviewData::CReusingReviewData(CProcessContext* context) : mIndividualSet(context),mDepthIndividualMap(context) { |
| 34 |
mContext = context; |
| 35 |
} |
| 36 |
|
| 37 |
|
| 38 |
CReusingReviewData* CReusingReviewData::initReviewData(CReusingReviewData* sigBlockRevData) { |
| 39 |
if (sigBlockRevData) { |
| 40 |
mIndividualSet = sigBlockRevData->mIndividualSet; |
| 41 |
mDepthIndividualMap = sigBlockRevData->mDepthIndividualMap; |
| 42 |
} else { |
| 43 |
mIndividualSet.clear(); |
| 44 |
mDepthIndividualMap.clear(); |
| 45 |
} |
| 46 |
return this; |
| 47 |
} |
| 48 |
|
| 49 |
CReusingReviewData* CReusingReviewData::insert(cint64 depth, cint64 indiID) { |
| 50 |
if (!mIndividualSet.contains(indiID)) { |
| 51 |
mIndividualSet.insert(indiID); |
| 52 |
mDepthIndividualMap.insertMulti(depth,indiID); |
| 53 |
} |
| 54 |
return this; |
| 55 |
} |
| 56 |
|
| 57 |
|
| 58 |
bool CReusingReviewData::contains(cint64 indiID) { |
| 59 |
return mIndividualSet.contains(indiID); |
| 60 |
} |
| 61 |
|
| 62 |
CReusingReviewData* CReusingReviewData::remove(cint64 indiID) { |
| 63 |
mIndividualSet.remove(indiID); |
| 64 |
return this; |
| 65 |
} |
| 66 |
|
| 67 |
bool CReusingReviewData::isEmpty() { |
| 68 |
return mIndividualSet.isEmpty(); |
| 69 |
} |
| 70 |
|
| 71 |
bool CReusingReviewData::hasNextIndividualID() { |
| 72 |
return mIndividualSet.isEmpty(); |
| 73 |
} |
| 74 |
|
| 75 |
cint64 CReusingReviewData::takeNextIndividualID() { |
| 76 |
cint64 indiID = 0; |
| 77 |
CPROCESSMAP<cint64,cint64>::iterator depthIndividualMapIt = mDepthIndividualMap.begin(), depthIndividualMapItEnd = mDepthIndividualMap.end(); |
| 78 |
while (depthIndividualMapIt != depthIndividualMapItEnd) { |
| 79 |
indiID = depthIndividualMapIt.value(); |
| 80 |
depthIndividualMapIt = mDepthIndividualMap.erase(depthIndividualMapIt); |
| 81 |
if (mIndividualSet.contains(indiID)) { |
| 82 |
mIndividualSet.remove(indiID); |
| 83 |
break; |
| 84 |
} |
| 85 |
} |
| 86 |
return indiID; |
| 87 |
} |
| 88 |
|
| 89 |
|
| 90 |
}; // end namespace Process |
| 91 |
|
| 92 |
}; // end namespace Kernel |
| 93 |
|
| 94 |
}; // end namespace Reasoner |
| 95 |
|
| 96 |
}; // end namespace Konclude |