Debian Codegraph @

Source/Reasoner/Kernel/Process/CBackendNeighbourExpansionQueue.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 "CBackendNeighbourExpansionQueue.h"
22
23
24 namespace Konclude {
25
26 namespace Reasoner {
27
28 namespace Kernel {
29
30 namespace Process {
31
32 CBackendNeighbourExpansionQueue::CBackendNeighbourExpansionQueue(CProcessContext* processContext) {
33 }
34
35
36
37 CBackendNeighbourExpansionQueue* CBackendNeighbourExpansionQueue::initBackendNeighbourExpansionQueue(CBackendNeighbourExpansionQueue* queue) {
38 if (queue) {
39 mCurrentQueueLinker = queue->mCurrentQueueLinker;
40 mNextQueueLinker = queue->mNextQueueLinker;
41 mHasPropagationCut = queue->mHasPropagationCut;
42 } else {
43 mHasPropagationCut = false;
44 mCurrentQueueLinker = nullptr;
45 mNextQueueLinker = nullptr;
46 }
47 return this;
48 }
49
50 bool CBackendNeighbourExpansionQueue::hasQueuedNeighbourExpansions() {
51 return mCurrentQueueLinker || mNextQueueLinker;
52 }
53
54 CBackendNeighbourExpansionQueueDataLinker* CBackendNeighbourExpansionQueue::getNextNeighbourExpansionQueueDataLinker() {
55 if (!mCurrentQueueLinker) {
56 mCurrentQueueLinker = mNextQueueLinker;
57 mNextQueueLinker = nullptr;
58 }
59 return mCurrentQueueLinker;
60 }
61
62 CBackendNeighbourExpansionQueueDataLinker* CBackendNeighbourExpansionQueue::takeNextNeighbourExpansionQueueDataLinker() {
63 if (!mCurrentQueueLinker) {
64 mCurrentQueueLinker = mNextQueueLinker;
65 mNextQueueLinker = nullptr;
66 }
67 CBackendNeighbourExpansionQueueDataLinker* linker = mCurrentQueueLinker;
68 if (mCurrentQueueLinker) {
69 mCurrentQueueLinker = mCurrentQueueLinker->getNext();
70 }
71 return linker;
72 }
73
74 CBackendNeighbourExpansionQueue* CBackendNeighbourExpansionQueue::addNeighbourExpansionQueueDataLinker(CBackendNeighbourExpansionQueueDataLinker* linker, bool addPrioritzied) {
75 if (addPrioritzied) {
76 mCurrentQueueLinker = linker->append(mCurrentQueueLinker);
77 } else {
78 mNextQueueLinker = linker->append(mNextQueueLinker);
79 }
80 return this;
81 }
82
83 CBackendNeighbourExpansionQueueDataLinker* CBackendNeighbourExpansionQueue::findNeighbourExpansionQueueDataLinker(cint64 arrayIndex) {
84 for (CBackendNeighbourExpansionQueueDataLinker* linkerIt = mCurrentQueueLinker; linkerIt; linkerIt = linkerIt->getNext()) {
85 if (linkerIt->getNeighbourArrayId() == arrayIndex) {
86 return linkerIt;
87 }
88 }
89 for (CBackendNeighbourExpansionQueueDataLinker* linkerIt = mNextQueueLinker; linkerIt; linkerIt = linkerIt->getNext()) {
90 if (linkerIt->getNeighbourArrayId() == arrayIndex) {
91 return linkerIt;
92 }
93 }
94 return nullptr;
95 }
96
97
98 bool CBackendNeighbourExpansionQueue::visitNeighbourExpansionQueueDataLinkers(function<bool(CBackendNeighbourExpansionQueueDataLinker* linker)> visitFunc) {
99 bool visisted = false;
100 bool continueVisiting = true;
101 for (CBackendNeighbourExpansionQueueDataLinker* linkerIt = mCurrentQueueLinker; linkerIt && continueVisiting; linkerIt = linkerIt->getNext()) {
102 continueVisiting = visitFunc(linkerIt);
103 visisted = true;
104 }
105 for (CBackendNeighbourExpansionQueueDataLinker* linkerIt = mNextQueueLinker; linkerIt && continueVisiting; linkerIt = linkerIt->getNext()) {
106 continueVisiting = visitFunc(linkerIt);
107 visisted = true;
108 }
109 return visisted;
110 }
111
112 bool CBackendNeighbourExpansionQueue::hasCuttedPropagationCutPropagation() {
113 return mHasPropagationCut;
114 }
115
116 CBackendNeighbourExpansionQueue* CBackendNeighbourExpansionQueue::setCuttedPropagationCutPropagation(bool hasPropagationCut) {
117 mHasPropagationCut = hasPropagationCut;
118 return this;
119 }
120
121
122 }; // end namespace Process
123
124 }; // end namespace Kernel
125
126 }; // end namespace Reasoner
127
128 }; // end namespace Konclude