1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2010 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
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 \*---------------------------------------------------------------------------*/
30 #include "OSspecific.H"
33 #include "IOstreams.H"
56 Info <<"delete Scalar: " << data_ << endl;
59 autoPtr<Scalar> clone() const;
61 friend Ostream& operator<<(Ostream& os, const Scalar& val)
69 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
72 int main(int argc, char *argv[])
74 PtrList<Scalar> list1(10);
75 PtrList<Scalar> list2(15);
79 list1.set(i, new Scalar(1.3*i));
84 list2.set(i, new Scalar(10 + 1.3*i));
88 Info<<"list1: " << list1 << endl;
89 Info<<"list2: " << list2 << endl;
91 Info<<"indirectly delete some items via set(.., 0) :" << endl;
92 for (label i = 0; i < 3; i++)
97 Info<<"transfer list2 -> list1:" << endl;
98 list1.transfer(list2);
100 Info<<"list1: " << list1 << endl;
101 Info<<"list2: " << list2 << endl;
103 Info<<"indirectly delete some items via setSize :" << endl;
106 Info<<"list1: " << list1 << endl;
108 PtrList<Scalar> list3(list1.xfer());
109 Info<< "Transferred via the xfer() method" << endl;
111 Info<<"list1: " << list1 << endl;
112 Info<<"list2: " << list2 << endl;
113 Info<<"list3: " << list3 << endl;
115 Info<< nl << "Done." << endl;
120 // ************************************************************************* //