OpenFOAM
5.0
The OpenFOAM Foundation
Main Page
Related Pages
Modules
+
Namespaces
Namespace List
+
Namespace Members
+
All
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
+
Functions
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
+
Variables
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
w
z
+
Typedefs
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
Enumerations
Enumerator
+
Classes
Class List
Class Index
Class Hierarchy
+
Class Members
+
All
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
+
Functions
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
+
Variables
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
+
Typedefs
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
v
w
+
Enumerations
a
b
c
d
e
f
g
i
k
l
m
o
p
r
s
t
v
w
+
Enumerator
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
+
Related Functions
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
+
Files
File List
+
File Members
+
All
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
+
Functions
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
+
Variables
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
+
Typedefs
b
c
d
f
g
k
l
m
p
r
s
t
v
w
+
Macros
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
r
s
t
u
v
w
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Modules
Pages
src
OpenFOAM
containers
HashTables
HashPtrTable
HashPtrTable.C
Go to the documentation of this file.
1
/*---------------------------------------------------------------------------*\
2
========= |
3
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4
\\ / O peration |
5
\\ / A nd | Copyright (C) 2011-2016 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 "
error.H
"
27
#include "
HashPtrTable.H
"
28
29
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
30
31
template
<
class
T,
class
Key,
class
Hash>
32
Foam::HashPtrTable<T, Key, Hash>::HashPtrTable
(
const
label
size)
33
:
34
HashTable
<
T
*, Key,
Hash
>(size)
35
{}
36
37
38
template
<
class
T,
class
Key,
class
Hash>
39
Foam::HashPtrTable<T, Key, Hash>::HashPtrTable
40
(
41
const
HashPtrTable<T, Key, Hash>
& ht
42
)
43
:
44
HashTable<T*, Key, Hash>
()
45
{
46
for
(
const_iterator
iter = ht.
begin
(); iter != ht.
end
(); ++iter)
47
{
48
this->
insert
(iter.key(),
new
T
(**iter));
49
}
50
}
51
52
53
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
54
55
template
<
class
T,
class
Key,
class
Hash>
56
Foam::HashPtrTable<T, Key, Hash>::~HashPtrTable
()
57
{
58
clear
();
59
}
60
61
62
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
63
64
template
<
class
T,
class
Key,
class
Hash>
65
T
*
Foam::HashPtrTable<T, Key, Hash>::remove
(
iterator
& it)
66
{
67
T
* elemPtr = *it;
68
HashTable<T*, Key, Hash>::erase
(it);
69
return
elemPtr;
70
}
71
72
73
template
<
class
T,
class
Key,
class
Hash>
74
bool
Foam::HashPtrTable<T, Key, Hash>::erase
(
iterator
& it)
75
{
76
T
* elemPtr = *it;
77
78
if
(
HashTable<T*, Key, Hash>::erase
(it))
79
{
80
if
(elemPtr)
81
{
82
delete
elemPtr;
83
}
84
85
return
true
;
86
}
87
else
88
{
89
return
false
;
90
}
91
}
92
93
94
template
<
class
T,
class
Key,
class
Hash>
95
void
Foam::HashPtrTable<T, Key, Hash>::clear
()
96
{
97
for
98
(
99
iterator
iter = this->begin();
100
iter != this->end();
101
++iter
102
)
103
{
104
delete
*iter;
105
}
106
107
HashTable<T*, Key, Hash>::clear
();
108
}
109
110
111
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
112
113
template
<
class
T,
class
Key,
class
Hash>
114
void
Foam::HashPtrTable<T, Key, Hash>::operator=
115
(
116
const
HashPtrTable<T, Key, Hash>
& rhs
117
)
118
{
119
// Check for assignment to self
120
if
(
this
== &rhs)
121
{
122
FatalErrorInFunction
123
<<
"attempted assignment to self"
124
<<
abort
(
FatalError
);
125
}
126
127
this->
clear
();
128
129
for
(
const_iterator
iter = rhs.begin(); iter != rhs.end(); ++iter)
130
{
131
this->
insert
(iter.key(),
new
T
(**iter));
132
}
133
}
134
135
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
136
137
#include "
HashPtrTableIO.C
"
138
139
// ************************************************************************* //
Foam::HashPtrTable::~HashPtrTable
~HashPtrTable()
Destructor.
Definition:
HashPtrTable.C:56
Foam::label
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
Foam::HashPtrTable::HashPtrTable
HashPtrTable(const label size=128)
Construct given initial table size.
Definition:
HashPtrTable.C:32
Foam::HashTable::const_iterator
An STL-conforming const_iterator.
Definition:
HashTable.H:481
Foam::HashTableCore::end
static iteratorEnd end()
iteratorEnd set to beyond the end of any HashTable
Definition:
HashTable.H:110
erase
srcOptions erase("case")
Foam::FatalError
error FatalError
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition:
error.H:319
clear
tUEqn clear()
error.H
Foam::HashPtrTable
A HashTable specialization for hashing pointers.
Definition:
HashPtrTable.H:50
Foam::HashPtrTable::clear
void clear()
Clear all entries from table.
Definition:
HashPtrTable.C:95
Foam::HashTable::iterator
An STL-conforming iterator.
Definition:
HashTable.H:426
insert
timeIndices insert(timeIndex, timeDirs[timeI].value())
Foam::HashTable< T *, Key, Hash >::begin
iterator begin()
Iterator set to the beginning of the HashTable.
Definition:
HashTableI.H:419
Foam::HashTable
An STL-conforming hash table.
Definition:
HashTable.H:62
Foam::abort
errorManip< error > abort(error &err)
Definition:
errorManip.H:131
HashPtrTableIO.C
T
const volScalarField & T
Definition:
createFieldRefs.H:2
Foam::Hash
Hash function class for primitives. All non-primitives used to hash entries on hash tables likely nee...
Definition:
Hash.H:54
Foam::HashPtrTable::remove
T * remove(iterator &)
Remove and return the pointer specified by given iterator.
Definition:
HashPtrTable.C:65
Foam::HashPtrTable::erase
bool erase(iterator &)
Erase an hashedEntry specified by given iterator.
Definition:
HashPtrTable.C:74
HashPtrTable.H
Generated by
1.8.13