xtd 0.2.0
Loading...
Searching...
No Matches
arranged_element_collection.hpp
Go to the documentation of this file.
1
4#pragma once
5
6//#include "items_added_event_handler.hpp"
7#include "sorter_none.hpp"
8#include <xtd/collections/generic/helpers/equator>
9#include <xtd/collections/generic/list>
11#include <xtd/array>
12#include <xtd/argument_out_of_range_exception>
13#include <xtd/event_args>
14#include <xtd/event_handler>
15#include <xtd/event>
16#include <xtd/object>
17#include <xtd/new_ptr>
18#include <xtd/usize_object>
19
21namespace xtd {
23 namespace forms {
25 namespace layout {
40 template<typename type_t, typename sorter_t = sorter_none>
41 class arranged_element_collection : public object, public xtd::collections::generic::icollection<type_t> {
42 public:
44 class value_type : public type_t {
45 public:
47 value_type() = default;
48 value_type(const value_type&) = default;
49 value_type(value_type&&) = default;
50 template<typename ...args_t>
51 value_type(args_t&& ...args) : type_t(args...) {}
52 value_type& operator =(const value_type& value) {
53 if (value.owner) owner = value.owner;
54 if (owner != nullptr && !owner->data_->inserting && !owner->data_->erasing) owner->on_item_updated(pos, static_cast<type_t&>(const_cast<value_type&>(value)));
55 type_t::operator =(value);
56 return self_;
57 }
59 if (value.owner) owner = value.owner;
60 if (owner != nullptr && !owner->data_->inserting && !owner->data_->erasing) owner->on_item_updated(pos, static_cast<type_t&>(value));
61 type_t::operator =(value);
62 return self_;
63 }
64 operator type_t() {return self_;}
65 friend std::ostream& operator <<(std::ostream& os, const arranged_element_collection::value_type& value) {return os << static_cast<const type_t&>(value);}
67
68 private:
69 friend class arranged_element_collection;
70 size_t pos = usize_object::max_value;
71 arranged_element_collection* owner = nullptr;
72 };
73
75
84 using reference = type_t&;
86 using const_reference = const type_t&;
88 using pointer = value_type*;
90 using const_pointer = const value_type*;
94
96
106 inline static constexpr xtd::usize npos = xtd::npos;
107
116 static inline constexpr xtd::usize bpos = 0;
117
134 static inline constexpr xtd::usize epos = npos - 1;
136
138
160
163 arranged_element_collection(const arranged_element_collection& collection) {*data_ = *collection.data_;}
167 data_ = std::move(collection.data_);
168 collection.data_ = new_ptr<data_collection>();
169 }
170
172 arranged_element_collection(const base_type& collection) {data_->items = collection;}
175 arranged_element_collection(base_type&& collection) {data_->items = std::move(collection);}
178 arranged_element_collection(std::initializer_list<type_t> items) {add_range(items);}
183 template <std::input_iterator input_iterator_t>
184 arranged_element_collection(input_iterator_t first, input_iterator_t last) {
185 for (auto iterator = first; iterator != last; ++iterator)
186 add(*iterator);
187 }
188
189
191
196 size_type capacity() const noexcept {return data_->items.capacity();}
201 void capacity(size_type value) {data_->items.capacity(value);}
202
205 size_type count() const noexcept override {return data_->items.count();}
206
209 pointer data() {return data_->items.data();}
212 const_pointer data() const {return data_->items.data();}
213
216 const auto& items() const {return data_->items.items();}
219 auto& items() {return data_->items.items();}
220
223 virtual bool sorted() const noexcept {return data_->sorted;}
226 virtual arranged_element_collection& sorted(bool value) {
227 if (data_->sorted == value) return self_;
228 data_->sorted = value;
229 if (data_->sorted) sort();
230 return self_;
231 }
232
233
235
239 void add(const type_t& item) override {
240 data_->items.add(item);
241 size_t index = data_->items.count() - 1;
242 static_cast<value_type&>(self_[index]).owner = this;
243 static_cast<value_type&>(self_[index]).pos = index;
244 on_item_added(index, data_->items[index]);
245 if (data_->sorted) sort();
246 }
247
249 virtual void add(type_t&& item) {
250 data_->items.add(item);
251 size_t index = data_->items.count() - 1;
252 static_cast<value_type&>(self_[index]).owner = this;
253 static_cast<value_type&>(self_[index]).pos = index;
254 on_item_added(index, data_->items[index]);
255 if (data_->sorted) sort();
256 }
257
260 virtual void add_range(const arranged_element_collection& collection) {
261 for (const auto& item : collection)
262 add(item);
263 }
264
266 virtual void add_range(const std::vector<type_t>& collection) {
267 for (const auto& item : collection)
268 add(item);
269 }
270
272 virtual void add_range(const std::initializer_list<type_t>& collection) {
273 for (const auto& item : collection)
274 add(item);
275 }
276
278 template<typename collection_t>
279 void add_range(collection_t&& collection) {
280 for (auto& item : collection)
281 add(value_type(item));
282 }
283
285 template<typename collection_t>
286 void add_range(const collection_t& collection) {
287 for (const auto& item : collection)
288 add(item);
289 }
290
293 void clear() override {
294 while (count())
295 remove_at(0);
296 }
297
301 bool contains(const type_t& item) const noexcept override {
302 return data_->items.contains(item);
303 }
304
309 void copy_to(xtd::array<type_t>& array, xtd::usize array_index) const override {
311 auto i = size_type {0};
312 for (const type_t& item : self_) {
313 if (i >= count()) return;
314 array[array_index + i++] = item;
315 }
316 }
317
321 struct arranged_element_collection_enumerator : public xtd::collections::generic::ienumerator<type_t> {
322 explicit arranged_element_collection_enumerator(const arranged_element_collection& items, xtd::usize version) : items_(items), version_(version) {}
323
324 const type_t& current() const override {
326 if (version_ != items_.items().version()) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::invalid_operation, "Collection was modified; enumeration operation may not execute.");
327 return items_[index_];
328 }
329
330 bool move_next() override {
331 if (version_ != items_.items().version()) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::invalid_operation, "Collection was modified; enumeration operation may not execute.");
332 return ++index_ < items_.count();
333 }
334
335 void reset() override {
336 version_ = items_.items().version();
338 }
339
340 private:
342 const arranged_element_collection& items_;
343 size_type version_ = 0;
344 };
345
347 }
348
352 virtual void insert(xtd::usize index, const type_t& value) {
354 data_->inserting = true;
355 items().insert(items().begin() + index, value);
356 data_->inserting = false;
357 static_cast<value_type&>(self_[index]).owner = this;
358 static_cast<value_type&>(self_[index]).pos = index;
359 on_item_added(index, data_->items[index]);
360 if (data_->sorted) sort();
361 }
362
365 sorter_t sorter;
366 sorter(items().begin(), items().end());
367 return self_;
368 }
369
375 bool remove(const type_t& item) override {
376 if (count() == 0) return false;
377 for (auto index = size_type {0}; index < count(); ++index) {
378 if (!xtd::collections::generic::helpers::equator<type_t> {}(self_[index], item)) continue;
379 remove_at(index);
380 return true;
381 }
382 return false;
383 }
384
387 virtual void remove_at(size_t index) {
389 on_item_removed(index, const_cast<value_type&>(data_->items[index]));
390 data_->erasing = true;
391 items().erase(items().begin() + index);
392 data_->erasing = false;
393 }
394
412 data_->items.reverse(index, count);
413 return self_;
414 }
415
416
419 xtd::array<type_t> to_array() const noexcept {
420 return data_->items.count() ? xtd::array<type_t>(data_->items.begin(), data_->items.end()) : xtd::array<type_t> {};
421 }
422
423
425
435
439 clear();
440 add_range(std::move(other.data_->items));
441 return self_;
442 }
443
446 arranged_element_collection& operator =(const std::initializer_list<type_t>& items) {
447 clear();
449 return self_;
450 }
451
455 value_type& operator [](size_type index) {
457 data_->items[index].pos = index > npos / 2 ? count() - (npos - index) : index;
458 data_->items[index].owner = this;
459 return data_->items[index];
460 }
461
464 const value_type& operator [](size_type index) const {
466 data_->items[index].pos = index > npos / 2 ? count() - (npos - index) : index;
467 data_->items[index].owner = const_cast<arranged_element_collection*>(this);
468 return data_->items[index];
469 }
470
473 operator const_base_type& () const noexcept {return items();}
476 operator base_type& () noexcept {return items();}
477
478 bool operator ==(const arranged_element_collection& value) const {return data_->items == value.data_->items;}
479 bool operator !=(const arranged_element_collection& value) const {return !operator ==(value);}
481
483
487 event<arranged_element_collection, delegate<void(size_t, type_t& item)>> item_added;
488
491 event<arranged_element_collection, delegate<void(size_t, type_t& item)>> item_updated;
492
495 event<arranged_element_collection, delegate<void(size_t, type_t& item)>> item_removed;
497
499
503 using reverse_iterator [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::items::reverse_iterator - Will be removed in version 0.4.0.")]] = typename xtd::collections::generic::list<value_type>::base_type::reverse_iterator;
506 using const_reverse_iterator [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::items::const_reverse_iterator - Will be removed in version 0.4.0.")]] = typename xtd::collections::generic::list<value_type>::base_type::const_reverse_iterator;
508
510
515 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::items().max_size - Will be removed in version 0.4.0.")]]
516 size_type max_size() const noexcept {return data_->items.max_size();}
518
520
526 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::operator [] - Will be removed in version 0.4.0.")]]
528 data_->items[pos].pos = pos;
529 data_->items[pos].owner = this;
530 return data_->items.at(pos);
531 }
532
536 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::operator [] - Will be removed in version 0.4.0.")]]
537 const_reference at(size_type pos) const {return data_->items.at(pos);}
538
542 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::operator [~1_z] - Will be removed in version 0.4.0.")]]
543 reference back() {return data_->items.back();}
547 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::operator [~1_z] - Will be removed in version 0.4.0.")]]
548 const_reference back() const {return data_->items.back();}
549
553 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::items().crbegin - Will be removed in version 0.4.0.")]]
554 const_reverse_iterator crbegin() const noexcept {return data_->items.crbegin();}
558 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::items().crend - Will be removed in version 0.4.0.")]]
559 const_reverse_iterator crend() const noexcept {return data_->items.crend();}
560
564 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::operator [0] - Will be removed in version 0.4.0.")]]
565 reference front() {return data_->items.front();}
569 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::operator [0] - Will be removed in version 0.4.0.")]]
570 const_reference front() const {return data_->items.front();}
571
575 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::items().get_allocator - Will be removed in version 0.4.0.")]]
576 auto get_allocator() const noexcept {return data_->items.get_allocator();}
577
582 template<typename ...args_t>
583 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::insert - Will be removed in version 0.4.0.")]]
585 auto index = pos - items().begin();
586 data_->inserting = true;
587 auto result = data_->items.insert(pos, args...);
588 data_->inserting = false;
589 self_[index].owner = this;
590 self_[index].pos = index;
591 on_item_added(index, data_->items[index]);
592 if (data_->sorted) sort();
593 return result;
594 }
595
599 template<typename ...args_t>
600 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::add - Will be removed in version 0.4.0.")]]
601 void emplace_back(args_t&& ... args) {
602 data_->items.emplace_back(args...);
603 size_t index = data_->items.count() - 1;
604 self_[index].owner = this;
605 self_[index].pos = index;
606 on_item_added(index, data_->items[index]);
607 if (data_->sorted) sort();
608 }
609
613 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::remove_at - Will be removed in version 0.4.0.")]]
615 on_item_removed(pos - items().begin(), *pos);
616 data_->erasing = true;
617 auto result = items().erase(pos);
618 data_->erasing = false;
619 return result;
620 }
621
624 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::remove_at - Will be removed in version 0.4.0.")]]
626 on_item_removed(pos - items().begin(), const_cast<value_type&>(*pos));
627 data_->erasing = true;
628 auto result = items().erase(pos);
629 data_->erasing = false;
630 return result;
631 }
632
637 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::remove_at - Will be removed in version 0.4.0.")]]
639 auto result = items().end();
640 auto index = first - items().begin();
641 for (auto it = first; it <= last; ++it)
642 remove_at(index++);
643 return result;
644 }
645
649 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::remove_at - Will be removed in version 0.4.0.")]]
651 auto result = items().end();
652 auto index = first - items().begin();
653 for (auto it = first; it <= last; ++it)
654 remove_at(index++);
655 return result;
656 }
657
661 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::remove_at - Will be removed in version 0.4.0.")]]
662 void erase_at(size_t index) {
663 remove_at(index);
664 }
665
670 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::insert - Will be removed in version 0.4.0.")]]
672 auto index = pos - items().begin();
673 data_->inserting = true;
674 auto result = items().insert(pos, value);
675 data_->inserting = false;
676 self_[index].owner = this;
677 self_[index].pos = index;
678 on_item_added(index, data_->items[index]);
679 if (data_->sorted) sort();
680 return result;
681 }
682
686 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::insert - Will be removed in version 0.4.0.")]]
688 auto index = pos - items().begin();
689 data_->inserting = true;
690 auto result = items().insert(pos, value);
691 data_->inserting = false;
692 self_[index].owner = this;
693 self_[index].pos = index;
694 on_item_added(index, data_->items[index]);
695 if (data_->sorted) sort();
696 return result;
697 }
698
703 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::insert - Will be removed in version 0.4.0.")]]
704 void insert_at(size_t index, const type_t& value) {
705 insert(index, value);
706 }
707
710 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::remove(count() - 1) - Will be removed in version 0.4.0.")]]
711 void pop_back() {
712 if (count() != 0) remove_at(count() - 1);
713 }
714
718 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::add - Will be removed in version 0.4.0.")]]
719 void push_back(const type_t& item) {
720 add(item);
721 }
722
725 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::add - Will be removed in version 0.4.0.")]]
726 void push_back(type_t&& item) {
727 add(std::move(item));
728 }
729
733 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::add_range - Will be removed in version 0.4.0.")]]
735 add_range(collection);
736 }
737
740 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::add_range - Will be removed in version 0.4.0.")]]
741 void push_back_range(const std::vector<type_t>& collection) {
742 add_range(collection);
743 }
744
747 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::add_range - Will be removed in version 0.4.0.")]]
748 void push_back_range(const std::initializer_list<type_t>& collection) {
749 add_range(collection);
750 }
751
754 template<typename collection_t>
755 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::add_range - Will be removed in version 0.4.0.")]]
756 void push_back_range(collection_t&& collection) {
757 add_range(collection);
758 }
759
762 template<typename iterator_t>
763 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::add_range - Will be removed in version 0.4.0.")]]
764 void push_back_range(iterator_t begin, iterator_t end) {
766 }
767
771 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::to_array - Will be removed in version 0.4.0.")]]
772 std::vector<type_t> to_vector() const noexcept {return to_array();}
773
777 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::items().rbegin - Will be removed in version 0.4.0.")]]
778 auto rbegin() noexcept {return data_->items.rbegin();}
782 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::items().rbegin - Will be removed in version 0.4.0.")]]
783 auto rbegin() const noexcept {return data_->items.rbegin();}
784
788 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::items().rend - Will be removed in version 0.4.0.")]]
789 auto rend() noexcept {return data_->items.rend();}
793 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::items().rend - Will be removed in version 0.4.0.")]]
794 auto rend() const noexcept {return data_->items.rend();}
795
798 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::items().reserve - Will be removed in version 0.4.0.")]]
799 void reserve(size_type size) {data_->items.reserve(size);}
800
803 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::items().shrink_to_fit - Will be removed in version 0.4.0.")]]
804 void shrink_to_fit() {data_->items.shrink_to_fit();}
806
807 protected:
809
814 virtual void on_item_added(size_t index, type_t& item) {item_added(index, item);}
815
819 virtual void on_item_updated(size_t index, type_t& item) {item_updated(index, item);}
820
824 virtual void on_item_removed(size_t index, type_t& item) {item_removed(index, item);}
826
827 private:
828 bool is_read_only() const noexcept override {return false;}
829 bool is_synchronized() const noexcept override {return false;}
830 const xtd::object& sync_root() const noexcept override {return data_->sync_root;}
831
832 struct data_collection {
833 mutable xtd::collections::generic::list < value_type > items;
834 bool inserting = false;
835 bool erasing = false;
836 bool sorted = false;
837 xtd::object sync_root;
838 };
840 };
841 }
842 }
843}
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Definition array.hpp:64
virtual auto items() const noexcept -> const base_type &
Returns the underlying base type items.
Definition basic_array.hpp:111
virtual auto length() const noexcept -> size_type
Gets a size that represents the total number of elements in all the dimensions of the array.
Definition basic_array.hpp:122
static constexpr xtd::usize max_value
Definition box_integer.hpp:71
Exposes the enumerator, which supports a simple iteration over a collection of a specified type.
Definition ienumerable.hpp:40
Supports a simple iteration over a generic collection.
Definition ienumerator.hpp:58
Represents a strongly typed list of objects that can be accessed by index. Provides methods to search...
Definition list.hpp:80
auto insert(size_type index, const type_t &value) -> void override
Determines the index of a specific item in the xtd::collections::generic::list <type_t>.
Definition list.hpp:697
typename xtd::collections::generic::helpers::raw_array< value_type >::base_type base_type
Represents the list base type.
Definition list.hpp:88
const auto & items() const noexcept
Returns the underlying base type items.
Definition list.hpp:251
Provides the base class for a generic read-only collection.
Definition read_only_collection.hpp:38
Represents the value type of the collection.
Definition arranged_element_collection.hpp:44
Represents a collection of objects.
Definition arranged_element_collection.hpp:41
void capacity(size_type value)
Sets the total number of elements the internal data structure can hold without resizing.
Definition arranged_element_collection.hpp:201
virtual void on_item_added(size_t index, type_t &item)
Raises the xtd::forms::layout::arranged_element_collection::item_added event.
Definition arranged_element_collection.hpp:814
void clear() override
Removes all items from the xtd::forms::layout::arranged_element_collection <type_t>.
Definition arranged_element_collection.hpp:293
auto & items()
Returns the underlying base type items.
Definition arranged_element_collection.hpp:219
const auto & items() const
Definition arranged_element_collection.hpp:216
void emplace_back(args_t &&... args)
Adds an element to the end.
Definition arranged_element_collection.hpp:601
arranged_element_collection(std::initializer_list< type_t > items)
Constructs the container with the contents of the specified initializer list, and allocator.
Definition arranged_element_collection.hpp:178
arranged_element_collection(const base_type &collection)
Copy constructor with specified base type list.
Definition arranged_element_collection.hpp:172
xtd::string & reference
Definition arranged_element_collection.hpp:84
virtual arranged_element_collection & sorted(bool value)
Sets the container is sorted.
Definition arranged_element_collection.hpp:226
auto rend() noexcept
Returns a reverse iterator to the end.
Definition arranged_element_collection.hpp:789
const_reference front() const
Access the first element.
Definition arranged_element_collection.hpp:570
arranged_element_collection(const arranged_element_collection &collection)
Default copy constructor with specified list.
Definition arranged_element_collection.hpp:163
void push_back(const type_t &item)
Adds an element to the end.
Definition arranged_element_collection.hpp:719
virtual void insert(xtd::usize index, const type_t &value)
Inserts specified element at specified index.
Definition arranged_element_collection.hpp:352
virtual void add_range(const std::vector< type_t > &collection)
Adds elements to the end.
Definition arranged_element_collection.hpp:266
virtual arranged_element_collection & sort()
Sorts the content.
Definition arranged_element_collection.hpp:364
arranged_element_collection(base_type &&collection)
Move constructor with specified base type list.
Definition arranged_element_collection.hpp:175
auto get_allocator() const noexcept
Returns the associated allocator.
Definition arranged_element_collection.hpp:576
void copy_to(xtd::array< type_t > &array, xtd::usize array_index) const override
Copies the elements of the xtd::forms::layout::arranged_element_collection <type_t> to an xtd::array,...
Definition arranged_element_collection.hpp:309
size_type capacity() const noexcept
Definition arranged_element_collection.hpp:196
virtual void on_item_removed(size_t index, type_t &item)
Raises the xtd::forms::layout::arranged_element_collection::item_removed event.
Definition arranged_element_collection.hpp:824
arranged_element_collection(input_iterator_t first, input_iterator_t last)
Constructs the container with the contents of the range [first, last).
Definition arranged_element_collection.hpp:184
void insert_at(size_t index, const type_t &value)
Inserts specified element at specified index.
Definition arranged_element_collection.hpp:704
event< arranged_element_collection, delegate< void(size_t, xtd::string &item)> > item_updated
Definition arranged_element_collection.hpp:491
auto insert(xtd::collections::generic::list< value_type >::const_iterator pos, type_t &&value)
Inserts specified element at specified position.
Definition arranged_element_collection.hpp:687
void push_back_range(const std::vector< type_t > &collection)
Adds elements to the end.
Definition arranged_element_collection.hpp:741
bool contains(const type_t &item) const noexcept override
Determines whether the xtd::forms::layout::arranged_element_collection <type_t> contains a specific v...
Definition arranged_element_collection.hpp:301
void add_range(collection_t &&collection)
Adds elements to the end.
Definition arranged_element_collection.hpp:279
const xtd::string & const_reference
Definition arranged_element_collection.hpp:86
void push_back(type_t &&item)
Adds an element to the end.
Definition arranged_element_collection.hpp:726
void pop_back()
Removes the last element of the container.
Definition arranged_element_collection.hpp:711
auto erase(xtd::collections::generic::list< value_type >::const_iterator pos)
Erases element at specified position.
Definition arranged_element_collection.hpp:625
auto rbegin() noexcept
Returns a reverse iterator to the end.
Definition arranged_element_collection.hpp:778
static constexpr xtd::usize bpos
Definition arranged_element_collection.hpp:116
void push_back_range(collection_t &&collection)
Adds elements to the end.
Definition arranged_element_collection.hpp:756
const_reverse_iterator crend() const noexcept
Returns a reverse iterator to the end.
Definition arranged_element_collection.hpp:559
xtd::usize size_type
Definition arranged_element_collection.hpp:82
void add(const type_t &item) override
Adds an item to the xtd::forms::layout::arranged_element_collection <type_t>.
Definition arranged_element_collection.hpp:239
arranged_element_collection()=default
Initializes a new instance of the xtd::forms::layout::arranged_element_collection class that is empty...
auto erase(xtd::collections::generic::list< value_type >::const_iterator first, xtd::collections::generic::list< value_type >::const_iterator last)
Erases elements at specified range.
Definition arranged_element_collection.hpp:650
auto reverse() -> arranged_element_collection &
Reverses the order of the elements in the entire xtd::collections::generic::list <type_t>.
Definition arranged_element_collection.hpp:401
virtual void add_range(const std::initializer_list< type_t > &collection)
Adds elements to the end.
Definition arranged_element_collection.hpp:272
static constexpr xtd::usize npos
Definition arranged_element_collection.hpp:106
void push_back_range(const arranged_element_collection &collection)
Adds elements to the end.
Definition arranged_element_collection.hpp:734
bool remove(const type_t &item) override
Removes the first occurrence of a specific object from the xtd::forms::layout::arranged_element_colle...
Definition arranged_element_collection.hpp:375
value_type & operator[](size_type index)
Access specified element.
Definition arranged_element_collection.hpp:455
reference back()
Access the last element.
Definition arranged_element_collection.hpp:543
virtual void remove_at(size_t index)
Erases element at specified index.
Definition arranged_element_collection.hpp:387
pointer data()
Direct access to the underlying array.
Definition arranged_element_collection.hpp:209
void shrink_to_fit()
Reduces memory usage by freeing unused memory.
Definition arranged_element_collection.hpp:804
xtd::array< type_t > to_array() const noexcept
Gets an array with the elements of the container.
Definition arranged_element_collection.hpp:419
reference front()
Access the first element.
Definition arranged_element_collection.hpp:565
auto rbegin() const noexcept
Returns a reverse iterator to the end.
Definition arranged_element_collection.hpp:783
auto rend() const noexcept
Returns a reverse iterator to the end.
Definition arranged_element_collection.hpp:794
xtd::collections::generic::enumerator< type_t > get_enumerator() const noexcept override
Returns an enumerator that iterates through the xtd::forms::layout::arranged_element_collection <type...
Definition arranged_element_collection.hpp:320
auto reverse(size_type index, size_type count) -> arranged_element_collection &
Reverses the order of the elements in the specified range.
Definition arranged_element_collection.hpp:411
void emplace(xtd::collections::generic::list< value_type >::const_iterator pos, args_t &&... args)
Inserts specified element at specified position.
Definition arranged_element_collection.hpp:584
auto insert(xtd::collections::generic::list< value_type >::const_iterator pos, const type_t &value)
Inserts specified element at specified position.
Definition arranged_element_collection.hpp:671
const base_type const_base_type
Definition arranged_element_collection.hpp:80
std::vector< type_t > to_vector() const noexcept
Gets an array with the elements of the container.
Definition arranged_element_collection.hpp:772
virtual void add_range(const arranged_element_collection &collection)
Adds elements to the end.
Definition arranged_element_collection.hpp:260
const_reverse_iterator crbegin() const noexcept
Returns a reverse iterator to the end.
Definition arranged_element_collection.hpp:554
const_reference back() const
Access the last element.
Definition arranged_element_collection.hpp:548
const_reference at(size_type pos) const
Access specified element with bounds checking.
Definition arranged_element_collection.hpp:537
static constexpr xtd::usize epos
Definition arranged_element_collection.hpp:134
arranged_element_collection(size_type capacity)
Constructs the container with specified count default-inserted instances of type_t....
Definition arranged_element_collection.hpp:151
auto erase(xtd::collections::generic::list< value_type >::iterator first, xtd::collections::generic::list< value_type >::iterator last)
Erases elements at specified range.
Definition arranged_element_collection.hpp:638
arranged_element_collection(arranged_element_collection &&collection)
Move constructor with specified list.
Definition arranged_element_collection.hpp:166
value_type * pointer
Definition arranged_element_collection.hpp:88
const value_type * const_pointer
Definition arranged_element_collection.hpp:90
virtual void add(type_t &&item)
Adds an item to the xtd::forms::layout::arranged_element_collection <type_t>.
Definition arranged_element_collection.hpp:249
void erase_at(size_t index)
Erases element at specified index.
Definition arranged_element_collection.hpp:662
const_pointer data() const
Direct access to the underlying array.
Definition arranged_element_collection.hpp:212
xtd::collections::object_model::read_only_collection< value_type > read_only_collection
Definition arranged_element_collection.hpp:92
void reserve(size_type size)
Reserves storage.
Definition arranged_element_collection.hpp:799
event< arranged_element_collection, delegate< void(size_t, xtd::string &item)> > item_removed
Definition arranged_element_collection.hpp:495
void push_back_range(iterator_t begin, iterator_t end)
Adds elements to the end.
Definition arranged_element_collection.hpp:764
size_type max_size() const noexcept
Returns the maximum possible number of elements.
Definition arranged_element_collection.hpp:516
arranged_element_collection(const xtd::collections::generic::ienumerable< type_t > &collection)
Initializes a new instance of the xtd::forms::layout::arranged_element_collection <type_t> class that...
Definition arranged_element_collection.hpp:159
arranged_element_collection & operator=(const arranged_element_collection &other)
Copy assignment operator. Replaces the contents with a copy of the contents of other.
Definition arranged_element_collection.hpp:430
void push_back_range(const std::initializer_list< type_t > &collection)
Adds elements to the end.
Definition arranged_element_collection.hpp:748
virtual void on_item_updated(size_t index, type_t &item)
Raises the xtd::forms::layout::arranged_element_collection::item_updated event.
Definition arranged_element_collection.hpp:819
typename xtd::collections::generic::list< value_type >::base_type base_type
Definition arranged_element_collection.hpp:78
void add_range(const collection_t &collection)
Adds elements to the end.
Definition arranged_element_collection.hpp:286
reference at(size_type pos)
Access specified element with bounds checking.
Definition arranged_element_collection.hpp:527
size_type count() const noexcept override
Gets the number of elements contained in the xtd::forms::layout::arranged_element_collection <type_t>...
Definition arranged_element_collection.hpp:205
virtual bool sorted() const noexcept
Checks whether the container is sorted.
Definition arranged_element_collection.hpp:223
event< arranged_element_collection, delegate< void(size_t, xtd::string &item)> > item_added
Definition arranged_element_collection.hpp:487
auto erase(xtd::collections::generic::list< value_type >::iterator pos)
Erases element at specified position.
Definition arranged_element_collection.hpp:614
static auto throws(xtd::helpers::exception_case exception_case, const source_location &location=source_location::current()) -> void
Throws an exption with specified exception case.
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.hpp:45
object()=default
Create a new instance of the ultimate base class object.
Represents the version number of an assembly, operating system, or the xtd. This class cannot be inhe...
Definition version.hpp:115
@ index_out_of_range
The index is out of range.
Definition exception_case.hpp:61
@ argument_out_of_range
The argument is out of range.
Definition exception_case.hpp:35
@ invalid_operation
The operation is not valid.
Definition exception_case.hpp:65
#define self_
The self_ expression is a reference value expression whose value is the reference of the implicit obj...
Definition self.hpp:20
constexpr xtd::usize npos
Represents a value that is not a valid position in a collection.
Definition npos.hpp:26
xtd::sptr< type_t > ptr
The xtd::ptr object is a shared pointer.
Definition ptr.hpp:27
std::size_t usize
Represents an unsigned size of any object in bytes.
Definition usize.hpp:22
ptr< type_t > new_ptr(args_t &&... args)
The xtd::new_ptr operator creates a xtd::ptr object.
Definition new_ptr.hpp:24
@ other
The operating system is other.
Definition platform_id.hpp:60
@ i
The I key.
Definition keys.hpp:215
The xtd::forms::layout namespace contains classes for implementing layout behaviors in your form or c...
Definition arranged_element_collection.hpp:25
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition texts.hpp:219
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8
const xtd::collections::generic::helpers::wrap_pointer_iterator< pointer > iterator
Represents the iterator of read_only_span value type.
Definition read_only_span.hpp:74
const_iterator begin() const
Returns an iterator to the beginning.
Definition read_only_span.hpp:183
read_only_span< type_t, count > first() const
Obtains a subspan consisting of the first count elements of the sequence.
Definition read_only_span.hpp:282
const std::reverse_iterator< xtd::collections::generic::helpers::wrap_pointer_iterator< pointer > > reverse_iterator
Represents the reverse iterator of read_only_span value type.
Definition read_only_span.hpp:78
const_iterator end() const
Returns an iterator to the end.
Definition read_only_span.hpp:213
read_only_span< type_t, count > last() const
Obtains a subspan consisting of the last N elements of the sequence.
Definition read_only_span.hpp:307
const std::reverse_iterator< xtd::collections::generic::helpers::wrap_pointer_iterator< pointer > > const_reverse_iterator
Represents the const reverse iterator of read_only_span value type.
Definition read_only_span.hpp:80
constexpr size_type size() const noexcept
Returns the number of elements.
Definition read_only_span.hpp:241
std::add_cv_t< type_t > value_type
Represents the read_only_span value type.
Definition read_only_span.hpp:60
Contains xtd::forms::layout::sorter_none class.
Supports a simple iteration over a generic collection.
Definition enumerator.hpp:38
Implements a function object for performing comparisons. Unless specialised, invokes operator== on ty...
Definition equator.hpp:39
Contains xtd::helpers::throw_helper class.