1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2008 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"
33 #include "IOstreams.H"
34 #include "Dictionary.H"
40 public Dictionary<ent>::link
47 ent(const word& keyword, int i)
53 const word& keyword() const
58 friend Ostream& operator<<(Ostream& os, const ent& e)
60 os << e.keyword_ << ' ' << e.i_ << endl;
66 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
69 int main(int argc, char *argv[])
71 Dictionary<ent>* dictPtr = new Dictionary<ent>;
72 Dictionary<ent>& dict = *dictPtr;
74 for (int i = 0; i<10; i++)
76 ent* ePtr = new ent(word("ent") + name(i), i);
77 dict.append(ePtr->keyword(), ePtr);
83 dict.swapDown(dict.first());
87 Dictionary<ent>::const_iterator iter = dict.begin();
92 Info<< "element : " << *iter;
95 Info<< dict.toc() << endl;
99 dictPtr = new Dictionary<ent>;
100 Dictionary<ent>& dict2 = *dictPtr;
102 for (int i = 0; i<10; i++)
104 ent* ePtr = new ent(word("ent") + name(i), i);
105 dict2.append(ePtr->keyword(), ePtr);
109 Info<< dict2 << endl;
111 Info<< nl << "Bye." << endl;
116 // ************************************************************************* //