diff --git a/applications/test/PackedList1/PackedListTest1.C b/applications/test/PackedList1/PackedListTest1.C index 4ee366854b..5e1902f382 100644 --- a/applications/test/PackedList1/PackedListTest1.C +++ b/applications/test/PackedList1/PackedListTest1.C @@ -329,23 +329,42 @@ int main(int argc, char *argv[]) list3.print(Info); - List list4(4, true); + List list4(16, false); { - const List& constLst = list4; + // fill with some values + forAll(list4, i) + { + list4[i] = i % 3; + } + + const UList& constLst = list4; Info<< "\ntest operator[] const with out-of-range index\n"; Info<< constLst << endl; - if (constLst[20]) + if (constLst[100]) { - Info<< "[20] is true (unexpected)\n"; + Info<< "[100] is true (unexpected)\n"; } else { - Info<< "[20] is false (expected) list size should be unchanged " - << "(const)\n"; + Info<< "[100] is false (expected) " + << "list size should be unchanged (const)\n"; } Info<< constLst << endl; } + + PackedBoolList listb(list4); + + Info<< "copied from bool list " << endl; + listb.print(Info, true); + + { + labelList indices = listb.used(); + + Info<< "indices: " << indices << endl; + } + + Info<< "\n\nDone.\n"; return 0; diff --git a/applications/test/PackedList4/Make/files b/applications/test/PackedList4/Make/files new file mode 100644 index 0000000000..0704f9b826 --- /dev/null +++ b/applications/test/PackedList4/Make/files @@ -0,0 +1,3 @@ +PackedListTest4.C + +EXE = $(FOAM_USER_APPBIN)/PackedListTest4 diff --git a/applications/test/PackedList4/Make/options b/applications/test/PackedList4/Make/options new file mode 100644 index 0000000000..e69de29bb2 diff --git a/applications/test/PackedList4/PackedListTest4.C b/applications/test/PackedList4/PackedListTest4.C new file mode 100644 index 0000000000..7271a3f1dd --- /dev/null +++ b/applications/test/PackedList4/PackedListTest4.C @@ -0,0 +1,124 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Application + +Description + +\*---------------------------------------------------------------------------*/ + +#include "uLabel.H" +#include "IOstreams.H" +#include "PackedBoolList.H" + +using namespace Foam; + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// Main program: + +int main(int argc, char *argv[]) +{ + PackedBoolList list1(20); + // set every other one on + forAll(list1, i) + { + list1[i] = i % 2; + } + + Info<< "\nalternative bit pattern\n"; + list1.print(Info, true); + + PackedBoolList list2 = ~list1; + + Info<< "\ncomplementary bit pattern\n"; + list2.print(Info, true); + + list2.resize(24, true); + list2.resize(28, false); + for (label i=0; i < 4; ++i) + { + list2[i] = true; + } + + Info<< "\nresized with 4 true + 4 false, bottom 4 bits true\n"; + list2.print(Info, true); + + labelList list2Labels = list2.used(); + + Info<< "\noperator|\n"; + (list1 | list2).print(Info, true); + + Info<< "\noperator& : does trim\n"; + (list1 & list2).print(Info, true); + + Info<< "\noperator^\n"; + (list1 ^ list2).print(Info, true); + + + Info<< "\noperator|=\n"; + { + PackedBoolList list3 = list1; + (list3 |= list2).print(Info, true); + } + + Info<< "\noperator|= with UList