UPtrListDictionary.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2023 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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
19  for more details.
20 
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/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "UPtrListDictionary.H"
27 #include "PtrListDictionary.H"
28 
29 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
30 
31 template<class T>
33 :
34  DictionaryBase<UPtrList<T>, T>(2*size)
35 {
37 }
38 
39 
40 template<class T>
42 :
44 {}
45 
46 
47 template<class T>
49 (
51 )
52 :
54 {
57 }
58 
59 
60 template<class T>
62 :
63  DictionaryBase<UPtrList<T>, T>(move(dict))
64 {}
65 
66 
67 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
68 
69 template<class T>
70 inline bool Foam::UPtrListDictionary<T>::set(const label i) const
71 {
72  return UPtrList<T>::set(i);
73 }
74 
75 
76 template<class T>
78 (
79  const label i,
80  const word& key,
81  T* ptr
82 )
83 {
84  if (!DictionaryBase<UPtrList<T>, T>::hashedTs_.insert(key, ptr))
85  {
87  << "Cannot insert with key '" << key << "' into hash-table"
88  << abort(FatalError);
89  }
90  return UPtrList<T>::set(i, ptr);
91 }
92 
93 
94 // ************************************************************************* //
Base dictionary class templated on both the form of doubly-linked list it uses as well as the type it...
HashTable< T * > hashedTs_
HashTable of the entries held on the IDLListType for quick lookup.
Template dictionary class which manages the storage associated with it.
Template dictionary class which manages the storage associated with it.
bool set(const label) const
Is element set.
UPtrListDictionary(const label size)
Construct given initial list size.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: UPtrList.H:66
bool set(const label) const
Is element set.
Definition: UPtrListI.H:87
label size() const
Return the number of elements in the UPtrList.
Definition: UPtrListI.H:29
void setSize(const label)
Reset size of UPtrList. This can only be used to set the size.
Definition: UPtrList.C:54
A class for handling words, derived from string.
Definition: word.H:62
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:334
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
errorManip< error > abort(error &err)
Definition: errorManip.H:131
error FatalError
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
dictionary dict