0024742: Remove rarely used collection classes: Set
[occt.git] / src / QANCollection / QANCollection_FuncArrays.hxx
CommitLineData
b311480e 1// Created on: 2002-04-30
2// Created by: Alexander KARTOMIN (akm)
973c2be1 3// Copyright (c) 2002-2014 OPEN CASCADE SAS
b311480e 4//
973c2be1 5// This file is part of Open CASCADE Technology software library.
b311480e 6//
d5f74e42 7// This library is free software; you can redistribute it and/or modify it under
8// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 9// by the Free Software Foundation, with special exception defined in the file
10// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11// distribution for complete text of the license and disclaimer of any warranty.
b311480e 12//
973c2be1 13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
7fd59977 15
16#ifndef QANCollection_FuncArrays_HeaderFile
17#define QANCollection_FuncArrays_HeaderFile
18
19// ===================== Test methods of Array1 type ==========================
20////////////////////////////////void TestArray1 (QANCollection_Array1& theA1)
21void TestArray1 (QANCollection_Array1Func& theA1)
22{
23 // Bounds
24 Standard_Integer iLow=theA1.Lower();
25 Standard_Integer iUpp=theA1.Upper();
26 Standard_Integer i;
27
28 printf ("Info: testing Array1(%d,%d), %s\n",
29 iLow, iUpp, (theA1.IsDeletable()?"deletable":"frozen"));
30 // C-array constructor, Length, Init
31 ItemType anItem;
32 Random(anItem);
33 theA1.Init (anItem);
34 ItemType * rBlock = new ItemType[theA1.Length()];
35 ////////////////////////////////QANCollection_Array1 aCArr(*rBlock, iLow-100, iUpp-100);
36 QANCollection_Array1Func aCArr(*rBlock, iLow-100, iUpp-100);
37 printf (" created the same sized preallocated array (%d,%d), %s\n",
38 aCArr.Lower(),aCArr.Upper(),(aCArr.IsDeletable()?"deletable":"frozen"));
39 // *Value, operator()
40 for (i=iLow+1; i<iUpp; i++)
41 {
42 Random (aCArr.ChangeValue (i-101));
43 aCArr.SetValue (i-100, ItemType(aCArr.Value(i-101)));
44 aCArr(i-99) = aCArr(i-100) = aCArr(i-101);
45 }
46 // Handle, copy constructor (including operator=)
47 ////////////////////////////////Handle(QANCollection_HArray1) aHa = new QANCollection_HArray1(aCArr);
48 Handle(QANCollection_HArray1Func) aHa = new QANCollection_HArray1Func(aCArr);
49 // Assign
50 AssignCollection (aHa->ChangeArray1(), theA1);
51}
52
53// ===================== Test methods of Array2 type ==========================
54////////////////////////////////void TestArray2 (QANCollection_Array2& theA2)
55void TestArray2 (QANCollection_Array2Func& theA2)
56{
57 // Bounds
58 Standard_Integer iLR=theA2.LowerRow(), iLC=theA2.LowerCol();
59 Standard_Integer iUR=theA2.UpperRow(), iUC=theA2.UpperCol();
60 Standard_Integer i,j;
61
62 printf ("Info: testing Array2 (%d,%d)(%d,%d), %s\n",
63 iLR, iUR, iLC, iUC, (theA2.IsDeletable()?"deletable":"frozen"));
64 // C-array constructor, Length, Init, RowLength, ColLength
65 ItemType anItem;
66 Random(anItem);
67 theA2.Init (anItem);
68 ItemType * rBlock = new ItemType[theA2.Length()];
69 ////////////////////////////////QANCollection_Array2 aCArr(*rBlock, iLR-100, iUR-100, iLC, iUC);
70 QANCollection_Array2Func aCArr(*rBlock, iLR-100, iUR-100, iLC, iUC);
71 printf (" created the same sized preallocated array (%d*%d), %s\n",
72 aCArr.RowLength(), aCArr.ColLength(),
73 (aCArr.IsDeletable()?"deletable":"frozen"));
74 // *Value, operator()
75 for (i=iLR+1; i<iUR; i++)
76 {
77 for (j=iLC; j<=iUC; j++)
78 {
79 Random (aCArr.ChangeValue (i-101, j));
80 aCArr.SetValue (i-100, j,
81 ItemType(aCArr.Value(i-101,j)));
82 aCArr(i-99,j) = aCArr(i-100,j) = aCArr(i-101,j);
83 }
84 }
85 // Handle, copy constructor (including operator=)
86 ////////////////////////////////Handle(QANCollection_HArray2) aHa = new QANCollection_HArray2(aCArr);
87 Handle(QANCollection_HArray2Func) aHa = new QANCollection_HArray2Func(aCArr);
88 // Assign
89 AssignCollection (aHa->ChangeArray2(), theA2);
90}
91
92#endif