1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2010-2011 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 A wordList with hashed indices for faster lookup by name.
34 \*---------------------------------------------------------------------------*/
36 #ifndef hashedWordList_H
37 #define hashedWordList_H
40 #include "HashTable.H"
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 // Forward declaration of friend functions and operators
50 Istream& operator>>(Istream&, hashedWordList&);
51 Ostream& operator<<(Ostream&, const hashedWordList&);
54 /*---------------------------------------------------------------------------*\
55 Class hashedWordList Declaration
56 \*---------------------------------------------------------------------------*/
64 HashTable<label, word> indices_;
67 // Private Member Functions
69 //- rebuild the hash of indices
80 hashedWordList(const hashedWordList&);
82 //- Construct from list of names
83 hashedWordList(const UList<word>& names);
85 //- Construct by transferring the parameter contents
86 hashedWordList(const Xfer< List<word> >& names);
88 //- Construct from number and list of names
89 hashedWordList(const label nNames, const char** names);
91 //- Construct from a NULL-terminated list of names
92 hashedWordList(const char** names);
94 //- Construct from Istream
95 hashedWordList(Istream&);
100 //- Clear the list, i.e. set size to zero.
103 //- Append an element at the end of the list
104 void append(const word&);
106 //- Does the list contain the specified name
107 inline bool contains(const word&) const;
109 //- Transfer the contents of the argument List into this list
110 // and annul the argument list.
111 void transfer(List<word>&);
116 //- Assignment operator from list of names
117 inline void operator=(const UList<word>& names);
119 //- Assignment operator.
120 inline void operator=(const hashedWordList&);
122 //- Return name corresponding to specified index
123 inline const word& operator[](const label index) const;
125 //- Return index corresponding to specified name
126 inline label operator[](const word&) const;
131 friend Istream& operator>>(Istream&, hashedWordList&);
132 friend Ostream& operator<<(Ostream&, const hashedWordList&);
136 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
138 } // End namespace Foam
140 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
142 #include "hashedWordListI.H"
146 // ************************************************************************* //