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 template<class t_value>
47 class Set : public SET_BASE<t_value>
48 {
49 public:
51 : SET_BASE<t_value>()
52 {}
53 template<class t_iter>
54 Set(const t_iter& begin, const t_iter& end)
55 : SET_BASE<t_value>(begin, end)
56 {}
57 template<class t_type, class t_index_type, class t_memory_allocator, class t_memory_manager>
61 [[nodiscard]] bool hasValue(const t_value& key) const
62 {
63 return SET_BASE<t_value>::find(key) != SET_BASE<t_value>::end();
64 }
65 void add(const t_value& key)
66 {
67 SET_BASE<t_value>::insert(key);
68 }
69 void add(t_value&& key)
70 {
71 SET_BASE<t_value>::insert(std::move(key));
72 }
73 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>>
81 [[nodiscard]] uint04 indexOf(const t_value& key) const
82 {
83 uint04 i = 0;
84 for (const auto& location : *this)
85 {
86 if (location.first == key)
87 return i;
88 i++;
89 }
91 }
92 [[nodiscard]] uint04 size() const
93 {
94 return cast<uint04>(SET_BASE<t_value>::size());
95 }
96 };
97}
98
Definition Pointer.hpp:297
The equivelent of std::vector but with a bit more control. The basic array unit of the library.
Definition Buffer.hpp:64
bool hasValue(const t_value &key) const
Definition Set.h:61
void add(const t_value &key)
Definition Set.h:65
uint04 size() const
Definition Set.h:92
Buffer< t_value, t_index_type, t_memory_allocator, t_memory_manager > values() const
Definition Set.h:74
uint04 indexOf(const t_value &key) const
Definition Set.h:81
Set(const Buffer< t_type, t_index_type, t_memory_allocator, t_memory_manager > &values)
Definition Set.h:58
Set(const t_iter &begin, const t_iter &end)
Definition Set.h:54
Set()
Definition Set.h:50
void add(t_value &&key)
Definition Set.h:69
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:120
constexpr t_to cast(const Angle< t_from > &value)
Definition Angle.h:514
Definition BaseValues.hpp:272