1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 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, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 \*---------------------------------------------------------------------------*/
31 #include "OSspecific.H"
34 #include "IOstreams.H"
57 Info <<"delete Scalar: " << data_ << endl;
60 friend Ostream& operator<<(Ostream& os, const Scalar& val)
68 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
71 int main(int argc, char *argv[])
73 PtrList<Scalar> list1(10);
74 PtrList<Scalar> list2(15);
78 list1.set(i, new Scalar(1.3*i));
83 list2.set(i, new Scalar(10 + 1.3*i));
87 Info<<"list1: " << list1 << endl;
88 Info<<"list2: " << list2 << endl;
90 Info<<"indirectly delete some items via set(.., 0) :" << endl;
91 for (label i = 0; i < 3; i++)
96 Info<<"transfer list2 -> list1:" << endl;
97 list1.transfer(list2);
99 Info<<"list1: " << list1 << endl;
100 Info<<"list2: " << list2 << endl;
102 Info<<"indirectly delete some items via setSize :" << endl;
105 Info<<"list1: " << list1 << endl;
107 PtrList<Scalar> list3(list1.xfer());
108 Info<< "Transferred via the xfer() method" << endl;
110 Info<<"list1: " << list1 << endl;
111 Info<<"list2: " << list2 << endl;
112 Info<<"list3: " << list3 << endl;
114 Info<< nl << "Done." << endl;
119 // ************************************************************************* //