xtd 1.0.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/index>
17#include <xtd/object>
18#include <xtd/new_ptr>
19#include <xtd/range>
20#include <xtd/read_only_span>
21#include <xtd/span>
22#include <xtd/usize_object>
23
25namespace xtd {
27 namespace forms {
29 namespace layout {
44 template<typename type_t, typename sorter_t = sorter_none>
46 public:
48 class value_type : public type_t {
49 public:
51 value_type() = default;
52 value_type(const value_type&) = default;
53 value_type(value_type&&) = default;
54 template<typename ...args_t>
55 value_type(args_t&& ...args) : type_t(args...) {}
56 value_type& operator =(const value_type& value) {
57 if (value.owner) owner = value.owner;
58 if (owner != nullptr && !owner->data_->inserting && !owner->data_->erasing) owner->on_item_updated(pos, static_cast<type_t&>(const_cast<value_type&>(value)));
59 type_t::operator =(value);
60 return self_;
61 }
63 if (value.owner) owner = value.owner;
64 if (owner != nullptr && !owner->data_->inserting && !owner->data_->erasing) owner->on_item_updated(pos, static_cast<type_t&>(value));
65 type_t::operator =(value);
66 return self_;
67 }
68 operator type_t() {return self_;}
69 friend std::ostream& operator <<(std::ostream& os, const arranged_element_collection::value_type& value) {return os << static_cast<const type_t&>(value);}
71
72 private:
73 friend class arranged_element_collection;
75 arranged_element_collection* owner = nullptr;
76 };
77
79
88 using reference = type_t&;
90 using const_reference = const type_t&;
92 using pointer = value_type*;
94 using const_pointer = const value_type*;
98
100
110 inline static constexpr xtd::usize npos = xtd::npos;
112
114
136
139 arranged_element_collection(const arranged_element_collection& collection) {*data_ = *collection.data_;}
143 data_ = std::move(collection.data_);
144 collection.data_ = new_ptr<data_collection>();
145 }
146
148 arranged_element_collection(const base_type& collection) {data_->items = collection;}
151 arranged_element_collection(base_type&& collection) {data_->items = std::move(collection);}
154 arranged_element_collection(std::initializer_list<type_t> items) {add_range(items);}
159 template <std::input_iterator input_iterator_t>
160 arranged_element_collection(input_iterator_t first, input_iterator_t last) {
161 for (auto iterator = first; iterator != last; ++iterator)
162 add(*iterator);
163 }
164
165
167
172 [[nodiscard]] auto capacity() const noexcept -> size_type {return data_->items.capacity();}
177 auto capacity(size_type value) -> void {data_->items.capacity(value);}
178
181 [[nodiscard]] auto count() const noexcept -> size_type override {return data_->items.count();}
182
185 [[nodiscard]] auto data() -> pointer {return data_->items.data();}
188 [[nodiscard]] auto data() const -> const_pointer {return data_->items.data();}
189
192 [[nodiscard]] const auto& items() const {return data_->items.items();}
195 [[nodiscard]] auto& items() {return data_->items.items();}
196
199 [[nodiscard]] virtual auto sorted() const noexcept -> bool {return data_->sorted;}
202 virtual auto sorted(bool value) -> arranged_element_collection& {
203 if (data_->sorted == value) return self_;
204 data_->sorted = value;
205 if (data_->sorted) sort();
206 return self_;
207 }
208
209
211
215 auto add(const type_t& item) -> void override {
216 data_->items.add(item);
217 xtd::usize index = data_->items.count() - 1;
218 static_cast<value_type&>(self_[index]).owner = this;
219 static_cast<value_type&>(self_[index]).pos = index;
220 on_item_added(index, data_->items[index]);
221 if (data_->sorted) sort();
222 }
223
225 virtual auto add(type_t&& item) -> void {
226 data_->items.add(item);
227 xtd::usize index = data_->items.count() - 1;
228 static_cast<value_type&>(self_[index]).owner = this;
229 static_cast<value_type&>(self_[index]).pos = index;
230 on_item_added(index, data_->items[index]);
231 if (data_->sorted) sort();
232 }
233
236 virtual auto add_range(const arranged_element_collection& collection) -> void {
237 for (const auto& item : collection)
238 add(item);
239 }
240
242 virtual auto add_range(const std::vector<type_t>& collection) -> void {
243 for (const auto& item : collection)
244 add(item);
245 }
246
248 virtual auto add_range(const std::initializer_list<type_t>& collection) -> void {
249 for (const auto& item : collection)
250 add(item);
251 }
252
254 template<typename collection_t>
255 auto add_range(collection_t&& collection) -> void {
256 for (auto& item : collection)
257 add(value_type(item));
258 }
259
261 template<typename collection_t>
262 auto add_range(const collection_t& collection) -> void {
263 for (const auto& item : collection)
264 add(item);
265 }
266
269 auto clear() -> void override {
270 while (count())
271 remove_at(0);
272 }
273
277 [[nodiscard]] auto contains(const type_t& item) const noexcept -> bool override {
278 return data_->items.contains(item);
279 }
280
285 auto copy_to(xtd::array<type_t>& array, xtd::usize array_index) const -> void override {
287 auto i = size_type {0};
288 for (const type_t& item : self_) {
289 if (i >= count()) return;
290 array[array_index + i++] = item;
291 }
292 }
293
296 [[nodiscard]] auto get_enumerator() const noexcept -> xtd::collections::generic::enumerator<type_t> override {
297 struct arranged_element_collection_enumerator : public xtd::collections::generic::ienumerator<type_t> {
298 explicit arranged_element_collection_enumerator(const arranged_element_collection& items, xtd::usize version) : items_(items), version_(version) {}
299
300 const type_t& current() const override {
302 if (version_ != items_.items().version()) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::invalid_operation, "Collection was modified; enumeration operation may not execute.");
303 return items_[index_];
304 }
305
306 bool move_next() override {
307 if (version_ != items_.items().version()) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::invalid_operation, "Collection was modified; enumeration operation may not execute.");
308 return ++index_ < items_.count();
309 }
310
311 void reset() override {
312 version_ = items_.items().version();
314 }
315
316 private:
318 const arranged_element_collection& items_;
319 size_type version_ = 0;
320 };
321
323 }
324
328 virtual auto insert(xtd::usize index, const type_t& value) -> void {
330 data_->inserting = true;
331 items().insert(items().begin() + index, value);
332 data_->inserting = false;
333 static_cast<value_type&>(self_[index]).owner = this;
334 static_cast<value_type&>(self_[index]).pos = index;
335 on_item_added(index, data_->items[index]);
336 if (data_->sorted) sort();
337 }
338
341 sorter_t sorter;
342 sorter(items().begin(), items().end());
343 return self_;
344 }
345
351 auto remove(const type_t& item) -> bool override {
352 if (count() == 0) return false;
353 for (auto index = size_type {0}; index < count(); ++index) {
356 return true;
357 }
358 return false;
359 }
360
363 virtual auto remove_at(xtd::usize index) -> void {
365 on_item_removed(index, const_cast<value_type&>(data_->items[index]));
366 data_->erasing = true;
367 items().erase(items().begin() + index);
368 data_->erasing = false;
369 }
370
388 data_->items.reverse(index, count);
389 return self_;
390 }
391
392
395 [[nodiscard]] auto to_array() const noexcept -> xtd::array<type_t> {
396 return data_->items.count() ? xtd::array<type_t>(data_->items.begin(), data_->items.end()) : xtd::array<type_t> {};
397 }
398
399
401
411
415 clear();
416 add_range(std::move(other.data_->items));
417 return self_;
418 }
419
422 auto operator =(const std::initializer_list<type_t>& items) -> arranged_element_collection& {
423 clear();
425 return self_;
426 }
427
431 [[nodiscard]] auto operator [](size_type index) -> value_type& {
433 data_->items[index].pos = index > npos / 2 ? count() - (npos - index) : index;
434 data_->items[index].owner = this;
435 return data_->items[index];
436 }
437
440 [[nodiscard]] auto operator [](size_type index) const -> const value_type& {
442 data_->items[index].pos = index > npos / 2 ? count() - (npos - index) : index;
443 data_->items[index].owner = const_cast<arranged_element_collection*>(this);
444 return data_->items[index];
445 }
446
449 [[nodiscard]] auto operator [](const xtd::index& index) -> value_type& {
451 }
452
455 [[nodiscard]] auto operator [](const xtd::index& index) const -> const value_type& {
457 }
458
464
468 return xtd::span<value_type> {*this, range};
469 }
470
474 [[nodiscard]] auto operator ()(size_type index) -> value_type& {
475 return operator [](index);
476 }
477
480 [[nodiscard]] auto operator ()(size_type index) const -> const value_type& {
481 return operator [](index);
482 }
483
486 [[nodiscard]] auto operator ()(const xtd::index& index) -> value_type& {
487 return operator [](index);
488 }
489
492 [[nodiscard]] auto operator ()(const xtd::index& index) const -> const value_type& {
493 return operator [](index);
494 }
495
501
505 return operator[](range);
506 }
507
510 [[nodiscard]] operator const_base_type& () const noexcept {return items();}
513 [[nodiscard]] operator base_type& () noexcept {return items();}
514
515 [[nodiscard]] auto operator ==(const arranged_element_collection& value) const -> bool {return data_->items == value.data_->items;}
516 [[nodiscard]] auto operator !=(const arranged_element_collection& value) const -> bool {return !operator ==(value);}
518
520
524 event<arranged_element_collection, delegate<void(xtd::usize, type_t& item)>> item_added;
525
528 event<arranged_element_collection, delegate<void(xtd::usize, type_t& item)>> item_updated;
529
532 event<arranged_element_collection, delegate<void(xtd::usize, type_t& item)>> item_removed;
534
536
540 using reverse_iterator [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::items::reverse_iterator - Will be removed in version 1.2.0.")]] = typename xtd::collections::generic::list<value_type>::base_type::reverse_iterator;
543 using const_reverse_iterator [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::items::const_reverse_iterator - Will be removed in version 1.2.0.")]] = typename xtd::collections::generic::list<value_type>::base_type::const_reverse_iterator;
545
547
552 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::items().max_size - Will be removed in version 1.2.0.")]]
553 [[nodiscard]] auto max_size() const noexcept -> size_type {return data_->items.max_size();}
555
557
563 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::operator [] - Will be removed in version 1.2.0.")]]
564 [[nodiscard]] auto at(size_type pos) -> reference {
565 data_->items[pos].pos = pos;
566 data_->items[pos].owner = this;
567 return data_->items.at(pos);
568 }
569
573 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::operator [] - Will be removed in version 1.2.0.")]]
574 [[nodiscard]] auto at(size_type pos) const -> const_reference {return data_->items.at(pos);}
575
579 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::operator [~1_i] - Will be removed in version 1.2.0.")]]
580 [[nodiscard]] auto back() -> reference {return data_->items.back();}
584 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::operator [~1_i] - Will be removed in version 1.2.0.")]]
585 [[nodiscard]] auto back() const -> const_reference {return data_->items.back();}
586
590 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::items().crbegin - Will be removed in version 1.2.0.")]]
591 [[nodiscard]] auto crbegin() const noexcept -> const_reverse_iterator {return data_->items.crbegin();}
595 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::items().crend - Will be removed in version 1.2.0.")]]
596 [[nodiscard]] auto crend() const noexcept -> const_reverse_iterator {return data_->items.crend();}
597
601 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::operator [0] - Will be removed in version 1.2.0.")]]
602 [[nodiscard]] auto front() -> reference {return data_->items.front();}
606 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::operator [0] - Will be removed in version 1.2.0.")]]
607 [[nodiscard]] auto front() const -> const_reference {return data_->items.front();}
608
612 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::items().get_allocator - Will be removed in version 1.2.0.")]]
613 [[nodiscard]] auto get_allocator() const noexcept {return data_->items.get_allocator();}
614
619 template<typename ...args_t>
620 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::insert - Will be removed in version 1.2.0.")]]
622 auto index = pos - items().begin();
623 data_->inserting = true;
624 auto result = data_->items.insert(pos, args...);
625 data_->inserting = false;
626 self_[index].owner = this;
627 self_[index].pos = index;
628 on_item_added(index, data_->items[index]);
629 if (data_->sorted) sort();
630 return result;
631 }
632
636 template<typename ...args_t>
637 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::add - Will be removed in version 1.2.0.")]]
638 auto emplace_back(args_t&& ... args) -> void {
639 data_->items.emplace_back(args...);
640 xtd::usize index = data_->items.count() - 1;
641 self_[index].owner = this;
642 self_[index].pos = index;
643 on_item_added(index, data_->items[index]);
644 if (data_->sorted) sort();
645 }
646
650 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::remove_at - Will be removed in version 1.2.0.")]]
652 on_item_removed(pos - items().begin(), *pos);
653 data_->erasing = true;
654 auto result = items().erase(pos);
655 data_->erasing = false;
656 return result;
657 }
658
661 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::remove_at - Will be removed in version 1.2.0.")]]
663 on_item_removed(pos - items().begin(), const_cast<value_type&>(*pos));
664 data_->erasing = true;
665 auto result = items().erase(pos);
666 data_->erasing = false;
667 return result;
668 }
669
674 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::remove_at - Will be removed in version 1.2.0.")]]
676 auto result = items().end();
677 auto index = first - items().begin();
678 for (auto it = first; it <= last; ++it)
679 remove_at(index++);
680 return result;
681 }
682
686 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::remove_at - Will be removed in version 1.2.0.")]]
688 auto result = items().end();
689 auto index = first - items().begin();
690 for (auto it = first; it <= last; ++it)
691 remove_at(index++);
692 return result;
693 }
694
698 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::remove_at - Will be removed in version 1.2.0.")]]
699 auto erase_at(xtd::usize index) -> void {
701 }
702
707 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::insert - Will be removed in version 1.2.0.")]]
709 auto index = pos - items().begin();
710 data_->inserting = true;
711 auto result = items().insert(pos, value);
712 data_->inserting = false;
713 self_[index].owner = this;
714 self_[index].pos = index;
715 on_item_added(index, data_->items[index]);
716 if (data_->sorted) sort();
717 return result;
718 }
719
723 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::insert - Will be removed in version 1.2.0.")]]
725 auto index = pos - items().begin();
726 data_->inserting = true;
727 auto result = items().insert(pos, value);
728 data_->inserting = false;
729 self_[index].owner = this;
730 self_[index].pos = index;
731 on_item_added(index, data_->items[index]);
732 if (data_->sorted) sort();
733 return result;
734 }
735
740 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::insert - Will be removed in version 1.2.0.")]]
741 auto insert_at(xtd::usize index, const type_t& value) -> void {
742 insert(index, value);
743 }
744
747 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::remove(count() - 1) - Will be removed in version 1.2.0.")]]
748 auto pop_back() -> void {
749 if (count() != 0) remove_at(count() - 1);
750 }
751
755 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::add - Will be removed in version 1.2.0.")]]
756 auto push_back(const type_t& item) -> void {
757 add(item);
758 }
759
762 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::add - Will be removed in version 1.2.0.")]]
763 auto push_back(type_t&& item) -> void {
764 add(std::move(item));
765 }
766
770 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::add_range - Will be removed in version 1.2.0.")]]
771 auto push_back_range(const arranged_element_collection& collection) -> void {
772 add_range(collection);
773 }
774
777 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::add_range - Will be removed in version 1.2.0.")]]
778 auto push_back_range(const std::vector<type_t>& collection) -> void {
779 add_range(collection);
780 }
781
784 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::add_range - Will be removed in version 1.2.0.")]]
785 auto push_back_range(const std::initializer_list<type_t>& collection) -> void {
786 add_range(collection);
787 }
788
791 template<typename collection_t>
792 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::add_range - Will be removed in version 1.2.0.")]]
793 auto push_back_range(collection_t&& collection) -> void {
794 add_range(collection);
795 }
796
799 template<typename iterator_t>
800 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::add_range - Will be removed in version 1.2.0.")]]
801 auto push_back_range(iterator_t begin, iterator_t end) -> void {
803 }
804
808 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::to_array - Will be removed in version 1.2.0.")]]
809 [[nodiscard]] auto to_vector() const noexcept -> std::vector<type_t> {return to_array();}
810
814 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::items().rbegin - Will be removed in version 1.2.0.")]]
815 [[nodiscard]] auto rbegin() noexcept {return data_->items.rbegin();}
819 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::items().rbegin - Will be removed in version 1.2.0.")]]
820 [[nodiscard]] auto rbegin() const noexcept {return data_->items.rbegin();}
821
825 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::items().rend - Will be removed in version 1.2.0.")]]
826 [[nodiscard]] auto rend() noexcept {return data_->items.rend();}
830 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::items().rend - Will be removed in version 1.2.0.")]]
831 [[nodiscard]] auto rend() const noexcept {return data_->items.rend();}
832
835 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::items().reserve - Will be removed in version 1.2.0.")]]
836 auto reserve(size_type size) -> void {data_->items.reserve(size);}
837
840 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::items().shrink_to_fit - Will be removed in version 1.2.0.")]]
841 auto shrink_to_fit() -> void {data_->items.shrink_to_fit();}
843
844 protected:
846
851 virtual auto on_item_added(xtd::usize index, type_t& item) -> void {item_added(index, item);}
852
856 virtual auto on_item_updated(xtd::usize index, type_t& item) -> void {item_updated(index, item);}
857
861 virtual auto on_item_removed(xtd::usize index, type_t& item) -> void {item_removed(index, item);}
863
864 private:
865 [[nodiscard]] auto is_read_only() const noexcept -> bool override {return false;}
866 [[nodiscard]] auto is_synchronized() const noexcept -> bool override {return false;}
867 [[nodiscard]] auto sync_root() const noexcept -> const xtd::object& override {return data_->sync_root;}
868
869 struct data_collection {
870 mutable xtd::collections::generic::list < value_type > items;
871 bool inserting = false;
872 bool erasing = false;
873 bool sorted = false;
875 };
877 };
878 }
879 }
880}
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
virtual auto size() const noexcept -> xtd::usize
Definition collection_common.hpp:43
virtual auto operator<<(const type_t &item) -> icollection< type_t > &
Definition collection_common.hpp:52
Defines methods to manipulate generic collections.
Definition icollection.hpp:45
virtual auto sync_root() const noexcept -> const xtd::object &=0
Gets an object that can be used to synchronize access to the the xtd::collections::generic::icollecti...
virtual auto clear() -> void=0
Removes all items from the xtd::collections::generic::icollection <type_t>.
virtual auto is_synchronized() const noexcept -> bool=0
Gets a value indicating whether access to the xtd::collections::generic::icollection <type_t> is sync...
virtual auto count() const noexcept -> xtd::usize=0
Gets the number of elements contained in the xtd::collections::generic::icollection <type_t>.
typename xtd::collections::generic::ienumerable< type_t >::value_type value_type
Represents the xtd::collections::generic::icollection value type.
Definition icollection.hpp:51
virtual auto is_read_only() const noexcept -> bool=0
Gets a value indicating whether the xtd::collections::generic::icollection <type_t> is read-only.
Exposes the enumerator, which supports a simple iteration over a collection of a specified type.
Definition ienumerable.hpp:40
typename xtd::collections::generic::extensions::enumerable_iterators< type_t, xtd::collections::generic::ienumerable< type_t > >::const_iterator const_iterator
Represents the const iterator of xtd::collections::generic::ienumerable value type.
Definition ienumerable.hpp:50
typename xtd::collections::generic::extensions::enumerable_iterators< type_t, xtd::collections::generic::ienumerable< type_t > >::iterator iterator
Represents the iterator of xtd::collections::generic::ienumerable value type.
Definition ienumerable.hpp:48
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:84
typename xtd::collections::generic::helpers::raw_array< value_type >::base_type base_type
Represents the list base type.
Definition list.hpp:92
Provides the base class for a generic read-only collection.
Definition read_only_collection.hpp:39
Represents the value type of the collection.
Definition arranged_element_collection.hpp:48
Represents a collection of objects.
Definition arranged_element_collection.hpp:45
auto clear() -> void override
Removes all items from the xtd::forms::layout::arranged_element_collection <type_t>.
Definition arranged_element_collection.hpp:269
auto remove(const type_t &item) -> bool override
Removes the first occurrence of a specific object from the xtd::forms::layout::arranged_element_colle...
Definition arranged_element_collection.hpp:351
auto & items()
Returns the underlying base type items.
Definition arranged_element_collection.hpp:195
const auto & items() const
Definition arranged_element_collection.hpp:192
virtual auto remove_at(xtd::usize index) -> void
Erases element at specified index.
Definition arranged_element_collection.hpp:363
auto crbegin() const noexcept -> const_reverse_iterator
Returns a reverse iterator to the end.
Definition arranged_element_collection.hpp:591
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:154
virtual auto sort() -> arranged_element_collection &
Sorts the content.
Definition arranged_element_collection.hpp:340
typename xtd::collections::generic::list< value_type >::base_type::reverse_iterator reverse_iterator
arranged_element_collection(const base_type &collection)
Copy constructor with specified base type list.
Definition arranged_element_collection.hpp:148
xtd::string & reference
Definition arranged_element_collection.hpp:88
auto shrink_to_fit() -> void
Reduces memory usage by freeing unused memory.
Definition arranged_element_collection.hpp:841
auto back() const -> const_reference
Access the last element.
Definition arranged_element_collection.hpp:585
auto rend() noexcept
Returns a reverse iterator to the end.
Definition arranged_element_collection.hpp:826
auto push_back_range(const std::initializer_list< type_t > &collection) -> void
Adds elements to the end.
Definition arranged_element_collection.hpp:785
arranged_element_collection(const arranged_element_collection &collection)
Default copy constructor with specified list.
Definition arranged_element_collection.hpp:139
auto push_back_range(iterator_t begin, iterator_t end) -> void
Adds elements to the end.
Definition arranged_element_collection.hpp:801
arranged_element_collection(base_type &&collection)
Move constructor with specified base type list.
Definition arranged_element_collection.hpp:151
auto get_allocator() const noexcept
Returns the associated allocator.
Definition arranged_element_collection.hpp:613
virtual auto on_item_removed(xtd::usize index, type_t &item) -> void
Raises the xtd::forms::layout::arranged_element_collection::item_removed event.
Definition arranged_element_collection.hpp:861
auto get_enumerator() const noexcept -> xtd::collections::generic::enumerator< type_t > override
Returns an enumerator that iterates through the xtd::forms::layout::arranged_element_collection <type...
Definition arranged_element_collection.hpp:296
auto data() -> pointer
Direct access to the underlying array.
Definition arranged_element_collection.hpp:185
auto crend() const noexcept -> const_reverse_iterator
Returns a reverse iterator to the end.
Definition arranged_element_collection.hpp:596
auto pop_back() -> void
Removes the last element of the container.
Definition arranged_element_collection.hpp:748
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:160
auto operator=(const arranged_element_collection &other) -> arranged_element_collection &
Copy assignment operator. Replaces the contents with a copy of the contents of other.
Definition arranged_element_collection.hpp:406
auto add(const type_t &item) -> void override
Adds an item to the xtd::forms::layout::arranged_element_collection <type_t>.
Definition arranged_element_collection.hpp:215
auto push_back(const type_t &item) -> void
Adds an element to the end.
Definition arranged_element_collection.hpp:756
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:724
auto to_array() const noexcept -> xtd::array< type_t >
Gets an array with the elements of the container.
Definition arranged_element_collection.hpp:395
auto at(size_type pos) -> reference
Access specified element with bounds checking.
Definition arranged_element_collection.hpp:564
auto emplace(xtd::collections::generic::list< value_type >::const_iterator pos, args_t &&... args) -> void
Inserts specified element at specified position.
Definition arranged_element_collection.hpp:621
const xtd::string & const_reference
Definition arranged_element_collection.hpp:90
auto erase(xtd::collections::generic::list< value_type >::const_iterator pos)
Erases element at specified position.
Definition arranged_element_collection.hpp:662
auto capacity(size_type value) -> void
Sets the total number of elements the internal data structure can hold without resizing.
Definition arranged_element_collection.hpp:177
auto rbegin() noexcept
Returns a reverse iterator to the end.
Definition arranged_element_collection.hpp:815
auto front() -> reference
Access the first element.
Definition arranged_element_collection.hpp:602
auto copy_to(xtd::array< type_t > &array, xtd::usize array_index) const -> void override
Copies the elements of the xtd::forms::layout::arranged_element_collection <type_t> to an xtd::array,...
Definition arranged_element_collection.hpp:285
xtd::usize size_type
Definition arranged_element_collection.hpp:86
auto push_back_range(const std::vector< type_t > &collection) -> void
Adds elements to the end.
Definition arranged_element_collection.hpp:778
auto push_back_range(collection_t &&collection) -> void
Adds elements to the end.
Definition arranged_element_collection.hpp:793
arranged_element_collection()=default
Initializes a new instance of the xtd::forms::layout::arranged_element_collection class that is empty...
virtual auto add_range(const std::initializer_list< type_t > &collection) -> void
Adds elements to the end.
Definition arranged_element_collection.hpp:248
auto front() const -> const_reference
Access the first element.
Definition arranged_element_collection.hpp:607
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:687
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:377
virtual auto add(type_t &&item) -> void
Adds an item to the xtd::forms::layout::arranged_element_collection <type_t>.
Definition arranged_element_collection.hpp:225
static constexpr xtd::usize npos
Definition arranged_element_collection.hpp:110
virtual auto sorted(bool value) -> arranged_element_collection &
Sets the container is sorted.
Definition arranged_element_collection.hpp:202
auto add_range(const collection_t &collection) -> void
Adds elements to the end.
Definition arranged_element_collection.hpp:262
auto rbegin() const noexcept
Returns a reverse iterator to the end.
Definition arranged_element_collection.hpp:820
auto at(size_type pos) const -> const_reference
Access specified element with bounds checking.
Definition arranged_element_collection.hpp:574
auto push_back_range(const arranged_element_collection &collection) -> void
Adds elements to the end.
Definition arranged_element_collection.hpp:771
auto rend() const noexcept
Returns a reverse iterator to the end.
Definition arranged_element_collection.hpp:831
auto contains(const type_t &item) const noexcept -> bool override
Determines whether the xtd::forms::layout::arranged_element_collection <type_t> contains a specific v...
Definition arranged_element_collection.hpp:277
auto push_back(type_t &&item) -> void
Adds an element to the end.
Definition arranged_element_collection.hpp:763
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:387
auto operator[](size_type index) -> value_type &
Access specified element.
Definition arranged_element_collection.hpp:431
event< arranged_element_collection, delegate< void(xtd::usize, xtd::string &item)> > item_updated
Definition arranged_element_collection.hpp:528
virtual auto add_range(const std::vector< type_t > &collection) -> void
Adds elements to the end.
Definition arranged_element_collection.hpp:242
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:708
auto insert_at(xtd::usize index, const type_t &value) -> void
Inserts specified element at specified index.
Definition arranged_element_collection.hpp:741
const base_type const_base_type
Definition arranged_element_collection.hpp:84
arranged_element_collection(size_type capacity)
Constructs the container with specified count default-inserted instances of type_t....
Definition arranged_element_collection.hpp:127
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:675
arranged_element_collection(arranged_element_collection &&collection)
Move constructor with specified list.
Definition arranged_element_collection.hpp:142
value_type * pointer
Definition arranged_element_collection.hpp:92
auto emplace_back(args_t &&... args) -> void
Adds an element to the end.
Definition arranged_element_collection.hpp:638
const value_type * const_pointer
Definition arranged_element_collection.hpp:94
auto erase_at(xtd::usize index) -> void
Erases element at specified index.
Definition arranged_element_collection.hpp:699
xtd::collections::object_model::read_only_collection< value_type > read_only_collection
Definition arranged_element_collection.hpp:96
virtual auto on_item_added(xtd::usize index, type_t &item) -> void
Raises the xtd::forms::layout::arranged_element_collection::item_added event.
Definition arranged_element_collection.hpp:851
auto operator()(size_type index) -> value_type &
Access specified element.
Definition arranged_element_collection.hpp:474
typename xtd::collections::generic::list< value_type >::base_type::const_reverse_iterator const_reverse_iterator
auto count() const noexcept -> size_type override
Gets the number of elements contained in the xtd::forms::layout::arranged_element_collection <type_t>...
Definition arranged_element_collection.hpp:181
virtual auto insert(xtd::usize index, const type_t &value) -> void
Inserts specified element at specified index.
Definition arranged_element_collection.hpp:328
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:135
virtual auto add_range(const arranged_element_collection &collection) -> void
Adds elements to the end.
Definition arranged_element_collection.hpp:236
event< arranged_element_collection, delegate< void(xtd::usize, xtd::string &item)> > item_removed
Definition arranged_element_collection.hpp:532
event< arranged_element_collection, delegate< void(xtd::usize, xtd::string &item)> > item_added
Definition arranged_element_collection.hpp:524
auto capacity() const noexcept -> size_type
Definition arranged_element_collection.hpp:172
auto reserve(size_type size) -> void
Reserves storage.
Definition arranged_element_collection.hpp:836
virtual auto on_item_updated(xtd::usize index, type_t &item) -> void
Raises the xtd::forms::layout::arranged_element_collection::item_updated event.
Definition arranged_element_collection.hpp:856
auto back() -> reference
Access the last element.
Definition arranged_element_collection.hpp:580
typename xtd::collections::generic::list< value_type >::base_type base_type
Definition arranged_element_collection.hpp:82
auto to_vector() const noexcept -> std::vector< type_t >
Gets an array with the elements of the container.
Definition arranged_element_collection.hpp:809
auto data() const -> const_pointer
Direct access to the underlying array.
Definition arranged_element_collection.hpp:188
auto max_size() const noexcept -> size_type
Returns the maximum possible number of elements.
Definition arranged_element_collection.hpp:553
virtual auto sorted() const noexcept -> bool
Checks whether the container is sorted.
Definition arranged_element_collection.hpp:199
auto add_range(collection_t &&collection) -> void
Adds elements to the end.
Definition arranged_element_collection.hpp:255
auto erase(xtd::collections::generic::list< value_type >::iterator pos)
Erases element at specified position.
Definition arranged_element_collection.hpp:651
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:40
object()=default
Create a new instance of the ultimate base class object.
Represents a range that has start and end indexes.
Definition range.hpp:38
Definition __span_definitions.hpp:16
Represents a non-owning view over a contiguous sequence of objects.
Definition span.hpp:62
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 auto 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
auto new_ptr(args_t &&... args) -> xtd::ptr< type_t >
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::collections namespace contains interfaces and classes that define various collections of obj...
Definition any_pair.hpp:10
The xtd::forms::layout namespace contains classes for implementing layout behaviors in your form or c...
Definition arranged_element_collection.hpp:29
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
auto first() const -> read_only_span< type_t, count >
Obtains a subspan consisting of the first count elements of the sequence.
Definition read_only_span.hpp:245
auto last() const -> read_only_span< type_t, count >
Obtains a subspan consisting of the last N elements of the sequence.
Definition read_only_span.hpp:286
Contains xtd::forms::layout::sorter_none class.
Implements a function object for performing comparisons. Unless specialised, invokes operator== on ty...
Definition equator.hpp:39
Represents a type that can be used to index a collection either from the beginning or the end.
Definition index.hpp:38
auto get_offset(value_type length) const noexcept -> xtd::usize
Calculates the offset from the start of the collection using the specified collection length.
Contains xtd::helpers::throw_helper class.