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{
38 {};
39 template <class t_type, class t_buffer>
41 {
42 protected:
43 t_buffer* m_container;
45 public:
46 using iterator_category = std::random_access_iterator_tag;
47 using value_type = t_type;
48 using difference_type = ptrdiff_t;
49 using pointer = t_type*;
50 using reference = t_type&;
51
52 explicit BufferInsertIterator(t_buffer& container, int i)
53 : m_container(&container)
54 , m_location(i)
55 {}
56
58 {
59 m_container->add(m_location, value);
60 ++m_location;
61 return *this;
62 }
64 {
65 m_container->add(m_location, std::move(value));
66 ++m_location;
67 return *this;
68 }
70 {
71 m_location++;
73 lib_assert(m_location <= m_container->size(), "iterator going off edge");
74 return *this;
75 }
77 {
80 lib_assert(m_location <= m_container->size(), "iterator going off edge");
81 return *this;
82 }
88 {
89 return *this;
90 }
91 };
92 template<class t_type, class t_memory_allocator, class t_memory_manager>
94 {
97 auto final_iter = std::set_intersection(a.begin(), a.end(), b.begin(), b.end(), iter);
98 intersect_buf.setSize(cast<uint04>(final_iter - intersect_buf.begin()));
99 return intersect_buf;
100 }
101 //Returns the elements from the sorted buffer a which are not found in the sorted buffer b.
102 template<class t_type, class t_memory_allocator, class t_memory_manager>
104 {
105 lib_assert(a.isSorted(), "A is not sorted");
106 lib_assert(b.isSorted(), "B is not sorted");
107 if (b.size() == 0)
108 return a;
109 if (a.size() == 0)
113 std::set_difference(a.begin(), a.end(), b.begin(), b.end(), iter);
114 return intersect_buf;
115 }
116
117 template<class t_type, class t_memory_allocator, class t_memory_manager>
126
127 template<class t_type, class t_memory_allocator, class t_memory_manager>
138 template<class t_type, class t_memory_allocator, class t_memory_manager>
149 template<class t_type, class t_memory_allocator, class t_memory_manager>
160
161
162
163}
164
#define lib_assert(expression, message)
Asserts some logic in the code. Disabled in non debug mode by default. Can be re-enabled in release u...
Definition LibAssert.h:70
Definition BufferFunctions.h:38
The equivelent of std::vector but with a bit more control. The basic array unit of the library.
Definition Buffer.hpp:64
bool contains(const t_type &element) const
Definition Buffer.hpp:674
void sort()
Definition Buffer.hpp:1611
constexpr t_index_type size() const
Definition Buffer.hpp:1461
bool isSorted() const
Definition Buffer.hpp:2037
void addAll(const Buffer< t_type, t_other_index_type, t_other_memory_allocator, t_other_memory_manager > &buffer)
Definition Buffer.hpp:248
decltype(auto) end()
Definition Buffer.hpp:746
void setSize(t_index_type new_size)
Definition Buffer.hpp:1413
void removeIndex(t_index_type location)
Definition Buffer.hpp:1037
void setUniquePresorted()
Definition Buffer.hpp:1664
decltype(auto) begin()
Definition Buffer.hpp:504
Definition BufferFunctions.h:41
BufferInsertIterator< t_type, t_buffer > & operator++(int val)
Definition BufferFunctions.h:76
t_type value_type
Definition BufferFunctions.h:47
const BufferInsertIterator< t_type, t_buffer > & operator*() const
Definition BufferFunctions.h:87
t_type & reference
Definition BufferFunctions.h:50
t_type * pointer
Definition BufferFunctions.h:49
t_buffer * m_container
Definition BufferFunctions.h:43
std::random_access_iterator_tag iterator_category
Definition BufferFunctions.h:46
BufferInsertIterator< t_type, t_buffer > & operator*()
Definition BufferFunctions.h:83
BufferInsertIterator(t_buffer &container, int i)
Definition BufferFunctions.h:52
BufferInsertIterator< t_type, t_buffer > & operator++()
Definition BufferFunctions.h:69
BufferInsertIterator< t_type, t_buffer > & operator=(const t_type &value)
Definition BufferFunctions.h:57
ptrdiff_t difference_type
Definition BufferFunctions.h:48
uint04 m_location
Definition BufferFunctions.h:44
Definition ACIColor.h:37
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:93
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:128
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:103
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:118
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
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:139
constexpr bool isNaN(const t_type &value)
Query if 'value' is valid or invalid.
Definition BaseFunctions.hpp:200
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:150
constexpr t_type getMin(const t_type &left, const t_type &right)
Finds the minimum of the given arguments based on the < operator.
Definition BaseFunctions.hpp:67