API Documentation
Loading...
Searching...
No Matches
BufferFunctions.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: BufferFunctions
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include <NDEVR/Buffer.h>
34#include <algorithm>
35namespace NDEVR
36{
37 /**--------------------------------------------------------------------------------------------------
38 \brief A dummy class to include complex Buffer insert and sort functions
39 Functions that enhance the functionality of the Buffer class.
40 **/
42 {};
43 /**--------------------------------------------------------------------------------------------------
44 \brief Used by stl library to insert objects into the buffer.
45 **/
46 template <class t_type, class t_buffer>
48 {
49 protected:
50 t_buffer* m_container;
52 public:
53 using iterator_category = std::random_access_iterator_tag;
54 using value_type = t_type;
55 using difference_type = ptrdiff_t;
56 using pointer = t_type*;
57 using reference = t_type&;
58
59 explicit BufferInsertIterator(t_buffer& container, int i)
60 : m_container(&container)
61 , m_location(i)
62 {}
63
65 {
66 m_container->add(m_location, value);
67 ++m_location;
68 return *this;
69 }
71 {
72 m_container->add(m_location, std::move(value));
73 ++m_location;
74 return *this;
75 }
77 {
78 m_location++;
80 lib_assert(m_location <= m_container->size(), "iterator going off edge");
81 return *this;
82 }
84 {
87 lib_assert(m_location <= m_container->size(), "iterator going off edge");
88 return *this;
89 }
95 {
96 return *this;
97 }
98 };
99 template<class t_type, class t_memory_allocator, class t_memory_manager>
101 {
104 auto final_iter = std::set_intersection(a.begin(), a.end(), b.begin(), b.end(), iter);
105 intersect_buf.setSize(cast<uint04>(final_iter - intersect_buf.begin()));
106 return intersect_buf;
107 }
108 //Returns the elements from the sorted buffer a which are not found in the sorted buffer b.
109 template<class t_type, class t_memory_allocator, class t_memory_manager>
111 {
112 lib_assert(a.isSorted(), "A is not sorted");
113 lib_assert(b.isSorted(), "B is not sorted");
114 if (b.size() == 0)
115 return a;
116 if (a.size() == 0)
120 std::set_difference(a.begin(), a.end(), b.begin(), b.end(), iter);
121 return intersect_buf;
122 }
123
124 template<class t_type, class t_memory_allocator, class t_memory_manager>
133
134 template<class t_type, class t_memory_allocator, class t_memory_manager>
145 template<class t_type, class t_memory_allocator, class t_memory_manager>
156 template<class t_type, class t_memory_allocator, class t_memory_manager>
167
168
169
170}
171
#define lib_assert(expression, message)
Definition LibAssert.h:61
A dummy class to include complex Buffer insert and sort functions Functions that enhance the function...
Definition BufferFunctions.h:42
The equivelent of std::vector but with a bit more control. The basic array unit of the library.
Definition Buffer.hpp:56
bool contains(const t_type &element) const
Definition Buffer.hpp:465
void sort()
Definition Buffer.hpp:892
constexpr t_index_type size() const
Definition Buffer.hpp:823
bool isSorted() const
Definition Buffer.hpp:1009
void addAll(const Buffer< t_type, t_other_index_type, t_other_memory_allocator, t_other_memory_manager > &buffer)
Definition Buffer.hpp:243
decltype(auto) end()
Definition Buffer.hpp:507
void setSize(t_index_type new_size)
Definition Buffer.hpp:803
void removeIndex(t_index_type location)
Definition Buffer.hpp:606
void setUniquePresorted()
Definition Buffer.hpp:908
decltype(auto) begin()
Definition Buffer.hpp:402
Used by stl library to insert objects into the buffer.
Definition BufferFunctions.h:48
BufferInsertIterator< t_type, t_buffer > & operator++(int val)
Definition BufferFunctions.h:83
t_type value_type
Definition BufferFunctions.h:54
const BufferInsertIterator< t_type, t_buffer > & operator*() const
Definition BufferFunctions.h:94
t_type & reference
Definition BufferFunctions.h:57
BufferInsertIterator< t_type, t_buffer > & operator=(t_type &&value)
Definition BufferFunctions.h:70
t_type * pointer
Definition BufferFunctions.h:56
t_buffer * m_container
Definition BufferFunctions.h:50
std::random_access_iterator_tag iterator_category
Definition BufferFunctions.h:53
BufferInsertIterator< t_type, t_buffer > & operator*()
Definition BufferFunctions.h:90
BufferInsertIterator(t_buffer &container, int i)
Definition BufferFunctions.h:59
BufferInsertIterator< t_type, t_buffer > & operator++()
Definition BufferFunctions.h:76
BufferInsertIterator< t_type, t_buffer > & operator=(const t_type &value)
Definition BufferFunctions.h:64
ptrdiff_t difference_type
Definition BufferFunctions.h:55
uint04 m_location
Definition BufferFunctions.h:51
Definition ACIColor.h:37
constexpr bool IsInvalid(const t_type &value)
Query if 'value' is valid or invalid. Invalid values should return invalid if used for calculations o...
Definition BaseFunctions.hpp:170
Buffer< t_type, t_memory_allocator, t_memory_manager > IntersectSorted(const Buffer< t_type, t_memory_allocator, t_memory_manager > &a, const Buffer< t_type, t_memory_allocator, t_memory_manager > &b)
Definition BufferFunctions.h:100
Buffer< t_type, t_memory_allocator, t_memory_manager > Intersect(const Buffer< t_type, t_memory_allocator, t_memory_manager > &a, const Buffer< t_type, t_memory_allocator, t_memory_manager > &b)
Definition BufferFunctions.h:135
Buffer< t_type, t_memory_allocator, t_memory_manager > ExceptSorted(const Buffer< t_type, t_memory_allocator, t_memory_manager > &a, const Buffer< t_type, t_memory_allocator, t_memory_manager > &b)
Definition BufferFunctions.h:110
Buffer< t_type, t_memory_allocator, t_memory_manager > Union(const Buffer< t_type, t_memory_allocator, t_memory_manager > &a, const Buffer< t_type, t_memory_allocator, t_memory_manager > &b)
Definition BufferFunctions.h:125
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
Buffer< t_type, t_memory_allocator, t_memory_manager > IntersectPreserveOrderA(const Buffer< t_type, t_memory_allocator, t_memory_manager > &a, const Buffer< t_type, t_memory_allocator, t_memory_manager > &b)
Definition BufferFunctions.h:146
Buffer< t_type, t_memory_allocator, t_memory_manager > Except(const Buffer< t_type, t_memory_allocator, t_memory_manager > &a, const Buffer< t_type, t_memory_allocator, t_memory_manager > &b)
Definition BufferFunctions.h:157
constexpr t_type getMin(const t_type &left, const t_type &right)
Finds the minimum of the given arguments based on the < operator Author: Tyler Parke Date: 2017-11-05...
Definition BaseFunctions.hpp:56