1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by
13 the Free Software Foundation, either version 3 of the License, or
14 (at your option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
28 \*---------------------------------------------------------------------------*/
31 #include "IOstreams.H"
32 #include "PackedBoolList.H"
33 #include "IStringStream.H"
37 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
40 int main(int argc, char *argv[])
42 PackedBoolList list1(20);
43 // set every third one on
49 Info<< "\nalternating bit pattern\n";
50 list1.printInfo(Info, true);
52 PackedBoolList list2 = ~list1;
54 Info<< "\ncomplementary bit pattern\n";
55 list2.printBits(Info);
63 Info<< "\nalternating bit pattern\n";
64 list2.printBits(Info);
66 list2.resize(28, false);
67 list2.resize(34, true);
68 list2.resize(40, false);
69 for (label i=0; i < 4; ++i)
74 Info<< "\nresized with false, 6 true + 6 false, bottom 4 bits true\n";
75 list2.printInfo(Info, true);
77 labelList list2Labels = list2.used();
79 Info<< "\noperator|\n";
81 list1.printBits(Info);
82 list2.printBits(Info);
84 (list1 | list2).printBits(Info);
86 Info<< "\noperator& : does trim\n";
87 (list1 & list2).printBits(Info);
89 Info<< "\noperator^\n";
90 (list1 ^ list2).printBits(Info);
93 Info<< "\noperator|=\n";
95 PackedBoolList list3 = list1;
96 (list3 |= list2).printBits(Info);
99 Info<< "\noperator|= with labelUList\n";
101 PackedBoolList list3 = list1;
102 (list3 |= list2Labels).printBits(Info);
105 Info<< "\noperator&=\n";
107 PackedBoolList list3 = list1;
108 (list3 &= list2).printBits(Info);
111 Info<< "\noperator+=\n";
113 PackedBoolList list3 = list1;
114 (list3 += list2).printBits(Info);
117 Info<< "\noperator+= with labelUList\n";
119 PackedBoolList list3 = list1;
120 (list3 += list2Labels).printBits(Info);
123 Info<< "\noperator-=\n";
125 PackedBoolList list3 = list1;
126 (list3 -= list2).printBits(Info);
129 Info<< "\noperator-= with labelUList\n";
131 PackedBoolList list3 = list1;
132 (list3 -= list2Labels).printBits(Info);
139 "(1 n 1 n 1 n 1 1 off 0 0 f f 0 y yes y true y false on t)"
143 Info<< "\ntest Istream constructor\n";
145 list4.printInfo(Info, true);
146 Info<< list4 << " indices: " << list4.used()() <<endl;
148 Info<< "\nassign from labelList\n";
153 "(0 1 2 3 12 13 14 19 20 21)"
157 list4.printInfo(Info, true);
158 Info<< list4 << " indices: " << list4.used()() <<endl;
160 Info<< "\nassign from indices\n";
165 "{0 1 2 3 12 13 14 19 20 21}"
170 list4.printInfo(Info, true);
171 Info<< list4 << " indices: " << list4.used()() <<endl;
173 List<bool> boolLst(list4.size());
176 boolLst[i] = list4[i];
179 Info<< "List<bool>: " << boolLst <<endl;
182 // check roundabout assignments
187 "{(0 3)(1 3)(2 3)(3 3)(12 3)(13 3)(14 3)(19 3)(20 3)(21 3)}"
191 Info<< "roundabout assignment: " << pl2 << endl;
199 list4.write(Info, true) << endl;
201 list4.writeEntry("PackedBoolList", Info);
207 // ************************************************************************* //