Debian Codegraph @

Source/Reasoner/Kernel/Cache/CBackendRepresentativeMemoryLabelCacheItemIndividualRoleSetNeighbourArrayIndexExtensionData.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 "CBackendRepresentativeMemoryLabelCacheItemIndividualRoleSetNeighbourArrayIndexExtensionData.h"
22
23
24 namespace Konclude {
25
26 namespace Reasoner {
27
28 namespace Kernel {
29
30 namespace Cache {
31
32
33 CBackendRepresentativeMemoryLabelCacheItemIndividualRoleSetNeighbourArrayIndexExtensionData::CBackendRepresentativeMemoryLabelCacheItemIndividualRoleSetNeighbourArrayIndexExtensionData(CContext* context) : CBackendRepresentativeMemoryLabelCacheItemExtensionData(context) {
34 mCacheItemExtensionType = INDIVIDUAL_NEIGHBOUR_ARRAY_INDEX;
35 }
36
37
38 CBackendRepresentativeMemoryLabelCacheItemIndividualRoleSetNeighbourArrayIndexExtensionData* CBackendRepresentativeMemoryLabelCacheItemIndividualRoleSetNeighbourArrayIndexExtensionData::initNeighbourArrayIndexData(CBackendRepresentativeMemoryLabelCacheItem* combinedNeighbourRoleSetLabel) {
39 mCombinedNeighbourRoleSetLabel = combinedNeighbourRoleSetLabel;
40 mArraySize = mCombinedNeighbourRoleSetLabel->getCacheValueCount();
41 mIndexNeighbourRoleSetLabelArray = CObjectAllocator<CBackendRepresentativeMemoryLabelCacheItem*>::allocateAndConstructArray(mContext->getMemoryAllocationManager(), mArraySize);
42 mNeighbourRoleSetLabelIndexHash = CObjectParameterizingAllocator< CCACHINGHASH<CBackendRepresentativeMemoryLabelCacheItem*, cint64>, CContext* >::allocateAndConstructAndParameterize(mContext->getMemoryAllocationManager(), mContext);
43 CBackendRepresentativeMemoryLabelValueLinker* cacheValueLinker = mCombinedNeighbourRoleSetLabel->getCacheValueLinker();
44 for (cint64 i = 0; i < mArraySize; ++i) {
45 if (cacheValueLinker) {
46 CBackendRepresentativeMemoryLabelCacheItem* neighbourRoleSetLabel = (CBackendRepresentativeMemoryLabelCacheItem*)cacheValueLinker->getCacheValue().getIdentification();
47 mIndexNeighbourRoleSetLabelArray[i] = neighbourRoleSetLabel;
48 mNeighbourRoleSetLabelIndexHash->insert(neighbourRoleSetLabel, i);
49 cacheValueLinker = cacheValueLinker->getNext();
50 } else {
51 mIndexNeighbourRoleSetLabelArray[i] = nullptr;
52 }
53 }
54 return this;
55 }
56
57 CBackendRepresentativeMemoryLabelCacheItemIndividualRoleSetNeighbourArrayIndexExtensionData* CBackendRepresentativeMemoryLabelCacheItemIndividualRoleSetNeighbourArrayIndexExtensionData::initNeighbourArrayIndexData(CBackendRepresentativeMemoryLabelCacheItemIndividualRoleSetNeighbourArrayIndexExtensionData* neighArray) {
58 return this;
59 }
60
61 CBackendRepresentativeMemoryLabelCacheItem* CBackendRepresentativeMemoryLabelCacheItemIndividualRoleSetNeighbourArrayIndexExtensionData::getCombinedNeighbourRoleSetLabel() {
62 return mCombinedNeighbourRoleSetLabel;
63 }
64
65 cint64 CBackendRepresentativeMemoryLabelCacheItemIndividualRoleSetNeighbourArrayIndexExtensionData::getArraySize() {
66 return mArraySize;
67 }
68
69 CBackendRepresentativeMemoryLabelCacheItem* CBackendRepresentativeMemoryLabelCacheItemIndividualRoleSetNeighbourArrayIndexExtensionData::getNeighbourRoleSetLabel(cint64 index) {
70 if (index >= 0 && index < mArraySize) {
71 return mIndexNeighbourRoleSetLabelArray[index];
72 }
73 return nullptr;
74 }
75
76 cint64 CBackendRepresentativeMemoryLabelCacheItemIndividualRoleSetNeighbourArrayIndexExtensionData::getIndex(CBackendRepresentativeMemoryLabelCacheItem* neighbourRoleSetLabel) {
77 return mNeighbourRoleSetLabelIndexHash->value(neighbourRoleSetLabel, -1);
78 }
79
80
81 }; // end namespace Cache
82
83 }; // end namespace Kernel
84
85 }; // end namespace Reasoner
86
87 }; // end namespace Konclude