HashTableCore.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) 2011-2016 OpenFOAM Foundation
9 Copyright (C) 2017-2020 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27Class
28 Foam::HashTableCore
29
30Description
31 Template invariant parts of hash table implementation.
32
33SourceFiles
34 HashTableCoreI.H
35 HashTableCore.C
36
37\*---------------------------------------------------------------------------*/
38
39#ifndef HashTableCore_H
40#define HashTableCore_H
41
42#include "label.H"
43#include "uLabel.H"
44#include "className.H"
45#include "nullObject.H"
46
47// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48
49namespace Foam
50{
51
52/*---------------------------------------------------------------------------*\
53 Class HashTableCore Declaration
54\*---------------------------------------------------------------------------*/
55
56//- Bits that are independent of HashTable template parameters.
57struct HashTableCore
58{
59 //- Maximum allowable internal table size. Approximately labelMax/4
60 static const label maxTableSize;
61
62 //- Return a canonical (power-of-two) of the requested size.
63 static label canonicalSize(const label requested_size);
64
65 //- Declare type-name (with debug switch)
66 ClassName("HashTable");
67
68 //- Default construct
69 HashTableCore() = default;
70
71 static_assert
72 (
73 sizeof(NullObject) >= sizeof(void*),
74 "NullObject is too small to reinterpret_cast as HashTable::iterator"
75 );
76
77
78 //- Factory class for creating a begin/end pair for any const iterator.
79 template<class IteratorType, class TableType>
81 {
82 const label size_;
83 IteratorType iter_;
84
85 public:
86
87 //- Default construct an empty pair
88 inline const_iterator_pair();
89
90 //- Construct begin/end pair for table
91 inline const_iterator_pair(const TableType& tbl);
93 label size() const noexcept { return size_; }
94 bool empty() const noexcept { return !size_; }
95
96 inline IteratorType begin() const;
97 inline IteratorType cbegin() const;
98
99 inline IteratorType end() const;
100 inline IteratorType cend() const;
101 };
102};
103
104
105// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
106
107} // End namespace Foam
108
109// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
110
111#include "HashTableCoreI.H"
112
113// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
114
115#endif
116
117// ************************************************************************* //
Factory class for creating a begin/end pair for any const iterator.
Definition: HashTableCore.H:80
const_iterator_pair()
Default construct an empty pair.
Singleton null-object class and instance.
Definition: nullObject.H:61
Macro definitions for declaring ClassName(), NamespaceName(), etc.
#define ClassName(TypeNameString)
Add typeName information from argument TypeNameString to a class.
Definition: className.H:67
Namespace for OpenFOAM.
const direction noexcept
Definition: Scalar.H:223
Bits that are independent of HashTable template parameters.
Definition: HashTableCore.H:57
HashTableCore()=default
Default construct.
static const label maxTableSize
Maximum allowable internal table size. Approximately labelMax/4.
Definition: HashTableCore.H:59
ClassName("HashTable")
Declare type-name (with debug switch)
static label canonicalSize(const label requested_size)
Return a canonical (power-of-two) of the requested size.
Definition: HashTableCore.C:45