Debian Codegraph @

Source/Utilities/Container/CDoubleDynamicReferenceVector.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 #ifndef KONCLUDE_UTILITIES_CONTAINER_CDOUBLEDYNAMICREFERENCEVECTOR_CPP
22 #define KONCLUDE_UTILITIES_CONTAINER_CDOUBLEDYNAMICREFERENCEVECTOR_CPP
23
24
25 #include "CDoubleDynamicReferenceVector.h"
26
27
28 namespace Konclude {
29
30 namespace Utilities {
31
32 namespace Container {
33
34 template<class T, class S, cint64 bucket2Size>
35 CDoubleDynamicReferenceVectorBase<T,S,bucket2Size>::CDoubleDynamicReferenceVectorBase(CContext* context) : mFirstVector(context),mSecondVector(context) {
36 clear();
37 }
38
39
40 template<class T, class S, cint64 bucket2Size>
41 CDoubleDynamicReferenceVectorBase<T,S,bucket2Size>::~CDoubleDynamicReferenceVectorBase() {
42 }
43
44
45 template<class T, class S, cint64 bucket2Size>
46 const T CDoubleDynamicReferenceVectorBase<T,S,bucket2Size>::getData(cint64 index, const T& defaultValue) {
47 if (index <= 0) {
48 return mFirstVector.getData(-(index),defaultValue);
49 } else {
50 return mSecondVector.getData(index,defaultValue);
51 }
52 }
53
54 template<class T, class S, cint64 bucket2Size>
55 const T CDoubleDynamicReferenceVectorBase<T,S,bucket2Size>::getData(cint64 index, const T& defaultValue, bool* localFlag) {
56 if (index <= 0) {
57 return mFirstVector.getData(-(index),defaultValue,localFlag);
58 } else {
59 return mSecondVector.getData(index,defaultValue,localFlag);
60 }
61 }
62
63 template<class T, class S, cint64 bucket2Size>
64 const T CDoubleDynamicReferenceVectorBase<T,S,bucket2Size>::getLocalData(cint64 index, const T& defaultValue) {
65 if (index <= 0) {
66 return mFirstVector.getLocalData(-(index),defaultValue);
67 } else {
68 return mSecondVector.getLocalData(index,defaultValue);
69 }
70 }
71
72 template<class T, class S, cint64 bucket2Size>
73 const T CDoubleDynamicReferenceVectorBase<T,S,bucket2Size>::getReferenceData(cint64 index, const T& defaultValue) {
74 if (index <= 0) {
75 return mFirstVector.getReferenceData(-(index),defaultValue);
76 } else {
77 return mSecondVector.getReferenceData(index,defaultValue);
78 }
79 }
80
81
82 template<class T, class S, cint64 bucket2Size>
83 S* CDoubleDynamicReferenceVectorBase<T,S,bucket2Size>::setLocalData(cint64 index, const T& data) {
84 if (index <= 0) {
85 mFirstVector.setLocalData(-(index),data);
86 } else {
87 mSecondVector.setLocalData(index,data);
88 }
89 return (S*)this;
90 }
91
92 template<class T, class S, cint64 bucket2Size>
93 S* CDoubleDynamicReferenceVectorBase<T,S,bucket2Size>::setData(cint64 index, const T& data) {
94 if (index <= 0) {
95 mFirstVector.setData(-(index),data);
96 } else {
97 mSecondVector.setData(index,data);
98 }
99 return (S*)this;
100 }
101
102
103
104 template<class T, class S, cint64 bucket2Size>
105 bool CDoubleDynamicReferenceVectorBase<T,S,bucket2Size>::hasLocalData(cint64 index) {
106 if (index <= 0) {
107 return mFirstVector.hasLocalData(-(index));
108 } else {
109 return mSecondVector.hasLocalData(index);
110 }
111 }
112
113 template<class T, class S, cint64 bucket2Size>
114 bool CDoubleDynamicReferenceVectorBase<T,S,bucket2Size>::hasData(cint64 index) {
115 if (index <= 0) {
116 return mFirstVector.hasData(-(index));
117 } else {
118 return mSecondVector.hasData(index);
119 }
120 }
121
122 template<class T, class S, cint64 bucket2Size>
123 bool CDoubleDynamicReferenceVectorBase<T,S,bucket2Size>::hasReferencedData(cint64 index) {
124 if (index <= 0) {
125 return mFirstVector.hasReferencedData(-(index));
126 } else {
127 return mSecondVector.hasReferencedData(index);
128 }
129 }
130
131
132 template<class T, class S, cint64 bucket2Size>
133 S* CDoubleDynamicReferenceVectorBase<T,S,bucket2Size>::clear() {
134 mFirstVector.clear();
135 mSecondVector.clear();
136 return (S*)this;
137 }
138
139 template<class T, class S, cint64 bucket2Size>
140 S* CDoubleDynamicReferenceVectorBase<T,S,bucket2Size>::referenceVector(CDoubleDynamicReferenceVectorBase<T,S,bucket2Size>* refVector) {
141 clear();
142 mFirstVector.referenceVector(&refVector->mFirstVector);
143 mSecondVector.referenceVector(&refVector->mSecondVector);
144 return (S*)this;
145 }
146
147
148 template<class T, class S, cint64 bucket2Size>
149 cint64 CDoubleDynamicReferenceVectorBase<T,S,bucket2Size>::getItemCount() {
150 return mFirstVector.getItemCount()+mSecondVector.getItemCount();
151 }
152
153 template<class T, class S, cint64 bucket2Size>
154 cint64 CDoubleDynamicReferenceVectorBase<T,S,bucket2Size>::getItemMaxIndex() {
155 return mSecondVector.getItemMaxIndex();
156 }
157
158 template<class T, class S, cint64 bucket2Size>
159 cint64 CDoubleDynamicReferenceVectorBase<T,S,bucket2Size>::getItemMinIndex() {
160 return -mFirstVector.getItemMaxIndex();
161 }
162
163 template<class T, class S, cint64 bucket2Size>
164 cint64 CDoubleDynamicReferenceVectorBase<T,S,bucket2Size>::getReferencedItemCount() {
165 return mFirstVector.getReferencedItemCount()+mSecondVector.getReferencedItemCount();
166 }
167
168 template<class T, class S, cint64 bucket2Size>
169 cint64 CDoubleDynamicReferenceVectorBase<T,S,bucket2Size>::getReferencedItemMaxIndex() {
170 return mSecondVector.getItemCount();
171 }
172
173 template<class T, class S, cint64 bucket2Size>
174 cint64 CDoubleDynamicReferenceVectorBase<T,S,bucket2Size>::getReferencedItemMinIndex() {
175 return -mFirstVector.getItemCount();
176 }
177
178 }; // end namespace Container
179
180 }; // end namespace Utilities
181
182 }; // end namespace Konclude
183
184 #endif // KONCLUDE_UTILITIES_CONTAINER_CDOUBLEDYNAMICREFERENCEVECTOR_CPP