API Documentation
Loading...
Searching...
No Matches
Set.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------------------------------
2Copyright (c) 2019, NDEVR LLC
3tyler.parke@ndevr.org
4 __ __ ____ _____ __ __ _______
5 | \ | | | __ \ | ___|\ \ / / | __ \
6 | \ | | | | \ \ | |___ \ \ / / | |__) |
7 | . \| | | |__/ / | |___ \ V / | _ /
8 | |\ |_|_____/__|_____|___\_/____| | \ \
9 |__| \__________________________________| \__\
10
11Subject to the terms of the Enterprise+ Agreement, NDEVR hereby grants
12Licensee a limited, non-exclusive, non-transferable, royalty-free license
13(without the right to sublicense) to use the API solely for the purpose of
14Licensee's internal development efforts to develop applications for which
15the API was provided.
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25DEALINGS IN THE SOFTWARE.
26
27Library: Base
28File: Dictionary
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include <NDEVR/BaseValues.h>
34#include <NDEVR/LibAssert.h>
35#include <NDEVR/Buffer.h>
36#define NDEVR_USE_ROBIN_MAP 1
37#if NDEVR_USE_ROBIN_MAP
38#include "tsl/robin_set.h"
39#define SET_BASE tsl::robin_set
40#else
41#include <set>
42#define SET_BASE std::set
43#endif
44namespace NDEVR
45{
46 /**--------------------------------------------------------------------------------------------------
47 \brief A dummy base class for all Set templates
48 **/
49 class SetBase
50 {};
51 /**--------------------------------------------------------------------------------------------------
52 \brief Container that stores unique elements in no particular order, and which allow for fast retrieval
53 or insertion of individual elements based on their value.
54 **/
55 template<class t_value>
56 class Set : public SET_BASE<t_value>, public SetBase
57 {
58 public:
60 : SET_BASE<t_value>()
61 {}
62 template<class t_iter>
63 Set(const t_iter& begin, const t_iter& end)
64 : SET_BASE<t_value>(begin, end)
65 {}
66 template<class t_type, class t_index_type, class t_memory_allocator, class t_memory_manager>
70 [[nodiscard]] bool hasValue(const t_value& key) const
71 {
72 return SET_BASE<t_value>::find(key) != SET_BASE<t_value>::end();
73 }
74 void add(const t_value& key)
75 {
76 SET_BASE<t_value>::insert(key);
77 }
78 void add(t_value&& key)
79 {
80 SET_BASE<t_value>::insert(std::move(key));
81 }
82 template<class t_index_type = uint04, class t_memory_allocator = ObjectAllocator<ObjectInfo<t_value>::Primitive, t_index_type>, class t_memory_manager = BufferAllocator<t_value, t_index_type, false>>
90 [[nodiscard]] uint04 indexOf(const t_value& key) const
91 {
92 uint04 i = 0;
93 for (const auto& location : *this)
94 {
95 if (location.first == key)
96 return i;
97 i++;
98 }
100 }
101 [[nodiscard]] uint04 size() const
102 {
103 return cast<uint04>(SET_BASE<t_value>::size());
104 }
105 };
106}
107
#define SET_BASE
Definition Set.h:39
Specific logic for reserving memory for a Buffer. When managed, and more memory is needed memory is r...
Definition Pointer.hpp:311
The equivelent of std::vector but with a bit more control. The basic array unit of the library.
Definition Buffer.hpp:56
A dummy base class for all Set templates.
Definition Set.h:50
Container that stores unique elements in no particular order, and which allow for fast retrieval or i...
Definition Model.h:51
bool hasValue(const t_value &key) const
Definition Set.h:70
void add(const t_value &key)
Definition Set.h:74
uint04 size() const
Definition Set.h:101
Buffer< t_value, t_index_type, t_memory_allocator, t_memory_manager > values() const
Definition Set.h:83
uint04 indexOf(const t_value &key) const
Definition Set.h:90
Set(const Buffer< t_type, t_index_type, t_memory_allocator, t_memory_manager > &values)
Definition Set.h:67
Set(const t_iter &begin, const t_iter &end)
Definition Set.h:63
Set()
Definition Set.h:59
void add(t_value &&key)
Definition Set.h:78
Definition ACIColor.h:37
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:96
constexpr t_to cast(const Angle< t_from > &value)
Definition Angle.h:375
Defines for a given type (such as sint04, fltp08, UUID, etc) a maximum, minimum, and reserved 'invali...
Definition BaseValues.hpp:233