39template <
class T,
class Compare = std::less<T>,
class Alloc = std::allocator<T> >
47 std::vector < std::function < void (
const T & ) > > insertCallbacks;
49 std::vector < std::function < void (
const T & ) > > removeCallbacks;
51 void fireInsert (
const T & element )
const {
52 for (
const std::function <
void (
const T & ) > &
callback : insertCallbacks ) {
57 void fireRemove (
const T & element )
const {
58 for (
const std::function <
void (
const T & ) > &
callback : removeCallbacks ) {
70 bool eq (
const T & first,
const T &
second ) {
76 insertCallbacks.push_back (
callback );
80 removeCallbacks.push_back (
callback );
120 explicit managed_linear_set (
const Compare& comp = Compare(),
const Alloc& alloc = Alloc()) : m_data ( comp, alloc ) {
141 template <
class InputIterator>
142 managed_linear_set (InputIterator first, InputIterator last,
const Compare& comp = Compare(),
const Alloc& alloc = Alloc()) : m_data ( first, last, comp, alloc ) {
152 template <
class Iterator >
182 for (
const T & elem : x ) {
183 x.fireRemove ( elem );
186 m_data = std::move ( x.m_data );
197 for (
const T & elem : x ) {
198 x.fireRemove ( elem );
201 m_data = std::move ( x.m_data );
212 managed_linear_set (std::initializer_list<T> il,
const Compare& comp = Compare(),
const Alloc& alloc = Alloc()) : m_data (
std::move ( il ), comp, alloc ) {
229 return m_data.
begin ( );
239 return m_data.
begin ( );
249 return std::move ( * this ).begin ( );
269 return m_data.
end ( );
279 return m_data.
end ( );
288 auto end ( ) &&
noexcept {
289 return std::move ( * this ).end ( );
299 return m_data.
cend ( );
309 auto endIter =
end ( );
310 auto beginIter =
begin ( );
321 auto endIter =
end ( );
322 auto beginIter =
begin ( );
333 auto endIter = std::move ( * this ).end ( );
334 auto beginIter = std::move ( * this ).begin ( );
344 for (
const T & elem : m_data ) {
357 size_t count (
const T& value )
const {
358 return m_data.
count ( value );
378 return m_data.
crend ( );
391 template <
class... Args>
392 std::pair < iterator, bool >
emplace ( Args && ... args ) {
393 return insert ( T ( std::forward ( args ) ... ) );
407 template <
class... Args>
409 return insert ( position, T ( std::forward ( args ) ... ) );
419 return m_data.
empty ( );
430 std::pair < const_iterator, const_iterator >
equal_range (
const T & val )
const {
455 fireRemove ( * position );
456 return m_data.
erase ( position );
469 if ( position !=
end ( ) && eq ( * position, val ) ) {
470 fireRemove ( * position );
471 m_data.
erase ( position );
491 return m_data.
erase ( first, last );
536 std::pair < iterator, bool >
insert (
const T & val ) {
537 return insert ( T ( val ) );
548 std::pair < iterator, bool >
insert ( T && val ) {
550 if ( position !=
end ( ) && eq ( * position, val ) )
568 return insert ( position, T ( val ) );
581 if ( position !=
end ( ) && eq ( * position, val ) )
584 if ( position !=
end ( ) && m_comp ( val, * position ) && ( position ==
begin ( ) || m_comp ( * std::prev ( position ), val ) ) ) {
586 return m_data.
emplace ( position, std::move ( val ) );
589 return insert ( std::move ( val ) ).first;
599 template <
class InputIterator>
600 void insert (InputIterator first, InputIterator last) {
604 m_data.
insert ( first, last );
613 void insert (std::initializer_list<T> il) {
614 insert ( il.begin ( ), il.end ( ) );
672 m_data = data.m_data;
687 for (
const T & elem : data ) {
688 data.fireRemove ( elem );
691 m_data = std::move ( data.m_data );
707 m_data = std::move ( data );
738 return m_data.
rend ( );
748 return m_data.
rend ( );
758 return m_data.
size ( );
768 auto thisToOther =
ext::make_callback_iterator ( [
this, & data ] (
const T & element ) { this->fireRemove ( element ); data.fireInsert ( element ); } );
769 auto otherToThis =
ext::make_callback_iterator ( [
this, & data ] (
const T & element ) { data.fireRemove ( element ); this->fireInsert ( element ); } );
772 m_data.
swap ( data.m_data );
833template<
class T,
class ... Ts >
838 for(
const T& item : value) {
839 if(!first) out <<
", ";
863template <
class T,
class Compare,
class Alloc>
Implementation of iterator_range, i.e. pair of iterators. The class provides most notably begin and e...
Definition: range.hpp:24
Implementation of set mimicking the iterface of the standard library set. The inner representation is...
Definition: linear_set.hpp:45
reverse_iterator rbegin() noexcept
Getter of a reverse iterator to the begining of range of values in the container.
Definition: linear_set.hpp:687
std::pair< iterator, bool > emplace(Args &&... args)
Emplace a value to the container. Internaly the method uses insert since the place to put the value r...
Definition: linear_set.hpp:375
bool empty() const noexcept
Tests whether the container is empty.
Definition: linear_set.hpp:401
void swap(linear_set &x)
Swaps two instances of linear set.
Definition: linear_set.hpp:737
iterator lower_bound(const T &val)
Returns an iterator pointing to the first element in the range [first,last) which does not compare le...
Definition: linear_set.hpp:613
Compare value_comp() const
Getter of the value comparator instance. Actually the value_type is the same as key_type so this is a...
Definition: linear_set.hpp:773
size_t count(const T &value) const
Computes the number of values in the container.
Definition: linear_set.hpp:340
iterator end() &noexcept
Getter of an iterator to the end of range of values in the container.
Definition: linear_set.hpp:255
const_reverse_iterator crbegin() const noexcept
Getter of a const revese iterator to the begining of reverse range of values in the container.
Definition: linear_set.hpp:350
const_iterator cbegin() const noexcept
Getter of a const iterator to the begining of range of values in the container.
Definition: linear_set.hpp:245
Alloc get_allocator() const noexcept
Getter of the allocator.
Definition: linear_set.hpp:508
const_reverse_iterator crend() const noexcept
Getter of a const revese iterator to the end of reverse range of values in the container.
Definition: linear_set.hpp:360
const_iterator find(const T &val) const
Function to binary search for given value.
Definition: linear_set.hpp:478
iterator upper_bound(const T &val)
Returns an iterator pointing to the first element in the range [first,last) which compares greater th...
Definition: linear_set.hpp:751
std::pair< iterator, bool > insert(const T &val)
Inserts a new value to the container.
Definition: linear_set.hpp:520
iterator erase(const_iterator position)
Removes value from the container based on the position given by iterator.
Definition: linear_set.hpp:437
iterator begin() &noexcept
Getter of an iterator to the begining of range of values in the container.
Definition: linear_set.hpp:215
reverse_iterator rend() noexcept
Getter of a reverse iterator to the end of range of values in the container.
Definition: linear_set.hpp:707
size_t size() const noexcept
Getter of the number of values inside the container.
Definition: linear_set.hpp:727
Compare key_comp() const
Getter of the key comparator instance.
Definition: linear_set.hpp:601
size_t max_size() const noexcept
Returns the maximal number of values possible to store inside the container.
Definition: linear_set.hpp:635
const_iterator cend() const noexcept
Getter of a const iterator to the end of range of values in the container.
Definition: linear_set.hpp:285
Implementation of set mimicking the iterface of the standard library set. The inner representation is...
Definition: managed_linear_set.hpp:40
std::pair< const_iterator, const_iterator > equal_range(const T &val) const
Returns a range of values equal to the val. The range is specified by const iterators.
Definition: managed_linear_set.hpp:430
iterator erase(const_iterator position)
Removes value from the container based on the position given by iterator.
Definition: managed_linear_set.hpp:454
auto range() &
Make range of non-const begin to end iterators.
Definition: managed_linear_set.hpp:308
managed_linear_set(managed_linear_set &&x, const Alloc &alloc)
Move constructor including allocator specification.
Definition: managed_linear_set.hpp:196
const_iterator upper_bound(const T &val) const
Returns an iterator pointing to the first element in the range [first,last) which compares greater th...
Definition: managed_linear_set.hpp:795
size_t size() const noexcept
Getter of the number of values inside the container.
Definition: managed_linear_set.hpp:757
const_reverse_iterator crend() const noexcept
Getter of a const revese iterator to the end of reverse range of values in the container.
Definition: managed_linear_set.hpp:377
managed_linear_set & operator=(const managed_linear_set &data)
Copy operator of assignmet.
Definition: managed_linear_set.hpp:669
const_reverse_iterator rend() const noexcept
Getter of a const reverse iterator to the end of range of values in the container.
Definition: managed_linear_set.hpp:747
ext::vector< T, Alloc >::const_iterator iterator
The type of iterator over values in the set. It is the same as the underling vector's const iterator.
Definition: managed_linear_set.hpp:93
const_iterator cbegin() const noexcept
Getter of a const iterator to the begining of range of values in the container.
Definition: managed_linear_set.hpp:258
auto range() const &
Make range of non-const begin to end iterators.
Definition: managed_linear_set.hpp:320
iterator insert(const_iterator position, T &&val)
Inserts a new value to the container. The method accepts a position hint where to place the new value...
Definition: managed_linear_set.hpp:580
const_iterator lower_bound(const T &val) const
Returns an iterator pointing to the first element in the range [first,last) which does not compare le...
Definition: managed_linear_set.hpp:647
std::pair< iterator, bool > emplace(Args &&... args)
Emplace a value to the container. Internaly the method uses insert since the place to put the value r...
Definition: managed_linear_set.hpp:392
iterator begin() &noexcept
Getter of an iterator to the begining of range of values in the container.
Definition: managed_linear_set.hpp:228
std::pair< iterator, iterator > equal_range(const T &val)
Returns a range of values equal to the val. The range is specified by iterators.
Definition: managed_linear_set.hpp:442
iterator emplace_hint(const_iterator position, Args &&... args)
Emplace a value to the container with provided position as a hint. Internaly the method uses insert s...
Definition: managed_linear_set.hpp:408
const_reverse_iterator rbegin() const noexcept
Getter of a const reverse iterator to the begining of range of values in the container.
Definition: managed_linear_set.hpp:727
managed_linear_set(managed_linear_set &&x)
Move constructor.
Definition: managed_linear_set.hpp:181
iterator insert(const_iterator position, const T &val)
Inserts a new value to the container. The method accepts a position hint where to place the new value...
Definition: managed_linear_set.hpp:567
managed_linear_set(std::initializer_list< T > il, const Compare &comp=Compare(), const Alloc &alloc=Alloc())
Set constructor from initializer list.
Definition: managed_linear_set.hpp:212
void swap(managed_linear_set &data)
Swaps two instances of linear set.
Definition: managed_linear_set.hpp:767
const_iterator end() const &noexcept
Getter of a const iterator to the end of range of values in the container.
Definition: managed_linear_set.hpp:278
iterator lower_bound(const T &val)
Returns an iterator pointing to the first element in the range [first,last) which does not compare le...
Definition: managed_linear_set.hpp:635
managed_linear_set(InputIterator first, InputIterator last, const Compare &comp=Compare(), const Alloc &alloc=Alloc())
Set constructor from a range of values.
Definition: managed_linear_set.hpp:142
ext::vector< T, Alloc >::const_reverse_iterator reverse_iterator
The type of reverse iterator over values in the set. It is the same as the underling vector's const r...
Definition: managed_linear_set.hpp:105
void addRemoveCallback(const std::function< void(const T &) > &callback)
Definition: managed_linear_set.hpp:79
auto operator<=>(const managed_linear_set< T, Compare, Alloc > &other) const =default
Compares two set instances by less relation.
ext::vector< T, Alloc >::const_iterator const_iterator
The type of const iterator over values in the set. It is the same as the underling vector's const ite...
Definition: managed_linear_set.hpp:99
void insert(std::initializer_list< T > il)
Insert values from a range speified by initializer list.
Definition: managed_linear_set.hpp:613
bool empty() const noexcept
Tests whether the container is empty.
Definition: managed_linear_set.hpp:418
reverse_iterator rend() noexcept
Getter of a reverse iterator to the end of range of values in the container.
Definition: managed_linear_set.hpp:737
void addInsertCallback(const std::function< void(const T &) > &callback)
Definition: managed_linear_set.hpp:75
iterator end() &noexcept
Getter of an iterator to the end of range of values in the container.
Definition: managed_linear_set.hpp:268
void insert(InputIterator first, InputIterator last)
Insert values from a range speified by pair of iterators.
Definition: managed_linear_set.hpp:600
T value_type
The type of values in the set.
Definition: managed_linear_set.hpp:87
iterator erase(const_iterator first, const_iterator last)
Removes values in the specified range. The range is specified by pair of iterators.
Definition: managed_linear_set.hpp:487
managed_linear_set(const Alloc &alloc)
Constructor of the empty set with specified allocator.
Definition: managed_linear_set.hpp:129
auto range() &&
Make range of move begin to end iterators.
Definition: managed_linear_set.hpp:332
std::pair< iterator, bool > insert(T &&val)
Inserts a new value to the container.
Definition: managed_linear_set.hpp:548
const_iterator find(const T &val) const
Function to binary search for given value.
Definition: managed_linear_set.hpp:502
size_t max_size() const noexcept
Returns the maximal number of values possible to store inside the container.
Definition: managed_linear_set.hpp:657
auto end() &&noexcept
Getter of a move iterator to the end of range of values in the container.
Definition: managed_linear_set.hpp:288
std::pair< iterator, bool > insert(const T &val)
Inserts a new value to the container.
Definition: managed_linear_set.hpp:536
auto begin() &&noexcept
Getter of a move iterator to the begining of range of values in the container.
Definition: managed_linear_set.hpp:248
Compare key_comp() const
Getter of the key comparator instance.
Definition: managed_linear_set.hpp:623
const_reverse_iterator crbegin() const noexcept
Getter of a const revese iterator to the begining of reverse range of values in the container.
Definition: managed_linear_set.hpp:367
iterator upper_bound(const T &val)
Returns an iterator pointing to the first element in the range [first,last) which compares greater th...
Definition: managed_linear_set.hpp:783
const_iterator begin() const &noexcept
Getter of a const iterator to the begining of range of values in the container.
Definition: managed_linear_set.hpp:238
iterator find(const T &val)
Function to binary search for given value.
Definition: managed_linear_set.hpp:514
managed_linear_set(const managed_linear_set &x, const Alloc &alloc)
Copy constructor including allocator specification.
Definition: managed_linear_set.hpp:172
managed_linear_set(const managed_linear_set &x)
Copy constructor.
Definition: managed_linear_set.hpp:162
reverse_iterator rbegin() noexcept
Getter of a reverse iterator to the begining of range of values in the container.
Definition: managed_linear_set.hpp:717
Alloc get_allocator() const noexcept
Getter of the allocator.
Definition: managed_linear_set.hpp:524
managed_linear_set(const Compare &comp=Compare(), const Alloc &alloc=Alloc())
Default constructor of the empty set.
Definition: managed_linear_set.hpp:120
size_t count(const T &value) const
Computes the number of values in the container.
Definition: managed_linear_set.hpp:357
managed_linear_set(const ext::iterator_range< Iterator > &range)
Definition: managed_linear_set.hpp:153
const_iterator cend() const noexcept
Getter of a const iterator to the end of range of values in the container.
Definition: managed_linear_set.hpp:298
size_t erase(const T &val)
Removes value from the container.
Definition: managed_linear_set.hpp:467
Compare value_comp() const
Getter of the value comparator instance. Actually the value_type is the same as key_type so this is a...
Definition: managed_linear_set.hpp:805
~managed_linear_set()
The destructor of the linear set.
Definition: managed_linear_set.hpp:219
void clear() noexcept
Removes all values from the conainer,.
Definition: managed_linear_set.hpp:343
ext::vector< T, Alloc >::const_reverse_iterator const_reverse_iterator
The type of const reverse iterator over values in the set. It is the same as the underling vector's c...
Definition: managed_linear_set.hpp:111
typename std::vector< T, Alloc >::const_iterator const_iterator
The type of constant values iterator.
Definition: vector.hpp:67
typename std::vector< T, Alloc >::const_reverse_iterator const_reverse_iterator
The type of constant reverse values iterator.
Definition: vector.hpp:79
p second
Definition: ToRegExpAlgebraic.h:126
Definition: sigHandler.cpp:20
callback_iterator< T > make_callback_iterator(T callback)
Definition: iterator.hpp:993
int callback(struct dl_phdr_info *info, size_t, void *data)
Definition: simpleStacktrace.cpp:25
void set_symmetric_difference(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, OutputIterator1 result1, OutputIterator2 result2, Compare comp)
Constructs sorted ranges beginning in the location pointed by result1 and result2 with the set differ...
Definition: algorithm.hpp:93
iterator_range< Iter > make_iterator_range(Iter begin, Iter end)
Helper to create iterator_range from two iterators.
Definition: range.hpp:235
constexpr auto make_pair(T1 &&x, T2 &&y)
Definition: pair.hpp:79
std::ostream & operator<<(ext::reference_wrapper< std::ostream > &os, std::ostream &(*const func)(std::ostream &))
Overloaded function allowing same operations on wrapped output stream as on the actual output stream,...
Definition: GlobalData.cpp:33
Definition: FordFulkerson.hpp:16
void swap(ext::managed_linear_set< T, Compare, Alloc > &x, ext::managed_linear_set< T, Compare, Alloc > &y)
Specialisation of swap for linear set.
Definition: managed_linear_set.hpp:864