HashTableCoreI.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2017-2019 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 // * * * * * * * * * * * * * * * helper methods * * * * * * * * * * * * * * //
29 
30 template<class IteratorType, class TableType>
31 inline IteratorType Foam::HashTableCore::iterator_begin
32 (
33  TableType& table
34 )
35 {
36  return IteratorType(table.begin());
37 }
38 
39 
40 template<class IteratorType, class TableType>
41 inline IteratorType Foam::HashTableCore::iterator_cbegin
42 (
43  const TableType& table
44 )
45 {
46  return IteratorType(table.cbegin());
47 }
48 
49 
50 template<class IteratorType>
51 inline const IteratorType& Foam::HashTableCore::iterator_end()
52 {
53  return *reinterpret_cast<const IteratorType*>(nullObjectPtr);
54 }
55 
56 
57 template<class IteratorType>
58 inline const IteratorType& Foam::HashTableCore::iterator_cend()
59 {
60  return *reinterpret_cast<const IteratorType*>(nullObjectPtr);
61 }
62 
63 
64 // * * * * * * * * * * * * * const iterator pair * * * * * * * * * * * * * * //
65 
66 template<class IteratorType, class TableType>
69 (
70  const TableType& tbl
71 )
72 :
73  size_(tbl.size()),
74  iter_(tbl.begin())
75 {}
76 
77 
78 template<class IteratorType, class TableType>
80 <
81  IteratorType,
82  TableType
83 >::begin() const
84 {
85  return iter_;
86 }
87 
88 
89 template<class IteratorType, class TableType>
91 <
92  IteratorType,
93  TableType
94 >::cbegin() const
95 {
96  return iter_;
97 }
98 
99 
100 template<class IteratorType, class TableType>
101 inline const IteratorType& Foam::HashTableCore::const_iterator_pair
102 <
103  IteratorType,
104  TableType
105 >::end() const
106 {
107  return HashTableCore::iterator_cend<IteratorType>();
108 }
109 
110 
111 template<class IteratorType, class TableType>
112 inline const IteratorType& Foam::HashTableCore::const_iterator_pair
113 <
114  IteratorType,
115  TableType
116 >::cend() const
117 {
118  return HashTableCore::iterator_cend<IteratorType>();
119 }
120 
121 
122 // ************************************************************************* //
Foam::HashTableCore::const_iterator_pair::const_iterator_pair
const_iterator_pair(const TableType &tbl)
Definition: HashTableCoreI.H:69
Foam::nullObjectPtr
const NullObject * nullObjectPtr
Pointer to the unique nullObject.
Definition: nullObject.C:33
stdFoam::begin
constexpr auto begin(C &c) -> decltype(c.begin())
Return iterator to the beginning of the container c.
Definition: stdFoam.H:91
Foam::HashTableCore::iterator_cend
static const IteratorType & iterator_cend()
Factory method to return an iterator cend.
Definition: HashTableCoreI.H:58
Foam::HashTableCore::iterator_begin
static IteratorType iterator_begin(TableType &table)
Factory method to create a non-const iterator begin.
Definition: HashTableCoreI.H:32
Foam::HashTableCore::iterator_end
static const IteratorType & iterator_end()
Factory method to return an iterator end.
Definition: HashTableCoreI.H:51
stdFoam::end
constexpr auto end(C &c) -> decltype(c.end())
Return iterator to the end of the container c.
Definition: stdFoam.H:115
Foam::HashTableCore::iterator_cbegin
static IteratorType iterator_cbegin(const TableType &table)
Factory method to create a const iterator begin.
Definition: HashTableCoreI.H:42
stdFoam::cend
constexpr auto cend(const C &c) -> decltype(c.end())
Return const_iterator to the end of the container c.
Definition: stdFoam.H:131
Foam::HashTableCore::const_iterator_pair
Factory class for creating a begin/end pair for any const iterator.
Definition: HashTableCore.H:98
stdFoam::cbegin
constexpr auto cbegin(const C &c) -> decltype(c.begin())
Return const_iterator to the beginning of the container c.
Definition: stdFoam.H:107