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 Simple demonstration and test application for the CompactListList class.
30 \*---------------------------------------------------------------------------*/
32 #include "CompactListList.H"
33 #include "IOstreams.H"
34 #include "OStringStream.H"
35 #include "IStringStream.H"
40 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 int main(int argc, char *argv[])
47 CompactListList<label> cll1;
48 Info<< "cll1:" << cll1 << endl;
50 // Resize and assign row by row
54 labelList rowSizes(2);
55 rowSizes[0] = row0.size();
56 rowSizes[1] = row1.size();
57 cll1.resize(rowSizes);
59 cll1[0].assign(row0); //note: operator= will not work since UList
61 Info<< "cll1:" << cll1 << endl;
65 Info<< "i:" << i << " whichRow:" << cll1.whichRow(i) << endl;
69 List<List<label> > lll(5);
76 CompactListList<label> cll2(lll);
78 Info<< "cll2 = " << cll2 << endl;
82 Info<< cll2[i] << endl;
87 Info<< "cll2(2, 3) = " << cll2(2, 3) << nl << endl;
89 Info<< "cll2(2, 3) = " << cll2(2, 3) << nl << endl;
91 Info<< "cll2 as List<List<label > > " << cll2()
96 Info<< "cll2 = " << cll2 << endl;
100 Info<< "cll2 = " << cll2 << endl;
103 List<label> rowSizes(5);
110 CompactListList<label> cll3(rowSizes, 1);
112 Info<< "cll3 = " << cll3 << endl;
114 CompactListList<label> cll4;
118 Info<< "cll3 = " << cll3 << endl;
119 Info<< "cll4 = " << cll4 << endl;
127 IStringStream istr(ostr.str());
128 CompactListList<label> cll5(istr);
129 Info<< "cll5 = " << cll5 << endl;
137 IStringStream istr(ostr.str());
138 CompactListList<label> cll5(istr);
139 Info<< "cll5 = " << cll5 << endl;
144 fcs[0] = face(labelList(1, 111));
145 fcs[1] = face(labelList(2, 222));
147 CompactListList<label, face> compactFcs(fcs);
148 Info<< "comactFcs:" << compactFcs << endl;
150 faceList fcs2 = compactFcs();
151 Info<< "fcs2:" << fcs2 << endl;
158 // ************************************************************************* //