neoGFX
Cross-platform C++ app/game engine
Loading...
Searching...
No Matches
indexitor.hpp
Go to the documentation of this file.
1/*
2* indexitor.hpp
3*
4* Copyright (c) 2007 Leigh Johnston.
5*
6* All rights reserved.
7*
8* Redistribution and use in source and binary forms, with or without
9* modification, are permitted provided that the following conditions are
10* met:
11*
12* * Redistributions of source code must retain the above copyright
13* notice, this list of conditions and the following disclaimer.
14*
15* * Redistributions in binary form must reproduce the above copyright
16* notice, this list of conditions and the following disclaimer in the
17* documentation and/or other materials provided with the distribution.
18*
19* * Neither the name of Leigh Johnston nor the names of any
20* other contributors to this software may be used to endorse or
21* promote products derived from this software without specific prior
22* written permission.
23*
24* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
25* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
26* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
27* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
28* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
29* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
30* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
31* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
32* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
33* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
34* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35*/
36
37#pragma once
38
39#include <neolib/neolib.hpp>
40#include <memory>
41#include <iterator>
42#include <type_traits>
44
45namespace neolib
46{
47 template <typename T, typename ForeignIndex, typename Alloc = std::allocator<std::pair<T, const ForeignIndex>>>
48 class indexitor : private index_array_tree<ForeignIndex, Alloc>
49 {
51 public:
52 typedef T data_type;
53 typedef ForeignIndex foreign_index_type;
54 typedef std::pair<data_type, const foreign_index_type> value_type;
57 typedef std::pair<const foreign_index_type, const foreign_index_type> skip_type;
58 typedef Alloc allocator_type;
59 typedef typename std::allocator_traits<allocator_type>::pointer pointer;
60 typedef typename std::allocator_traits<allocator_type>::const_pointer const_pointer;
61 typedef typename std::allocator_traits<allocator_type>::size_type size_type;
62 typedef typename std::allocator_traits<allocator_type>::difference_type difference_type;
63 private:
64 class node : public base_type::node
65 {
66 public:
67 node(const value_type& aValue, const skip_type& aSkip = skip_type{}) :
68 iValue{aValue}, iSkip{aSkip}
69 {
70 }
71
72 public:
73 const value_type& value() const
74 {
75 return iValue;
76 }
77 value_type& value()
78 {
79 return iValue;
80 }
81 const skip_type& skip() const
82 {
83 return iSkip;
84 }
85 skip_type& skip()
86 {
87 return iSkip;
88 }
89
90 private:
91 value_type iValue;
92 skip_type iSkip;
93 };
94 typedef typename std::allocator_traits<allocator_type>:: template rebind_alloc<node> node_allocator_type;
95 public:
97 {
98 friend class indexitor;
100
101 public:
102 typedef std::random_access_iterator_tag iterator_category;
107
108 public:
110 iContainer{}, iNode{}, iContainerPosition{ 0 }
111 {
112 }
113 iterator(const iterator& aOther) :
114 iContainer{ aOther.iContainer }, iNode{ aOther.iNode }, iContainerPosition{ aOther.iContainerPosition }
115 {
116 }
118 {
119 iContainer = aOther.iContainer;
120 iNode = aOther.iNode;
121 iContainerPosition = aOther.iContainerPosition;
122 return *this;
123 }
124 private:
125 iterator(indexitor& aContainer, size_type aContainerPosition) :
126 iContainer{ &aContainer }, iNode{ nullptr }, iContainerPosition{ aContainerPosition }
127 {
128 iNode = iContainer->find_node(aContainerPosition);
129 if (iNode->is_nil())
130 *this = iContainer->end();
131 }
132 iterator(indexitor& aContainer, node* aNode) :
133 iContainer{ &aContainer }, iNode{ aNode }, iContainerPosition{ iContainer->index(*this) }
134 {
135 }
136 iterator(indexitor& aContainer, node* aNode, size_type aContainerPosition) :
137 iContainer{ &aContainer }, iNode{ aNode }, iContainerPosition{ aContainerPosition }
138 {
139 }
140
141 public:
143 {
144 iNode = static_cast<node*>(iNode->next());
145 ++iContainerPosition;
146 return *this;
147 }
149 {
150 iNode = static_cast<node*>(iNode != nullptr ? iNode->previous() : iContainer->back_node());
151 --iContainerPosition;
152 return *this;
153 }
154 iterator operator++(int) { iterator ret{*this}; operator++(); return ret; }
155 iterator operator--(int) { iterator ret{*this}; operator--(); return ret; }
157 {
158 if (aDifference < 0)
159 return operator-=(-aDifference);
160 *this = iterator{*iContainer, container_position() + aDifference};
161 return *this;
162 }
164 {
165 if (aDifference < 0)
166 return operator+=(-aDifference);
167 *this = iterator{*iContainer, container_position() - aDifference};
168 return *this;
169 }
170 iterator operator+(difference_type aDifference) const { iterator result{*this}; result += aDifference; return result; }
171 iterator operator-(difference_type aDifference) const { iterator result{*this}; result -= aDifference; return result; }
172 reference operator[](difference_type aDifference) const { return *((*this) + aDifference); }
173 difference_type operator-(const iterator& aOther) const { return static_cast<difference_type>(container_position())-static_cast<difference_type>(aOther.container_position()); }
174 reference operator*() const { return iNode->value(); }
175 pointer operator->() const { return &operator*(); }
176 bool operator==(const iterator& aOther) const { return container_position() == aOther.container_position(); }
177 bool operator!=(const iterator& aOther) const { return container_position() != aOther.container_position(); }
178 bool operator<(const iterator& aOther) const { return container_position() < aOther.container_position(); }
179 bool operator<=(const iterator& aOther) const { return container_position() <= aOther.container_position(); }
180 bool operator>(const iterator& aOther) const { return container_position() > aOther.container_position(); }
181 bool operator>=(const iterator& aOther) const { return container_position() >= aOther.container_position(); }
182
183 private:
184 size_type container_position() const { return iContainerPosition; }
185
186 private:
187 indexitor* iContainer;
188 node* iNode;
189 size_type iContainerPosition;
190 };
192 {
193 friend class indexitor;
194
195 public:
196 typedef std::random_access_iterator_tag iterator_category;
201
202 public:
204 iContainer{}, iNode{}, iContainerPosition{ 0 }
205 {
206 }
208 iContainer{ aOther.iContainer }, iNode{ aOther.iNode }, iContainerPosition{ aOther.iContainerPosition }
209 {
210 }
211 const_iterator(const typename indexitor::iterator& aOther) :
212 iContainer{ aOther.iContainer }, iNode{ aOther.iNode }, iContainerPosition{ aOther.iContainerPosition }
213 {
214 }
216 {
217 iContainer = aOther.iContainer;
218 iNode = aOther.iNode;
219 iContainerPosition = aOther.iContainerPosition;
220 return *this;
221 }
223 {
224 iContainer = aOther.iContainer;
225 iNode = aOther.iNode;
226 iContainerPosition = aOther.iContainerPosition;
227 return *this;
228 }
229 private:
230 const_iterator(const indexitor& aContainer, size_type aContainerPosition) :
231 iContainer{ &aContainer }, iNode{ nullptr }, iContainerPosition{ aContainerPosition }
232 {
233 iNode = iContainer->find_node(aContainerPosition);
234 if (iNode->is_nil())
235 *this = iContainer->end();
236 }
237 const_iterator(const indexitor& aContainer, node* aNode) :
238 iContainer{ &aContainer }, iNode{ aNode }, iContainerPosition{ iContainer->index(*this) }
239 {
240 }
241 const_iterator(const indexitor& aContainer, node* aNode, size_type aContainerPosition) :
242 iContainer{ &aContainer }, iNode{ aNode }, iContainerPosition{ aContainerPosition }
243 {
244 }
245
246 public:
248 {
249 iNode = static_cast<node*>(iNode->next());
250 ++iContainerPosition;
251 return *this;
252 }
254 {
255 iNode = static_cast<node*>(iNode != nullptr ? iNode->previous() : iContainer->back_node());
256 --iContainerPosition;
257 return *this;
258 }
259 const_iterator operator++(int) { const_iterator ret{*this}; operator++(); return ret; }
260 const_iterator operator--(int) { const_iterator ret{*this}; operator--(); return ret; }
262 {
263 if (aDifference < 0)
264 return operator-=(-aDifference);
265 *this = const_iterator{*iContainer, container_position() + aDifference};
266 return *this;
267 }
269 {
270 if (aDifference < 0)
271 return operator+=(-aDifference);
272 *this = const_iterator{*iContainer, container_position() - aDifference};
273 return *this;
274 }
275 const_iterator operator+(difference_type aDifference) const { const_iterator result{*this}; result += aDifference; return result; }
276 const_iterator operator-(difference_type aDifference) const { const_iterator result{*this}; result -= aDifference; return result; }
277 const_reference operator[](difference_type aDifference) const { return *((*this) + aDifference); }
278 friend difference_type operator-(const const_iterator& aLhs, const const_iterator& aRhs) { return static_cast<difference_type>(aLhs.container_position())-static_cast<difference_type>(aRhs.container_position()); }
279 const_reference operator*() const { return iNode->value(); }
280 const_pointer operator->() const { return &operator*(); }
281 bool operator==(const const_iterator& aOther) const { return container_position() == aOther.container_position(); }
282 bool operator!=(const const_iterator& aOther) const { return container_position() != aOther.container_position(); }
283 bool operator<(const const_iterator& aOther) const { return container_position() < aOther.container_position(); }
284 bool operator<=(const const_iterator& aOther) const { return container_position() <= aOther.container_position(); }
285 bool operator>(const const_iterator& aOther) const { return container_position() > aOther.container_position(); }
286 bool operator>=(const const_iterator& aOther) const { return container_position() >= aOther.container_position(); }
287
288 private:
289 size_type container_position() const { return iContainerPosition; }
290
291 private:
292 const indexitor* iContainer;
293 node* iNode;
294 size_type iContainerPosition;
295 };
296 typedef std::reverse_iterator<iterator> reverse_iterator;
297 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
298
299 public:
300 indexitor(const Alloc& aAllocator = Alloc()) :
301 iAllocator(aAllocator), iSize(0)
302 {
303 }
304 indexitor(const size_type aCount, const value_type& aValue, const Alloc& aAllocator = Alloc()) :
305 iAllocator(aAllocator), iSize(0)
306 {
307 insert(begin(), aCount, aValue);
308 }
309 template <typename InputIterator>
310 indexitor(InputIterator aFirst, InputIterator aLast, const Alloc& aAllocator = Alloc()) :
311 iAllocator(aAllocator), iSize(0)
312 {
313 insert(begin(), aFirst, aLast);
314 }
315 indexitor(const indexitor& aOther, const Alloc& aAllocator = Alloc()) :
316 iAllocator(aAllocator), iSize(0)
317 {
318 insert(begin(), aOther.begin(), aOther.end());
319 }
321 {
322 erase(begin(), end());
323 }
325 {
326 indexitor newContents{aOther};
327 newContents.swap(*this);
328 return *this;
329 }
330
331 public:
333 {
334 return iSize;
335 }
336 bool empty() const
337 {
338 return iSize == 0;
339 }
341 {
342 return const_iterator{*this, static_cast<node*>(base_type::front_node()), 0};
343 }
345 {
346 return const_iterator{*this, nullptr, size()};
347 }
349 {
350 return iterator{*this, static_cast<node*>(base_type::front_node()), 0};
351 }
353 {
354 return iterator{*this, nullptr, size()};
355 }
357 {
358 return const_reverse_iterator{end()};
359 }
361 {
363 }
365 {
366 return reverse_iterator{end()};
367 }
369 {
370 return reverse_iterator{begin()};
371 }
373 {
374 return *begin();
375 }
377 {
378 return *begin();
379 }
381 {
382 return *--end();
383 }
385 {
386 return *--end();
387 }
389 {
390 if (aPosition.iNode != nullptr)
391 {
392 if (aPosition.iNode->parent() != nullptr)
393 return do_index(aPosition.iNode);
394 else
395 return aPosition.iNode->left_size();
396 }
397 else
398 return size();
399 }
400 size_type index(iterator aPosition) const
401 {
402 if (aPosition.iNode != nullptr)
403 {
404 if (aPosition.iNode->parent() != nullptr)
405 return do_index(aPosition.iNode);
406 else
407 return aPosition.iNode->left_size();
408 }
409 else
410 return size();
411 }
412 iterator insert(const_iterator aPosition, const value_type& aValue, const skip_type& aSkip = skip_type{})
413 {
414 return insert(aPosition, 1, aValue, aSkip);
415 }
417 {
418 return *(begin() + aIndex);
419 }
421 {
422 return *(begin() + aIndex);
423 }
424 template <class InputIterator>
425 typename std::enable_if<!std::is_integral<InputIterator>::value, iterator>::type
426 insert(const_iterator aPosition, InputIterator aFirst, InputIterator aLast)
427 {
428 return do_insert(aPosition, aFirst, aLast);
429 }
430 template <class InputIterator, class SkipIterator>
431 typename std::enable_if<!std::is_integral<InputIterator>::value, iterator>::type
432 insert(const_iterator aPosition, InputIterator aFirst, InputIterator aLast, SkipIterator aSkipFirst, SkipIterator aSkipSecond)
433 {
434 return do_insert(aPosition, aFirst, aLast, aSkipFirst, aSkipSecond);
435 }
436 iterator insert(const_iterator aPosition, size_type aCount, const value_type& aValue, const skip_type& aSkip = skip_type{})
437 {
438 if (aCount == 0)
439 return iterator{*this, aPosition.iNode};
440 auto pos = aPosition.container_position();
441 while (aCount > 0)
442 {
443 aPosition = insert(aPosition, &aValue, &aValue+1, &aSkip, &aSkip+1);
444 ++aPosition;
445 --aCount;
446 }
447 return iterator{*this, pos};
448 }
449 void clear()
450 {
451 erase(begin(), end());
452 }
453 void push_front(const value_type& aValue, const skip_type& aSkip = skip_type{})
454 {
455 insert(begin(), aValue, aSkip);
456 }
457 void push_back(const value_type& aValue, const skip_type& aSkip = skip_type{})
458 {
459 insert(end(), aValue, aSkip);
460 }
461 void resize(std::size_t aNewSize, const value_type& aValue = value_type{}, const skip_type& aSkip = skip_type{})
462 {
463 if (size() < aNewSize)
464 insert(end(), aNewSize - size(), aValue, aSkip);
465 else
466 erase(begin() + aNewSize, end());
467 }
469 {
470 auto pos = aPosition.container_position();
471 erase(aPosition, aPosition + 1);
472 return iterator{*this, pos};
473 }
475 {
476 if (aFirst == aLast)
477 return iterator{*this, aFirst.container_position()};
478 auto pos = aFirst.container_position();
479 for (node* n = aFirst.iNode; n != aLast.iNode;)
480 {
481 node* next = static_cast<node*>(n->next());
482 free_node(n);
483 --iSize;
484 n = next;
485 }
486 return iterator{*this, pos};
487 }
489 {
490 erase(begin());
491 }
492 void pop_back()
493 {
494 erase(--end());
495 }
496 void swap(indexitor& aOther)
497 {
498 base_type::swap(aOther);
499 std::swap(iAllocator, aOther.iAllocator);
500 std::swap(iSize, aOther.iSize);
501 }
502
503 public:
504 void update_foreign_index(const_iterator aPosition, const foreign_index_type& aForeignIndex, const skip_type& aSkip = skip_type{})
505 {
506 value_type currentValue = *aPosition;
507 insert(erase(aPosition), value_type{ currentValue.first, aForeignIndex }, aSkip);
508 }
509 template <typename Pred = std::less<foreign_index_type>>
510 std::pair<const_iterator, foreign_index_type> find_by_foreign_index(foreign_index_type aForeignIndex, Pred aPred = Pred{}) const
511 {
512 size_type nodeIndex{};
513 foreign_index_type nodeForeignIndex{};
514 auto n = base_type::find_node_by_foreign_index(aForeignIndex, nodeIndex, nodeForeignIndex, aPred);
515 if (!n->is_nil() &&
516 !aPred(aForeignIndex - nodeForeignIndex, static_cast<node*>(n)->skip().first) &&
517 aPred(aForeignIndex - nodeForeignIndex, static_cast<node*>(n)->foreign_index() - static_cast<node*>(n)->skip().second))
518 return std::make_pair(const_iterator{*this, static_cast<node*>(n)}, nodeForeignIndex + static_cast<node*>(n)->skip().first);
519 else
520 return std::make_pair(end(), foreign_index(end()));
521 }
522 template <typename Pred = std::less<foreign_index_type>>
523 std::pair<iterator, foreign_index_type> find_by_foreign_index(foreign_index_type aForeignIndex, Pred aPred = Pred{})
524 {
525 size_type nodeIndex{};
526 foreign_index_type nodeForeignIndex{};
527 auto n = base_type::find_node_by_foreign_index(aForeignIndex, nodeIndex, nodeForeignIndex, aPred);
528 if (!n->is_nil() &&
529 !aPred(aForeignIndex - nodeForeignIndex, static_cast<node*>(n)->skip().first) &&
530 aPred(aForeignIndex - nodeForeignIndex, static_cast<node*>(n)->foreign_index() - static_cast<node*>(n)->skip().second))
531 return std::make_pair(iterator{*this, static_cast<node*>(n)}, nodeForeignIndex + static_cast<node*>(n)->skip().first);
532 else
533 return std::make_pair(end(), foreign_index(end()));
534 }
536 {
537 if (aPosition.iNode != nullptr)
538 return do_foreign_index(aPosition.iNode) + aPosition.iNode->skip().first;
539 else
540 return empty() ? foreign_index_type{} : do_foreign_index(static_cast<const node*>(base_type::back_node())) + base_type::back_node()->foreign_index();
541 }
543 {
544 if (aPosition.iNode != nullptr)
545 return aPosition.iNode->skip().first;
546 else
547 return foreign_index_type{};
548 }
550 {
551 if (aPosition.iNode != nullptr)
552 return aPosition.iNode->skip().second;
553 else
554 return foreign_index_type{};
555 }
556
557 private:
558 template <class InputIterator>
559 iterator do_insert(const_iterator aPosition, InputIterator aFirst, InputIterator aLast)
560 {
561 node* before = aPosition.iNode;
562 size_type pos = aPosition.container_position();
563 auto nextPos = pos;
564 while (aFirst != aLast)
565 {
566 base_type::insert_node(allocate_node(before, *aFirst++), nextPos++);
567 ++iSize;
568 }
569 return iterator{*this, pos};
570 }
571 template <class InputIterator, class SkipIterator>
572 iterator do_insert(const_iterator aPosition, InputIterator aFirst, InputIterator aLast, SkipIterator aSkipFirst, SkipIterator aSkipLast)
573 {
574 node* before = aPosition.iNode;
575 size_type pos = aPosition.container_position();
576 auto nextPos = pos;
577 while (aFirst != aLast && aSkipFirst != aSkipLast)
578 {
579 base_type::insert_node(allocate_node(before, *aFirst++, *aSkipFirst++), nextPos++);
580 ++iSize;
581 }
582 return iterator{ *this, pos };
583 }
584 size_type do_index(const node* aNode) const
585 {
586 if (aNode != base_type::root_node())
587 {
588 if (aNode == aNode->parent()->left())
589 return do_index(static_cast<const node*>(aNode->parent())) - aNode->size() + aNode->left_size();
590 else
591 return do_index(static_cast<const node*>(aNode->parent())) + aNode->parent()->centre_size() + aNode->left_size();
592 }
593 else
595 }
596 foreign_index_type do_foreign_index(const node* aNode) const
597 {
598 if (aNode != base_type::root_node())
599 {
600 if (aNode == aNode->parent()->left())
601 return do_foreign_index(static_cast<const node*>(aNode->parent())) - aNode->foreign_index() + aNode->left_foreign_index();
602 else
603 return do_foreign_index(static_cast<const node*>(aNode->parent())) + aNode->parent()->centre_foreign_index() + aNode->left_foreign_index();
604 }
605 else
607 }
608 node* find_node(size_type aContainerPosition) const
609 {
610 return static_cast<node*>(base_type::find_node(aContainerPosition));
611 }
612 node* allocate_node(node* aBefore, const value_type& aValue, const skip_type& aSkip = skip_type{})
613 {
614 node* newNode = std::allocator_traits<node_allocator_type>::allocate(iAllocator, 1);
615 try
616 {
617 std::allocator_traits<node_allocator_type>::construct(iAllocator, newNode, node(aValue, aSkip));
618 }
619 catch (...)
620 {
621 std::allocator_traits<node_allocator_type>::deallocate(iAllocator, newNode, 1);
622 throw;
623 }
624 if (empty())
625 {
628 }
629 else
630 {
631 newNode->set_next(aBefore);
632 if (aBefore)
633 {
634 if (aBefore->previous())
635 {
636 newNode->set_previous(aBefore->previous());
637 aBefore->previous()->set_next(newNode);
638 }
639 aBefore->set_previous(newNode);
640 if (base_type::front_node() == aBefore)
642 }
643 else
644 {
645 base_type::back_node()->set_next(newNode);
646 newNode->set_previous(base_type::back_node());
648 }
649 }
650 newNode->set_size(1);
651 newNode->set_foreign_index(aSkip.first + aValue.second + aSkip.second);
652 return newNode;
653 }
654 void free_node(node* aNode)
655 {
656 if (aNode)
657 {
658 if (aNode->next())
659 aNode->next()->set_previous(aNode->previous());
660 if (aNode->previous())
661 aNode->previous()->set_next(aNode->next());
662 if (base_type::back_node() == aNode)
663 base_type::set_back_node(aNode->previous());
664 if (base_type::front_node() == aNode)
665 base_type::set_front_node(aNode->next());
667 }
668 std::allocator_traits<node_allocator_type>::destroy(iAllocator, aNode);
669 std::allocator_traits<node_allocator_type>::deallocate(iAllocator, aNode, 1);
670 }
671
672 private:
673 node_allocator_type iAllocator;
674 size_type iSize;
675 };
676}
foreign_index_type foreign_index() const
foreign_index_type left_foreign_index() const
node * find_node(size_type aPosition) const
void insert_node(node *aNode, size_type aPosition)
node * find_node_by_foreign_index(foreign_index_type aForeignIndex, size_type &aNodeIndex, foreign_index_type &aNodeForeignIndex, Pred aPred=Pred{}) const
void swap(index_array_tree &aOther)
void set_back_node(node *aBack)
void set_front_node(node *aFront)
const_reference operator[](difference_type aDifference) const
const_iterator & operator=(const typename indexitor::iterator &aOther)
const_pointer operator->() const
friend difference_type operator-(const const_iterator &aLhs, const const_iterator &aRhs)
indexitor::const_reference reference
bool operator<(const const_iterator &aOther) const
bool operator>(const const_iterator &aOther) const
bool operator<=(const const_iterator &aOther) const
const_iterator & operator+=(difference_type aDifference)
bool operator>=(const const_iterator &aOther) const
const_iterator operator-(difference_type aDifference) const
const_iterator & operator-=(difference_type aDifference)
const_iterator(const const_iterator &aOther)
const_iterator(const typename indexitor::iterator &aOther)
std::random_access_iterator_tag iterator_category
const_iterator & operator=(const const_iterator &aOther)
indexitor::difference_type difference_type
bool operator==(const const_iterator &aOther) const
indexitor::const_pointer pointer
bool operator!=(const const_iterator &aOther) const
const_reference operator*() const
const_iterator operator+(difference_type aDifference) const
indexitor::value_type value_type
difference_type operator-(const iterator &aOther) const
iterator & operator-=(difference_type aDifference)
bool operator>(const iterator &aOther) const
iterator(const iterator &aOther)
bool operator<(const iterator &aOther) const
iterator & operator+=(difference_type aDifference)
iterator operator-(difference_type aDifference) const
iterator operator+(difference_type aDifference) const
bool operator<=(const iterator &aOther) const
reference operator[](difference_type aDifference) const
std::random_access_iterator_tag iterator_category
indexitor::difference_type difference_type
bool operator==(const iterator &aOther) const
bool operator>=(const iterator &aOther) const
iterator & operator=(const iterator &aOther)
indexitor::reference reference
reference operator*() const
bool operator!=(const iterator &aOther) const
indexitor::value_type value_type
indexitor::pointer pointer
std::allocator_traits< allocator_type >::difference_type difference_type
Definition indexitor.hpp:62
iterator insert(const_iterator aPosition, const value_type &aValue, const skip_type &aSkip=skip_type{})
iterator erase(const_iterator aPosition)
reference back()
reference front()
iterator insert(const_iterator aPosition, size_type aCount, const value_type &aValue, const skip_type &aSkip=skip_type{})
std::allocator_traits< allocator_type >::size_type size_type
Definition indexitor.hpp:61
foreign_index_type skip_after(const_iterator aPosition) const
size_type index(const_iterator aPosition) const
std::pair< const foreign_index_type, const foreign_index_type > skip_type
Definition indexitor.hpp:57
reverse_iterator rend()
size_type size() const
std::pair< data_type, const foreign_index_type > value_type
Definition indexitor.hpp:54
const_reverse_iterator rend() const
std::reverse_iterator< const_iterator > const_reverse_iterator
value_type & reference
Definition indexitor.hpp:55
foreign_index_type skip_before(const_iterator aPosition) const
indexitor & operator=(const indexitor &aOther)
size_type index(iterator aPosition) const
const_reference operator[](size_type aIndex) const
foreign_index_type foreign_index(const_iterator aPosition) const
std::allocator_traits< allocator_type >::pointer pointer
Definition indexitor.hpp:59
indexitor(InputIterator aFirst, InputIterator aLast, const Alloc &aAllocator=Alloc())
std::pair< const_iterator, foreign_index_type > find_by_foreign_index(foreign_index_type aForeignIndex, Pred aPred=Pred{}) const
void resize(std::size_t aNewSize, const value_type &aValue=value_type{}, const skip_type &aSkip=skip_type{})
void push_front(const value_type &aValue, const skip_type &aSkip=skip_type{})
iterator erase(const_iterator aFirst, const_iterator aLast)
indexitor(const Alloc &aAllocator=Alloc())
bool empty() const
std::enable_if<!std::is_integral< InputIterator >::value, iterator >::type insert(const_iterator aPosition, InputIterator aFirst, InputIterator aLast)
std::pair< iterator, foreign_index_type > find_by_foreign_index(foreign_index_type aForeignIndex, Pred aPred=Pred{})
std::allocator_traits< allocator_type >::const_pointer const_pointer
Definition indexitor.hpp:60
const_iterator end() const
ForeignIndex foreign_index_type
Definition indexitor.hpp:53
const_reference front() const
const_iterator begin() const
const value_type & const_reference
Definition indexitor.hpp:56
reference operator[](size_type aIndex)
std::enable_if<!std::is_integral< InputIterator >::value, iterator >::type insert(const_iterator aPosition, InputIterator aFirst, InputIterator aLast, SkipIterator aSkipFirst, SkipIterator aSkipSecond)
void update_foreign_index(const_iterator aPosition, const foreign_index_type &aForeignIndex, const skip_type &aSkip=skip_type{})
void swap(indexitor &aOther)
const_reference back() const
reverse_iterator rbegin()
std::reverse_iterator< iterator > reverse_iterator
indexitor(const indexitor &aOther, const Alloc &aAllocator=Alloc())
void push_back(const value_type &aValue, const skip_type &aSkip=skip_type{})
indexitor(const size_type aCount, const value_type &aValue, const Alloc &aAllocator=Alloc())
const_reverse_iterator rbegin() const
void swap(plf::hive< element_type, allocator_type > &a, plf::hive< element_type, allocator_type > &b) noexcept(std::allocator_traits< allocator_type >::propagate_on_container_swap::value||std::allocator_traits< allocator_type >::is_always_equal::value)
Definition plf_hive.h:4776