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/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>
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;
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;
108
110
132
135 arranged_element_collection(const arranged_element_collection& collection) {*data_ = *collection.data_;}
139 data_ = std::move(collection.data_);
140 collection.data_ = new_ptr<data_collection>();
141 }
142
144 arranged_element_collection(const base_type& collection) {data_->items = collection;}
147 arranged_element_collection(base_type&& collection) {data_->items = std::move(collection);}
150 arranged_element_collection(std::initializer_list<type_t> items) {add_range(items);}
155 template <std::input_iterator input_iterator_t>
156 arranged_element_collection(input_iterator_t first, input_iterator_t last) {
157 for (auto iterator = first; iterator != last; ++iterator)
158 add(*iterator);
159 }
160
161
163
168 [[nodiscard]] auto capacity() const noexcept -> size_type {return data_->items.capacity();}
173 auto capacity(size_type value) -> void {data_->items.capacity(value);}
174
177 [[nodiscard]] auto count() const noexcept -> size_type override {return data_->items.count();}
178
181 [[nodiscard]] auto data() -> pointer {return data_->items.data();}
184 [[nodiscard]] auto data() const -> const_pointer {return data_->items.data();}
185
188 [[nodiscard]] const auto& items() const {return data_->items.items();}
191 [[nodiscard]] auto& items() {return data_->items.items();}
192
195 [[nodiscard]] virtual auto sorted() const noexcept -> bool {return data_->sorted;}
198 virtual auto sorted(bool value) -> arranged_element_collection& {
199 if (data_->sorted == value) return self_;
200 data_->sorted = value;
201 if (data_->sorted) sort();
202 return self_;
203 }
204
205
207
211 auto add(const type_t& item) -> void override {
212 data_->items.add(item);
213 xtd::usize index = data_->items.count() - 1;
214 static_cast<value_type&>(self_[index]).owner = this;
215 static_cast<value_type&>(self_[index]).pos = index;
216 on_item_added(index, data_->items[index]);
217 if (data_->sorted) sort();
218 }
219
221 virtual auto add(type_t&& item) -> void {
222 data_->items.add(item);
223 xtd::usize index = data_->items.count() - 1;
224 static_cast<value_type&>(self_[index]).owner = this;
225 static_cast<value_type&>(self_[index]).pos = index;
226 on_item_added(index, data_->items[index]);
227 if (data_->sorted) sort();
228 }
229
232 virtual auto add_range(const arranged_element_collection& collection) -> void {
233 for (const auto& item : collection)
234 add(item);
235 }
236
238 virtual auto add_range(const std::vector<type_t>& collection) -> void {
239 for (const auto& item : collection)
240 add(item);
241 }
242
244 virtual auto add_range(const std::initializer_list<type_t>& collection) -> void {
245 for (const auto& item : collection)
246 add(item);
247 }
248
250 template<typename collection_t>
251 auto add_range(collection_t&& collection) -> void {
252 for (auto& item : collection)
253 add(value_type(item));
254 }
255
257 template<typename collection_t>
258 auto add_range(const collection_t& collection) -> void {
259 for (const auto& item : collection)
260 add(item);
261 }
262
265 auto clear() -> void override {
266 while (count())
267 remove_at(0);
268 }
269
273 [[nodiscard]] auto contains(const type_t& item) const noexcept -> bool override {
274 return data_->items.contains(item);
275 }
276
281 auto copy_to(xtd::array<type_t>& array, xtd::usize array_index) const -> void override {
283 auto i = size_type {0};
284 for (const type_t& item : self_) {
285 if (i >= count()) return;
286 array[array_index + i++] = item;
287 }
288 }
289
292 [[nodiscard]] auto get_enumerator() const noexcept -> xtd::collections::generic::enumerator<type_t> override {
293 struct arranged_element_collection_enumerator : public xtd::collections::generic::ienumerator<type_t> {
294 explicit arranged_element_collection_enumerator(const arranged_element_collection& items, xtd::usize version) : items_(items), version_(version) {}
295
296 const type_t& current() const override {
298 if (version_ != items_.items().version()) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::invalid_operation, "Collection was modified; enumeration operation may not execute.");
299 return items_[index_];
300 }
301
302 bool move_next() override {
303 if (version_ != items_.items().version()) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::invalid_operation, "Collection was modified; enumeration operation may not execute.");
304 return ++index_ < items_.count();
305 }
306
307 void reset() override {
308 version_ = items_.items().version();
310 }
311
312 private:
314 const arranged_element_collection& items_;
315 size_type version_ = 0;
316 };
317
319 }
320
324 virtual auto insert(xtd::usize index, const type_t& value) -> void {
326 data_->inserting = true;
327 items().insert(items().begin() + index, value);
328 data_->inserting = false;
329 static_cast<value_type&>(self_[index]).owner = this;
330 static_cast<value_type&>(self_[index]).pos = index;
331 on_item_added(index, data_->items[index]);
332 if (data_->sorted) sort();
333 }
334
337 sorter_t sorter;
338 sorter(items().begin(), items().end());
339 return self_;
340 }
341
347 auto remove(const type_t& item) -> bool override {
348 if (count() == 0) return false;
349 for (auto index = size_type {0}; index < count(); ++index) {
350 if (!xtd::collections::generic::helpers::equator<type_t> {}(self_[index], item)) continue;
351 remove_at(index);
352 return true;
353 }
354 return false;
355 }
356
359 virtual auto remove_at(xtd::usize index) -> void {
361 on_item_removed(index, const_cast<value_type&>(data_->items[index]));
362 data_->erasing = true;
363 items().erase(items().begin() + index);
364 data_->erasing = false;
365 }
366
384 data_->items.reverse(index, count);
385 return self_;
386 }
387
388
391 [[nodiscard]] auto to_array() const noexcept -> xtd::array<type_t> {
392 return data_->items.count() ? xtd::array<type_t>(data_->items.begin(), data_->items.end()) : xtd::array<type_t> {};
393 }
394
395
397
407
411 clear();
412 add_range(std::move(other.data_->items));
413 return self_;
414 }
415
418 auto operator =(const std::initializer_list<type_t>& items) -> arranged_element_collection& {
419 clear();
421 return self_;
422 }
423
427 [[nodiscard]] auto operator [](size_type index) -> value_type& {
429 data_->items[index].pos = index > npos / 2 ? count() - (npos - index) : index;
430 data_->items[index].owner = this;
431 return data_->items[index];
432 }
433
436 [[nodiscard]] auto operator [](size_type index) const -> const value_type& {
438 data_->items[index].pos = index > npos / 2 ? count() - (npos - index) : index;
439 data_->items[index].owner = const_cast<arranged_element_collection*>(this);
440 return data_->items[index];
441 }
442
445 [[nodiscard]] operator const_base_type& () const noexcept {return items();}
448 [[nodiscard]] operator base_type& () noexcept {return items();}
449
450 [[nodiscard]] auto operator ==(const arranged_element_collection& value) const -> bool {return data_->items == value.data_->items;}
451 [[nodiscard]] auto operator !=(const arranged_element_collection& value) const -> bool {return !operator ==(value);}
453
455
459 event<arranged_element_collection, delegate<void(xtd::usize, type_t& item)>> item_added;
460
463 event<arranged_element_collection, delegate<void(xtd::usize, type_t& item)>> item_updated;
464
467 event<arranged_element_collection, delegate<void(xtd::usize, type_t& item)>> item_removed;
469
471
475 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;
478 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;
480
482
487 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::items().max_size - Will be removed in version 1.2.0.")]]
488 [[nodiscard]] auto max_size() const noexcept -> size_type {return data_->items.max_size();}
490
492
498 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::operator [] - Will be removed in version 1.2.0.")]]
499 [[nodiscard]] auto at(size_type pos) -> reference {
500 data_->items[pos].pos = pos;
501 data_->items[pos].owner = this;
502 return data_->items.at(pos);
503 }
504
508 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::operator [] - Will be removed in version 1.2.0.")]]
509 [[nodiscard]] auto at(size_type pos) const -> const_reference {return data_->items.at(pos);}
510
514 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::operator [~1_i] - Will be removed in version 1.2.0.")]]
515 [[nodiscard]] auto back() -> reference {return data_->items.back();}
519 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::operator [~1_i] - Will be removed in version 1.2.0.")]]
520 [[nodiscard]] auto back() const -> const_reference {return data_->items.back();}
521
525 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::items().crbegin - Will be removed in version 1.2.0.")]]
526 [[nodiscard]] auto crbegin() const noexcept -> const_reverse_iterator {return data_->items.crbegin();}
530 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::items().crend - Will be removed in version 1.2.0.")]]
531 [[nodiscard]] auto crend() const noexcept -> const_reverse_iterator {return data_->items.crend();}
532
536 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::operator [0] - Will be removed in version 1.2.0.")]]
537 [[nodiscard]] auto front() -> reference {return data_->items.front();}
541 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::operator [0] - Will be removed in version 1.2.0.")]]
542 [[nodiscard]] auto front() const -> const_reference {return data_->items.front();}
543
547 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::items().get_allocator - Will be removed in version 1.2.0.")]]
548 [[nodiscard]] auto get_allocator() const noexcept {return data_->items.get_allocator();}
549
554 template<typename ...args_t>
555 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::insert - Will be removed in version 1.2.0.")]]
557 auto index = pos - items().begin();
558 data_->inserting = true;
559 auto result = data_->items.insert(pos, args...);
560 data_->inserting = false;
561 self_[index].owner = this;
562 self_[index].pos = index;
563 on_item_added(index, data_->items[index]);
564 if (data_->sorted) sort();
565 return result;
566 }
567
571 template<typename ...args_t>
572 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::add - Will be removed in version 1.2.0.")]]
573 auto emplace_back(args_t&& ... args) -> void {
574 data_->items.emplace_back(args...);
575 xtd::usize index = data_->items.count() - 1;
576 self_[index].owner = this;
577 self_[index].pos = index;
578 on_item_added(index, data_->items[index]);
579 if (data_->sorted) sort();
580 }
581
585 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::remove_at - Will be removed in version 1.2.0.")]]
587 on_item_removed(pos - items().begin(), *pos);
588 data_->erasing = true;
589 auto result = items().erase(pos);
590 data_->erasing = false;
591 return result;
592 }
593
596 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::remove_at - Will be removed in version 1.2.0.")]]
598 on_item_removed(pos - items().begin(), const_cast<value_type&>(*pos));
599 data_->erasing = true;
600 auto result = items().erase(pos);
601 data_->erasing = false;
602 return result;
603 }
604
609 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::remove_at - Will be removed in version 1.2.0.")]]
611 auto result = items().end();
612 auto index = first - items().begin();
613 for (auto it = first; it <= last; ++it)
614 remove_at(index++);
615 return result;
616 }
617
621 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::remove_at - Will be removed in version 1.2.0.")]]
623 auto result = items().end();
624 auto index = first - items().begin();
625 for (auto it = first; it <= last; ++it)
626 remove_at(index++);
627 return result;
628 }
629
633 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::remove_at - Will be removed in version 1.2.0.")]]
634 auto erase_at(xtd::usize index) -> void {
635 remove_at(index);
636 }
637
642 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::insert - Will be removed in version 1.2.0.")]]
644 auto index = pos - items().begin();
645 data_->inserting = true;
646 auto result = items().insert(pos, value);
647 data_->inserting = false;
648 self_[index].owner = this;
649 self_[index].pos = index;
650 on_item_added(index, data_->items[index]);
651 if (data_->sorted) sort();
652 return result;
653 }
654
658 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::insert - Will be removed in version 1.2.0.")]]
660 auto index = pos - items().begin();
661 data_->inserting = true;
662 auto result = items().insert(pos, value);
663 data_->inserting = false;
664 self_[index].owner = this;
665 self_[index].pos = index;
666 on_item_added(index, data_->items[index]);
667 if (data_->sorted) sort();
668 return result;
669 }
670
675 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::insert - Will be removed in version 1.2.0.")]]
676 auto insert_at(xtd::usize index, const type_t& value) -> void {
677 insert(index, value);
678 }
679
682 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::remove(count() - 1) - Will be removed in version 1.2.0.")]]
683 auto pop_back() -> void {
684 if (count() != 0) remove_at(count() - 1);
685 }
686
690 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::add - Will be removed in version 1.2.0.")]]
691 auto push_back(const type_t& item) -> void {
692 add(item);
693 }
694
697 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::add - Will be removed in version 1.2.0.")]]
698 auto push_back(type_t&& item) -> void {
699 add(std::move(item));
700 }
701
705 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::add_range - Will be removed in version 1.2.0.")]]
706 auto push_back_range(const arranged_element_collection& collection) -> void {
707 add_range(collection);
708 }
709
712 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::add_range - Will be removed in version 1.2.0.")]]
713 auto push_back_range(const std::vector<type_t>& collection) -> void {
714 add_range(collection);
715 }
716
719 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::add_range - Will be removed in version 1.2.0.")]]
720 auto push_back_range(const std::initializer_list<type_t>& collection) -> void {
721 add_range(collection);
722 }
723
726 template<typename collection_t>
727 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::add_range - Will be removed in version 1.2.0.")]]
728 auto push_back_range(collection_t&& collection) -> void {
729 add_range(collection);
730 }
731
734 template<typename iterator_t>
735 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::add_range - Will be removed in version 1.2.0.")]]
736 auto push_back_range(iterator_t begin, iterator_t end) -> void {
738 }
739
743 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::to_array - Will be removed in version 1.2.0.")]]
744 [[nodiscard]] auto to_vector() const noexcept -> std::vector<type_t> {return to_array();}
745
749 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::items().rbegin - Will be removed in version 1.2.0.")]]
750 [[nodiscard]] auto rbegin() noexcept {return data_->items.rbegin();}
754 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::items().rbegin - Will be removed in version 1.2.0.")]]
755 [[nodiscard]] auto rbegin() const noexcept {return data_->items.rbegin();}
756
760 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::items().rend - Will be removed in version 1.2.0.")]]
761 [[nodiscard]] auto rend() noexcept {return data_->items.rend();}
765 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::items().rend - Will be removed in version 1.2.0.")]]
766 [[nodiscard]] auto rend() const noexcept {return data_->items.rend();}
767
770 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::items().reserve - Will be removed in version 1.2.0.")]]
771 auto reserve(size_type size) -> void {data_->items.reserve(size);}
772
775 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::items().shrink_to_fit - Will be removed in version 1.2.0.")]]
776 auto shrink_to_fit() -> void {data_->items.shrink_to_fit();}
778
779 protected:
781
786 virtual auto on_item_added(xtd::usize index, type_t& item) -> void {item_added(index, item);}
787
791 virtual auto on_item_updated(xtd::usize index, type_t& item) -> void {item_updated(index, item);}
792
796 virtual auto on_item_removed(xtd::usize index, type_t& item) -> void {item_removed(index, item);}
798
799 private:
800 [[nodiscard]] auto is_read_only() const noexcept -> bool override {return false;}
801 [[nodiscard]] auto is_synchronized() const noexcept -> bool override {return false;}
802 [[nodiscard]] auto sync_root() const noexcept -> const xtd::object& override {return data_->sync_root;}
803
804 struct data_collection {
805 mutable xtd::collections::generic::list < value_type > items;
806 bool inserting = false;
807 bool erasing = false;
808 bool sorted = false;
810 };
812 };
813 }
814 }
815}
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:82
typename xtd::collections::generic::helpers::raw_array< value_type >::base_type base_type
Represents the list base type.
Definition list.hpp:90
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:44
Represents a collection of objects.
Definition arranged_element_collection.hpp:41
auto clear() -> void override
Removes all items from the xtd::forms::layout::arranged_element_collection <type_t>.
Definition arranged_element_collection.hpp:265
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:347
auto & items()
Returns the underlying base type items.
Definition arranged_element_collection.hpp:191
const auto & items() const
Definition arranged_element_collection.hpp:188
virtual auto remove_at(xtd::usize index) -> void
Erases element at specified index.
Definition arranged_element_collection.hpp:359
auto crbegin() const noexcept -> const_reverse_iterator
Returns a reverse iterator to the end.
Definition arranged_element_collection.hpp:526
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:150
virtual auto sort() -> arranged_element_collection &
Sorts the content.
Definition arranged_element_collection.hpp:336
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:144
xtd::string & reference
Definition arranged_element_collection.hpp:84
auto shrink_to_fit() -> void
Reduces memory usage by freeing unused memory.
Definition arranged_element_collection.hpp:776
auto back() const -> const_reference
Access the last element.
Definition arranged_element_collection.hpp:520
auto rend() noexcept
Returns a reverse iterator to the end.
Definition arranged_element_collection.hpp:761
auto push_back_range(const std::initializer_list< type_t > &collection) -> void
Adds elements to the end.
Definition arranged_element_collection.hpp:720
arranged_element_collection(const arranged_element_collection &collection)
Default copy constructor with specified list.
Definition arranged_element_collection.hpp:135
auto push_back_range(iterator_t begin, iterator_t end) -> void
Adds elements to the end.
Definition arranged_element_collection.hpp:736
arranged_element_collection(base_type &&collection)
Move constructor with specified base type list.
Definition arranged_element_collection.hpp:147
auto get_allocator() const noexcept
Returns the associated allocator.
Definition arranged_element_collection.hpp:548
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:796
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:292
auto data() -> pointer
Direct access to the underlying array.
Definition arranged_element_collection.hpp:181
auto crend() const noexcept -> const_reverse_iterator
Returns a reverse iterator to the end.
Definition arranged_element_collection.hpp:531
auto pop_back() -> void
Removes the last element of the container.
Definition arranged_element_collection.hpp:683
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:156
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:402
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:211
auto push_back(const type_t &item) -> void
Adds an element to the end.
Definition arranged_element_collection.hpp:691
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:659
auto to_array() const noexcept -> xtd::array< type_t >
Gets an array with the elements of the container.
Definition arranged_element_collection.hpp:391
auto at(size_type pos) -> reference
Access specified element with bounds checking.
Definition arranged_element_collection.hpp:499
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:556
const xtd::string & const_reference
Definition arranged_element_collection.hpp:86
auto erase(xtd::collections::generic::list< value_type >::const_iterator pos)
Erases element at specified position.
Definition arranged_element_collection.hpp:597
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:173
auto rbegin() noexcept
Returns a reverse iterator to the end.
Definition arranged_element_collection.hpp:750
auto front() -> reference
Access the first element.
Definition arranged_element_collection.hpp:537
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:281
xtd::usize size_type
Definition arranged_element_collection.hpp:82
auto push_back_range(const std::vector< type_t > &collection) -> void
Adds elements to the end.
Definition arranged_element_collection.hpp:713
auto push_back_range(collection_t &&collection) -> void
Adds elements to the end.
Definition arranged_element_collection.hpp:728
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:244
auto front() const -> const_reference
Access the first element.
Definition arranged_element_collection.hpp:542
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:622
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:373
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:221
static constexpr xtd::usize npos
Definition arranged_element_collection.hpp:106
virtual auto sorted(bool value) -> arranged_element_collection &
Sets the container is sorted.
Definition arranged_element_collection.hpp:198
auto add_range(const collection_t &collection) -> void
Adds elements to the end.
Definition arranged_element_collection.hpp:258
auto rbegin() const noexcept
Returns a reverse iterator to the end.
Definition arranged_element_collection.hpp:755
auto at(size_type pos) const -> const_reference
Access specified element with bounds checking.
Definition arranged_element_collection.hpp:509
auto push_back_range(const arranged_element_collection &collection) -> void
Adds elements to the end.
Definition arranged_element_collection.hpp:706
auto rend() const noexcept
Returns a reverse iterator to the end.
Definition arranged_element_collection.hpp:766
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:273
auto push_back(type_t &&item) -> void
Adds an element to the end.
Definition arranged_element_collection.hpp:698
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:383
auto operator[](size_type index) -> value_type &
Access specified element.
Definition arranged_element_collection.hpp:427
event< arranged_element_collection, delegate< void(xtd::usize, xtd::string &item)> > item_updated
Definition arranged_element_collection.hpp:463
virtual auto add_range(const std::vector< type_t > &collection) -> void
Adds elements to the end.
Definition arranged_element_collection.hpp:238
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:643
auto insert_at(xtd::usize index, const type_t &value) -> void
Inserts specified element at specified index.
Definition arranged_element_collection.hpp:676
const base_type const_base_type
Definition arranged_element_collection.hpp:80
arranged_element_collection(size_type capacity)
Constructs the container with specified count default-inserted instances of type_t....
Definition arranged_element_collection.hpp:123
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:610
arranged_element_collection(arranged_element_collection &&collection)
Move constructor with specified list.
Definition arranged_element_collection.hpp:138
value_type * pointer
Definition arranged_element_collection.hpp:88
auto emplace_back(args_t &&... args) -> void
Adds an element to the end.
Definition arranged_element_collection.hpp:573
const value_type * const_pointer
Definition arranged_element_collection.hpp:90
auto erase_at(xtd::usize index) -> void
Erases element at specified index.
Definition arranged_element_collection.hpp:634
xtd::collections::object_model::read_only_collection< value_type > read_only_collection
Definition arranged_element_collection.hpp:92
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:786
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:177
virtual auto insert(xtd::usize index, const type_t &value) -> void
Inserts specified element at specified index.
Definition arranged_element_collection.hpp:324
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:131
virtual auto add_range(const arranged_element_collection &collection) -> void
Adds elements to the end.
Definition arranged_element_collection.hpp:232
event< arranged_element_collection, delegate< void(xtd::usize, xtd::string &item)> > item_removed
Definition arranged_element_collection.hpp:467
event< arranged_element_collection, delegate< void(xtd::usize, xtd::string &item)> > item_added
Definition arranged_element_collection.hpp:459
auto capacity() const noexcept -> size_type
Definition arranged_element_collection.hpp:168
auto reserve(size_type size) -> void
Reserves storage.
Definition arranged_element_collection.hpp:771
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:791
auto back() -> reference
Access the last element.
Definition arranged_element_collection.hpp:515
typename xtd::collections::generic::list< value_type >::base_type base_type
Definition arranged_element_collection.hpp:78
auto to_vector() const noexcept -> std::vector< type_t >
Gets an array with the elements of the container.
Definition arranged_element_collection.hpp:744
auto data() const -> const_pointer
Direct access to the underlying array.
Definition arranged_element_collection.hpp:184
auto max_size() const noexcept -> size_type
Returns the maximum possible number of elements.
Definition arranged_element_collection.hpp:488
virtual auto sorted() const noexcept -> bool
Checks whether the container is sorted.
Definition arranged_element_collection.hpp:195
auto add_range(collection_t &&collection) -> void
Adds elements to the end.
Definition arranged_element_collection.hpp:251
auto erase(xtd::collections::generic::list< value_type >::iterator pos)
Erases element at specified position.
Definition arranged_element_collection.hpp:586
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 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: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
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:263
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:288
Contains xtd::forms::layout::sorter_none class.
Implements a function object for performing comparisons. Unless specialised, invokes operator== on ty...
Definition equator.hpp:39
Contains xtd::helpers::throw_helper class.