0024157: Parallelization of assembly part of BO
[occt.git] / src / QANCollection / QANCollection_FuncMaps.hxx
CommitLineData
b311480e 1// Created on: 2002-04-30
2// Created by: Alexander KARTOMIN (akm)
3// Copyright (c) 2002-2012 OPEN CASCADE SAS
4//
5// The content of this file is subject to the Open CASCADE Technology Public
6// License Version 6.5 (the "License"). You may not use the content of this file
7// except in compliance with the License. Please obtain a copy of the License
8// at http://www.opencascade.org and read it completely before using this file.
9//
10// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
11// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
12//
13// The Original Code and all software distributed under the License is
14// distributed on an "AS IS" basis, without warranty of any kind, and the
15// Initial Developer hereby disclaims all such warranties, including without
16// limitation, any warranties of merchantability, fitness for a particular
17// purpose or non-infringement. Please see the License for the specific terms
18// and conditions governing the rights and limitations under the License.
19
7fd59977 20
21
22#ifndef QANCollection_FuncMaps_HeaderFile
23#define QANCollection_FuncMaps_HeaderFile
24
25// ===================== Test methods of Map type =============================
26////////////////////////////////void TestMap (QANCollection_Map& theM)
27void TestMap (QANCollection_MapFunc& theM)
28{
29 // Extent
30 Standard_Integer iExt=theM.Extent();
31 Standard_Integer i;
32
33 printf ("Info: testing Map(l=%d)\n", iExt);
34 theM.Statistics(cout);
35 // Resize
36 theM.ReSize(8);
37 theM.Statistics(cout);
38 cout.flush();
39 // Constructor
40 ////////////////////////////////QANCollection_Map aM;
41 QANCollection_MapFunc aM;
42 // Add
43 Key1Type aKey;
44 for (i=0; i<8; i++)
45 {
46 Random (aKey);
47 aM.Add (aKey);
48 }
49 // Contains, Remove
50 if (!aM.Contains(aKey))
51 {
52 printf("Error : map says that it does not contain its key ");
53 PrintItem(aKey);
54 }
55 else
56 {
57 aM.Remove(aKey);
58 printf(" successfully removed item, l=%d\n", aM.Size());
59 }
60 // Copy constructor (including operator=)
61 ////////////////////////////////QANCollection_Map aM2 = QANCollection_Map(aM);
62 QANCollection_MapFunc aM2 = QANCollection_MapFunc(aM);
63 // Assign
64 AssignCollection (aM2,theM);
65
66 // Clear
67 aM.Clear();
68}
69
70// ===================== Test methods of DataMap type =========================
71////////////////////////////////void TestDataMap (QANCollection_DataMap& theM)
72void TestDataMap (QANCollection_DataMapFunc& theM)
73{
74 // Extent
75 Standard_Integer iExt=theM.Extent();
76 Standard_Integer i;
77
78 printf ("Info: testing DataMap(l=%d)\n", iExt);
79 theM.Statistics(cout);
80 // Resize
81 theM.ReSize(8);
82 theM.Statistics(cout);
83 cout.flush();
84 // Constructor
85 ////////////////////////////////QANCollection_DataMap aM;
86 QANCollection_DataMapFunc aM;
87 // Bind, Find, ChangeFind, ()
88 Key1Type aKey;
89 ItemType anItem;
90 for (i=0; i<8; i++)
91 {
92 Random (aKey);
93 Random (anItem);
94 aM.Bind (aKey, anItem);
95 PrintItem(aM.Find(aKey));
96 Random(aM(aKey));
97 }
98 // IsBound, UnBind
99 if (!aM.IsBound(aKey))
100 {
101 printf("Error : map says that it does not contain its key ");
102 PrintItem(aKey);
103 }
104 else
105 {
106 aM.UnBind(aKey);
107 printf(" successfully unbound the key, l=%d\n", aM.Size());
108 }
109 // Copy constructor (including operator=)
110 ////////////////////////////////theM = QANCollection_DataMap(aM);
111 theM = QANCollection_DataMapFunc(aM);
112 // Assign - prohibited
113 // AssignCollection (aM2,theM);
114 printCollection (theM, "DataMap:");
115
116 // Clear
117 aM.Clear();
118}
119
120
121// ===================== Test methods of DoubleMap type =======================
122////////////////////////////////void TestDoubleMap (QANCollection_DoubleMap& theM)
123void TestDoubleMap (QANCollection_DoubleMapFunc& theM)
124{
125 // Extent
126 Standard_Integer iExt=theM.Extent();
127 Standard_Integer i;
128
129 printf ("Info: testing DoubleMap(l=%d)\n", iExt);
130 theM.Statistics(cout);
131 // Resize
132 theM.ReSize(8);
133 theM.Statistics(cout);
134 cout.flush();
135 // Constructor
136 ////////////////////////////////QANCollection_DoubleMap aM;
137 QANCollection_DoubleMapFunc aM;
138 // Bind, Find?,
139 Key1Type aKey1;
140 Key2Type aKey2;
141 for (i=0; i<8; i++)
142 {
143 Random (aKey1);
144 Random (aKey2);
145 aM.Bind (aKey1, aKey2);
146 PrintItem(aM.Find1(aKey1));
147 if (!aM.IsBound1(aKey1))
148 {
149 printf("Error : map says that it does not contain its key ");
150 PrintItem(aKey1);
151 }
152 PrintItem(aM.Find2(aKey2));
153 if (!aM.IsBound2(aKey2))
154 {
155 printf("Error : map says that it does not contain its key ");
156 PrintItem(aKey2);
157 }
158 }
159 // AreBound, UnBind
160 if (!aM.AreBound(aKey1,aKey2))
161 {
162 printf("Error : map says that it does not contain its keys ");
163 PrintItem(aKey1);
164 PrintItem(aKey2);
165 }
166 else
167 {
168 if (aM.UnBind2(aKey2))
169 printf(" successfully unbound the key, l=%d\n", aM.Size());
170 if (aM.UnBind1(aKey1))
171 printf("Error : unbound both keys?!\n");
172 }
173 // Copy constructor (including operator=)
174 ////////////////////////////////theM = QANCollection_DoubleMap(aM);
175 theM = QANCollection_DoubleMapFunc(aM);
176 // Assign - prohibited
177 // AssignCollection (aM2,theM);
178 printCollection (theM, "DoubleMap:");
179
180 // Clear
181 aM.Clear();
182}
183
184// ===================== Test methods of IndexedMap type ======================
185////////////////////////////////void TestIndexedMap (QANCollection_IndexedMap& theM)
186void TestIndexedMap (QANCollection_IndexedMapFunc& theM)
187{
188 // Extent
189 Standard_Integer iExt=theM.Extent();
190 Standard_Integer i;
191
192 printf ("Info: testing IndexedMap(l=%d)\n", iExt);
193 theM.Statistics(cout);
194 // Resize
195 theM.ReSize(8);
196 theM.Statistics(cout);
197 cout.flush();
198 // Constructor
199 ////////////////////////////////QANCollection_IndexedMap aM;
200 QANCollection_IndexedMapFunc aM;
201 // Add, FindKey, FindIndex
202 Key1Type aKey;
203 for (i=0; i<8; i++)
204 {
205 Random (aKey);
206 aM.Add (aKey);
207 Standard_Integer iIndex=aM.FindIndex(aKey);
208 printf (" added a key, i=%d, k=",iIndex);
209 PrintItem(aM(iIndex));
210 }
211 // Contains, Remove
212 if (!aM.Contains(aM.FindKey(aM.FindIndex(aKey))))
213 {
214 printf("Error : map says that it does not contain its key ");
215 PrintItem(aKey);
216 }
217 else
218 {
219 aM.RemoveLast();
220 printf(" successfully removed item, l=%d\n", aM.Size());
221 }
222 // Substitute
223 Random(aKey);
224 aM.Substitute(1,aKey);
225 // Copy constructor (including operator=)
226 ////////////////////////////////QANCollection_IndexedMap aM2 = QANCollection_IndexedMap(aM);
227 QANCollection_IndexedMapFunc aM2 = QANCollection_IndexedMapFunc(aM);
228 // Assign
229 AssignCollection (aM2,theM);
230
231 // Clear
232 aM.Clear();
233}
234
235// ===================== Test methods of IndexedDataMap type ==================
236////////////////////////////////void TestIndexedDataMap (QANCollection_IDMap& theM)
237void TestIndexedDataMap (QANCollection_IDMapFunc& theM)
238{
239 // Extent
240 Standard_Integer iExt=theM.Extent();
241 Standard_Integer i;
242
243 printf ("Info: testing IndexedDataMap(l=%d)\n", iExt);
244 theM.Statistics(cout);
245 // Resize
246 theM.ReSize(8);
247 theM.Statistics(cout);
248 cout.flush();
249 // Constructor
250 ////////////////////////////////QANCollection_IDMap aM;
251 QANCollection_IDMapFunc aM;
252 // Add, FindKey, FindIndex, FindFromIndex, Change..., ()
253 Key1Type aKey;
254 ItemType anItem;
255 for (i=0; i<8; i++)
256 {
257 Random (aKey);
258 Random (anItem);
259 aM.Add (aKey, anItem);
260 Standard_Integer iIndex=aM.FindIndex(aKey);
261 printf (" added a key, i=%d, k=",iIndex);
262 PrintItem(aM.FindKey(iIndex));
263 PrintItem(aM(iIndex));
264 Random(aM.ChangeFromIndex(iIndex));
265 }
266 // Contains, Remove, FindFromKey
267 if (!aM.Contains(aM.FindKey(aM.FindIndex(aKey))))
268 {
269 printf("Error : map says that it does not contain its key ");
270 PrintItem(aKey);
271 }
272 else
273 {
274 anItem = aM.FindFromKey(aKey);
275 aM.RemoveLast();
276 printf(" successfully removed item, l=%d\n", aM.Size());
277 }
278 // Substitute
279 Random(aKey);
280 aM.Substitute (1, aKey, anItem);
281 // Copy constructor (including operator=)
282 ////////////////////////////////theM = QANCollection_IDMap(aM);
283 theM = QANCollection_IDMapFunc(aM);
284 // Assign - prohibited
285 // AssignCollection (aM2,theM);
286 printCollection (theM, "DoubleMap:");
287
288 // Clear
289 aM.Clear();
290}
291
292
293#endif