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/size_object>
19
21namespace xtd {
23 namespace forms {
25 namespace layout {
41 template<class type_t, class sorter_t = sorter_none>
42 class arranged_element_collection : public object, public xtd::collections::generic::icollection<type_t> {
43 struct __enumerator__ : public xtd::collections::generic::ienumerator<type_t> {
44 public:
45 explicit __enumerator__(const arranged_element_collection& items, xtd::size version) : items_(items), version_(version) {}
46
47 const type_t& current() const override {
48 if (version_ != items_.items().version()) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::invalid_operation, "Collection was modified; enumeration operation may not execute.");
49 if (index_ < items_.count()) return items_[index_];
50 return default_value_;
51 }
52
53 bool move_next() override {
54 if (version_ != items_.items().version()) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::invalid_operation, "Collection was modified; enumeration operation may not execute.");
55 return ++index_ < items_.count();
56 }
57
58 void reset() override {
59 version_ = items_.items().version();
61 }
62
63 protected:
64 const arranged_element_collection& items_;
66 xtd::size version_ = 0;
67 type_t default_value_;
68 };
69
70 public:
72 class value_type : public type_t {
73 public:
75 value_type() = default;
76 value_type(const value_type&) = default;
77 value_type(value_type&&) = default;
78 template<class ...args_t>
79 value_type(args_t&& ...args) : type_t(args...) {}
80 value_type& operator =(const value_type& value) {
81 if (value.owner) owner = value.owner;
82 if (owner != nullptr && !owner->data_->inserting && !owner->data_->erasing) owner->on_item_updated(pos, static_cast<type_t&>(const_cast<value_type&>(value)));
83 type_t::operator =(value);
84 return self_;
85 }
87 if (value.owner) owner = value.owner;
88 if (owner != nullptr && !owner->data_->inserting && !owner->data_->erasing) owner->on_item_updated(pos, static_cast<type_t&>(value));
89 type_t::operator =(value);
90 return self_;
91 }
92 operator type_t() {return self_;}
93 friend std::ostream& operator <<(std::ostream& os, const value_type& value) {return os << static_cast<const type_t&>(value);}
95
96 private:
97 friend class arranged_element_collection;
98 size_t pos = size_object::max_value;
99 arranged_element_collection* owner = nullptr;
100 };
101
103
112 using reference = type_t&;
114 using const_reference = const type_t&;
116 using pointer = value_type*;
118 using const_pointer = const value_type*;
122
124
134 inline static constexpr xtd::size npos = xtd::npos;
135
144 static inline constexpr xtd::size bpos = 0;
145
162 static inline constexpr xtd::size epos = npos - 1;
164
166
188
191 arranged_element_collection(const arranged_element_collection& collection) {*data_ = *collection.data_;}
195 data_ = std::move(collection.data_);
196 collection.data_ = new_ptr<data_collection>();
197 }
198
200 arranged_element_collection(const base_type& collection) {data_->items = collection;}
203 arranged_element_collection(base_type&& collection) {data_->items = std::move(collection);}
206 arranged_element_collection(std::initializer_list<type_t> items) {add_range(items);}
211 template <std::input_iterator input_iterator_t>
212 arranged_element_collection(input_iterator_t first, input_iterator_t last) {
213 for (auto iterator = first; iterator != last; ++iterator)
214 add(*iterator);
215 }
216
217
219
224 size_type capacity() const noexcept {return data_->items.capacity();}
229 void capacity(size_type value) {data_->items.capacity(value);}
230
233 size_type count() const noexcept override {return data_->items.count();}
234
237 pointer data() {return data_->items.data();}
240 const_pointer data() const {return data_->items.data();}
241
244 const auto& items() const {return data_->items.items();}
247 auto& items() {return data_->items.items();}
248
251 virtual bool sorted() const noexcept {return data_->sorted;}
254 virtual arranged_element_collection& sorted(bool value) {
255 if (data_->sorted == value) return self_;
256 data_->sorted = value;
257 if (data_->sorted) sort();
258 return self_;
259 }
260
261
263
267 void add(const type_t& item) override {
268 data_->items.add(item);
269 size_t index = data_->items.count() - 1;
270 static_cast<value_type&>(self_[index]).owner = this;
271 static_cast<value_type&>(self_[index]).pos = index;
272 on_item_added(index, data_->items[index]);
273 if (data_->sorted) sort();
274 }
275
277 virtual void add(type_t&& item) {
278 data_->items.add(item);
279 size_t index = data_->items.count() - 1;
280 static_cast<value_type&>(self_[index]).owner = this;
281 static_cast<value_type&>(self_[index]).pos = index;
282 on_item_added(index, data_->items[index]);
283 if (data_->sorted) sort();
284 }
285
288 virtual void add_range(const arranged_element_collection& collection) {
289 for (const auto& item : collection)
290 add(item);
291 }
292
294 virtual void add_range(const std::vector<type_t>& collection) {
295 for (const auto& item : collection)
296 add(item);
297 }
298
300 virtual void add_range(const std::initializer_list<type_t>& collection) {
301 for (const auto& item : collection)
302 add(item);
303 }
304
306 template<class collection_t>
307 void add_range(collection_t&& collection) {
308 for (auto& item : collection)
309 add(value_type(item));
310 }
311
313 template<class collection_t>
314 void add_range(const collection_t& collection) {
315 for (const auto& item : collection)
316 add(item);
317 }
318
321 void clear() override {
322 while (count())
323 remove_at(0);
324 }
325
329 bool contains(const type_t& item) const noexcept override {
330 return data_->items.contains(item);
331 }
332
337 void copy_to(xtd::array<type_t>& array, xtd::size array_index) const override {
339 auto i = size_type {0};
340 for (const type_t& item : self_) {
341 if (i >= count()) return;
342 array[array_index + i++] = item;
343 }
344 }
345
351
355 virtual void insert(xtd::size index, const type_t& value) {
357 data_->inserting = true;
358 items().insert(items().begin() + index, value);
359 data_->inserting = false;
360 static_cast<value_type&>(self_[index]).owner = this;
361 static_cast<value_type&>(self_[index]).pos = index;
362 on_item_added(index, data_->items[index]);
363 if (data_->sorted) sort();
364 }
365
368 sorter_t sorter;
369 sorter(items().begin(), items().end());
370 return self_;
371 }
372
378 bool remove(const type_t& item) override {
379 if (count() == 0) return false;
380 for (auto index = size_type {0}; index < count(); ++index) {
381 if (!xtd::collections::generic::helpers::equator<type_t> {}(self_[index], item)) continue;
382 remove_at(index);
383 return true;
384 }
385 return false;
386 }
387
390 virtual void remove_at(size_t index) {
392 on_item_removed(index, const_cast<value_type&>(data_->items[index]));
393 data_->erasing = true;
394 items().erase(items().begin() + index);
395 data_->erasing = false;
396 }
397
400 xtd::array<type_t> to_array() const noexcept {
401 return data_->items.count() ? xtd::array<type_t>(data_->items.data(), data_->items.count()) : xtd::array<type_t> {};
402 }
403
404
406
416
420 clear();
421 add_range(std::move(other.data_->items));
422 return self_;
423 }
424
427 arranged_element_collection& operator =(const std::initializer_list<type_t>& items) {
428 clear();
430 return self_;
431 }
432
436 value_type& operator [](size_type index) {
438 data_->items[index].pos = index > npos / 2 ? count() - (npos - index) : index;
439 data_->items[index].owner = this;
440 return data_->items[index];
441 }
442
445 const value_type& operator [](size_type index) const {
447 data_->items[index].pos = index > npos / 2 ? count() - (npos - index) : index;
448 data_->items[index].owner = const_cast<arranged_element_collection*>(this);
449 return data_->items[index];
450 }
451
454 operator const_base_type& () const noexcept {return items();}
457 operator base_type& () noexcept {return items();}
458
459 bool operator ==(const arranged_element_collection& value) const {return data_->items == value.data_->items;}
460 bool operator !=(const arranged_element_collection& value) const {return !operator ==(value);}
462
464
468 event<arranged_element_collection, delegate<void(size_t, type_t& item)>> item_added;
469
472 event<arranged_element_collection, delegate<void(size_t, type_t& item)>> item_updated;
473
476 event<arranged_element_collection, delegate<void(size_t, type_t& item)>> item_removed;
478
480
484 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;
487 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;
489
491
496 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::items().max_size - Will be removed in version 0.4.0.")]]
497 size_type max_size() const noexcept {return data_->items.max_size();}
499
501
507 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::operator [] - Will be removed in version 0.4.0.")]]
509 data_->items[pos].pos = pos;
510 data_->items[pos].owner = this;
511 return data_->items.at(pos);
512 }
513
517 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::operator [] - Will be removed in version 0.4.0.")]]
518 const_reference at(size_type pos) const {return data_->items.at(pos);}
519
523 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::operator [~1_z] - Will be removed in version 0.4.0.")]]
524 reference back() {return data_->items.back();}
528 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::operator [~1_z] - Will be removed in version 0.4.0.")]]
529 const_reference back() const {return data_->items.back();}
530
534 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::items().crbegin - Will be removed in version 0.4.0.")]]
535 const_reverse_iterator crbegin() const noexcept {return data_->items.crbegin();}
539 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::items().crend - Will be removed in version 0.4.0.")]]
540 const_reverse_iterator crend() const noexcept {return data_->items.crend();}
541
545 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::operator [0] - Will be removed in version 0.4.0.")]]
546 reference front() {return data_->items.front();}
550 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::operator [0] - Will be removed in version 0.4.0.")]]
551 const_reference front() const {return data_->items.front();}
552
556 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::items().get_allocator - Will be removed in version 0.4.0.")]]
557 auto get_allocator() const noexcept {return data_->items.get_allocator();}
558
563 template<class ...args_t>
564 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::insert - Will be removed in version 0.4.0.")]]
566 auto index = pos - items().begin();
567 data_->inserting = true;
568 auto result = data_->items.insert(pos, args...);
569 data_->inserting = false;
570 self_[index].owner = this;
571 self_[index].pos = index;
572 on_item_added(index, data_->items[index]);
573 if (data_->sorted) sort();
574 return result;
575 }
576
580 template<class ...args_t>
581 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::add - Will be removed in version 0.4.0.")]]
582 void emplace_back(args_t&& ... args) {
583 data_->items.emplace_back(args...);
584 size_t index = data_->items.size() - 1;
585 self_[index].owner = this;
586 self_[index].pos = index;
587 on_item_added(index, data_->items[index]);
588 if (data_->sorted) sort();
589 }
590
594 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::remove_at - Will be removed in version 0.4.0.")]]
596 on_item_removed(pos - items().begin(), *pos);
597 data_->erasing = true;
598 auto result = items().erase(pos);
599 data_->erasing = false;
600 return result;
601 }
602
605 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::remove_at - Will be removed in version 0.4.0.")]]
607 on_item_removed(pos - items().begin(), const_cast<value_type&>(*pos));
608 data_->erasing = true;
609 auto result = items().erase(pos);
610 data_->erasing = false;
611 return result;
612 }
613
618 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::remove_at - Will be removed in version 0.4.0.")]]
620 auto result = items().end();
621 auto index = first - items().begin();
622 for (auto it = first; it <= last; ++it)
623 remove_at(index++);
624 return result;
625 }
626
630 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::remove_at - Will be removed in version 0.4.0.")]]
632 auto result = items().end();
633 auto index = first - items().begin();
634 for (auto it = first; it <= last; ++it)
635 remove_at(index++);
636 return result;
637 }
638
642 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::remove_at - Will be removed in version 0.4.0.")]]
643 void erase_at(size_t index) {
644 remove_at(index);
645 }
646
651 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::insert - Will be removed in version 0.4.0.")]]
653 auto index = pos - items().begin();
654 data_->inserting = true;
655 auto result = items().insert(pos, value);
656 data_->inserting = false;
657 self_[index].owner = this;
658 self_[index].pos = index;
659 on_item_added(index, data_->items[index]);
660 if (data_->sorted) sort();
661 return result;
662 }
663
667 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::insert - Will be removed in version 0.4.0.")]]
669 auto index = pos - items().begin();
670 data_->inserting = true;
671 auto result = items().insert(pos, value);
672 data_->inserting = false;
673 self_[index].owner = this;
674 self_[index].pos = index;
675 on_item_added(index, data_->items[index]);
676 if (data_->sorted) sort();
677 return result;
678 }
679
684 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::insert - Will be removed in version 0.4.0.")]]
685 void insert_at(size_t index, const type_t& value) {
686 insert(index, value);
687 }
688
691 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::remove(count() - 1) - Will be removed in version 0.4.0.")]]
692 void pop_back() {
693 if (count() != 0) remove_at(count() - 1);
694 }
695
699 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::add - Will be removed in version 0.4.0.")]]
700 void push_back(const type_t& item) {
701 add(item);
702 }
703
706 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::add - Will be removed in version 0.4.0.")]]
707 void push_back(type_t&& item) {
708 add(std::move(item));
709 }
710
714 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::add_range - Will be removed in version 0.4.0.")]]
716 add_range(collection);
717 }
718
721 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::add_range - Will be removed in version 0.4.0.")]]
722 void push_back_range(const std::vector<type_t>& collection) {
723 add_range(collection);
724 }
725
728 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::add_range - Will be removed in version 0.4.0.")]]
729 void push_back_range(const std::initializer_list<type_t>& collection) {
730 add_range(collection);
731 }
732
735 template<class collection_t>
736 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::add_range - Will be removed in version 0.4.0.")]]
737 void push_back_range(collection_t&& collection) {
738 add_range(collection);
739 }
740
743 template<class iterator_t>
744 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::add_range - Will be removed in version 0.4.0.")]]
745 void push_back_range(iterator_t begin, iterator_t end) {
747 }
748
752 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::to_array - Will be removed in version 0.4.0.")]]
753 std::vector<type_t> to_vector() const noexcept {return to_array();}
754
758 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::items().rbegin - Will be removed in version 0.4.0.")]]
759 auto rbegin() noexcept {return data_->items.rbegin();}
763 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::items().rbegin - Will be removed in version 0.4.0.")]]
764 auto rbegin() const noexcept {return data_->items.rbegin();}
765
769 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::items().rend - Will be removed in version 0.4.0.")]]
770 auto rend() noexcept {return data_->items.rend();}
774 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::items().rend - Will be removed in version 0.4.0.")]]
775 auto rend() const noexcept {return data_->items.rend();}
776
779 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::items().reserve - Will be removed in version 0.4.0.")]]
780 void reserve(size_type size) {data_->items.reserve(size);}
781
784 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::items().shrink_to_fit - Will be removed in version 0.4.0.")]]
785 void shrink_to_fit() {data_->items.shrink_to_fit();}
787
788 protected:
790
795 virtual void on_item_added(size_t index, type_t& item) {item_added(index, item);}
796
800 virtual void on_item_updated(size_t index, type_t& item) {item_updated(index, item);}
801
805 virtual void on_item_removed(size_t index, type_t& item) {item_removed(index, item);}
807
808 private:
809 bool is_read_only() const noexcept override {return false;}
810 bool is_synchronized() const noexcept override {return false;}
811 const xtd::object& sync_root() const noexcept override {return data_->sync_root;}
812
813 struct data_collection {
814 mutable xtd::collections::generic::list < value_type > items;
815 bool inserting = false;
816 bool erasing = false;
817 bool sorted = false;
818 xtd::object sync_root;
819 };
821 };
822 }
823 }
824}
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Definition array.hpp:63
virtual const base_type & items() const noexcept
Returns the underlying base type items.
Definition basic_array.hpp:172
static constexpr size_t max_value
Definition box_integer.hpp:67
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:79
typename __xtd_raw_array_data__< value_type >::base_type base_type
Represents the list base type.
Definition list.hpp:126
const auto & items() const noexcept
Returns the underlying base type items.
Definition list.hpp:290
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:72
Represents a collection of objects.
Definition arranged_element_collection.hpp:42
static constexpr xtd::size bpos
Definition arranged_element_collection.hpp:144
void capacity(size_type value)
Sets the total number of elements the internal data structure can hold without resizing.
Definition arranged_element_collection.hpp:229
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:795
void clear() override
Removes all items from the xtd::forms::layout::arranged_element_collection <type_t>.
Definition arranged_element_collection.hpp:321
auto & items()
Returns the underlying base type items.
Definition arranged_element_collection.hpp:247
const auto & items() const
Returns the underlying base type items.
Definition arranged_element_collection.hpp:244
void emplace_back(args_t &&... args)
Adds an element to the end.
Definition arranged_element_collection.hpp:582
static constexpr xtd::size npos
Represents a value that is not a valid position in a collection.
Definition arranged_element_collection.hpp:134
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:206
arranged_element_collection(const base_type &collection)
Copy constructor with specified base type list.
Definition arranged_element_collection.hpp:200
xtd::string & reference
Definition arranged_element_collection.hpp:112
virtual arranged_element_collection & sorted(bool value)
Sets the container is sorted.
Definition arranged_element_collection.hpp:254
auto rend() noexcept
Returns a reverse iterator to the end.
Definition arranged_element_collection.hpp:770
const_reference front() const
Access the first element.
Definition arranged_element_collection.hpp:551
arranged_element_collection(const arranged_element_collection &collection)
Default copy constructor with specified list.
Definition arranged_element_collection.hpp:191
void push_back(const type_t &item)
Adds an element to the end.
Definition arranged_element_collection.hpp:700
virtual void add_range(const std::vector< type_t > &collection)
Adds elements to the end.
Definition arranged_element_collection.hpp:294
virtual arranged_element_collection & sort()
Sorts the content.
Definition arranged_element_collection.hpp:367
arranged_element_collection(base_type &&collection)
Move constructor with specified base type list.
Definition arranged_element_collection.hpp:203
auto get_allocator() const noexcept
Returns the associated allocator.
Definition arranged_element_collection.hpp:557
size_type capacity() const noexcept
Definition arranged_element_collection.hpp:224
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:805
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:212
void insert_at(size_t index, const type_t &value)
Inserts specified element at specified index.
Definition arranged_element_collection.hpp:685
event< arranged_element_collection, delegate< void(size_t, xtd::string &item)> > item_updated
Definition arranged_element_collection.hpp:472
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:668
void push_back_range(const std::vector< type_t > &collection)
Adds elements to the end.
Definition arranged_element_collection.hpp:722
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:329
void add_range(collection_t &&collection)
Adds elements to the end.
Definition arranged_element_collection.hpp:307
const xtd::string & const_reference
Definition arranged_element_collection.hpp:114
void push_back(type_t &&item)
Adds an element to the end.
Definition arranged_element_collection.hpp:707
void pop_back()
Removes the last element of the container.
Definition arranged_element_collection.hpp:692
auto erase(xtd::collections::generic::list< value_type >::const_iterator pos)
Erases element at specified position.
Definition arranged_element_collection.hpp:606
auto rbegin() noexcept
Returns a reverse iterator to the end.
Definition arranged_element_collection.hpp:759
xtd::size size_type
Definition arranged_element_collection.hpp:110
void push_back_range(collection_t &&collection)
Adds elements to the end.
Definition arranged_element_collection.hpp:737
const_reverse_iterator crend() const noexcept
Returns a reverse iterator to the end.
Definition arranged_element_collection.hpp:540
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:267
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:631
virtual void add_range(const std::initializer_list< type_t > &collection)
Adds elements to the end.
Definition arranged_element_collection.hpp:300
void push_back_range(const arranged_element_collection &collection)
Adds elements to the end.
Definition arranged_element_collection.hpp:715
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:378
value_type & operator[](size_type index)
Access specified element.
Definition arranged_element_collection.hpp:436
reference back()
Access the last element.
Definition arranged_element_collection.hpp:524
virtual void remove_at(size_t index)
Erases element at specified index.
Definition arranged_element_collection.hpp:390
virtual void insert(xtd::size index, const type_t &value)
Inserts specified element at specified index.
Definition arranged_element_collection.hpp:355
pointer data()
Direct access to the underlying array.
Definition arranged_element_collection.hpp:237
void shrink_to_fit()
Reduces memory usage by freeing unused memory.
Definition arranged_element_collection.hpp:785
xtd::array< type_t > to_array() const noexcept
Gets an array with the elements of the container.
Definition arranged_element_collection.hpp:400
reference front()
Access the first element.
Definition arranged_element_collection.hpp:546
auto rbegin() const noexcept
Returns a reverse iterator to the end.
Definition arranged_element_collection.hpp:764
auto rend() const noexcept
Returns a reverse iterator to the end.
Definition arranged_element_collection.hpp:775
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:348
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:565
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:652
const base_type const_base_type
Definition arranged_element_collection.hpp:108
std::vector< type_t > to_vector() const noexcept
Gets an array with the elements of the container.
Definition arranged_element_collection.hpp:753
virtual void add_range(const arranged_element_collection &collection)
Adds elements to the end.
Definition arranged_element_collection.hpp:288
const_reverse_iterator crbegin() const noexcept
Returns a reverse iterator to the end.
Definition arranged_element_collection.hpp:535
const_reference back() const
Access the last element.
Definition arranged_element_collection.hpp:529
const_reference at(size_type pos) const
Access specified element with bounds checking.
Definition arranged_element_collection.hpp:518
arranged_element_collection(size_type capacity)
Constructs the container with specified count default-inserted instances of type_t....
Definition arranged_element_collection.hpp:179
void copy_to(xtd::array< type_t > &array, xtd::size 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:337
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:619
arranged_element_collection(arranged_element_collection &&collection)
Move constructor with specified list.
Definition arranged_element_collection.hpp:194
value_type * pointer
Definition arranged_element_collection.hpp:116
const value_type * const_pointer
Definition arranged_element_collection.hpp:118
virtual void add(type_t &&item)
Adds an item to the xtd::forms::layout::arranged_element_collection <type_t>.
Definition arranged_element_collection.hpp:277
void erase_at(size_t index)
Erases element at specified index.
Definition arranged_element_collection.hpp:643
const_pointer data() const
Direct access to the underlying array.
Definition arranged_element_collection.hpp:240
xtd::collections::object_model::read_only_collection< value_type > read_only_collection
Definition arranged_element_collection.hpp:120
void reserve(size_type size)
Reserves storage.
Definition arranged_element_collection.hpp:780
event< arranged_element_collection, delegate< void(size_t, xtd::string &item)> > item_removed
Definition arranged_element_collection.hpp:476
void push_back_range(iterator_t begin, iterator_t end)
Adds elements to the end.
Definition arranged_element_collection.hpp:745
size_type max_size() const noexcept
Returns the maximum possible number of elements.
Definition arranged_element_collection.hpp:497
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:187
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:411
void push_back_range(const std::initializer_list< type_t > &collection)
Adds elements to the end.
Definition arranged_element_collection.hpp:729
static constexpr xtd::size epos
Definition arranged_element_collection.hpp:162
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:800
typename xtd::collections::generic::list< value_type >::base_type base_type
Definition arranged_element_collection.hpp:106
void add_range(const collection_t &collection)
Adds elements to the end.
Definition arranged_element_collection.hpp:314
reference at(size_type pos)
Access specified element with bounds checking.
Definition arranged_element_collection.hpp:508
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:233
virtual bool sorted() const noexcept
Checks whether the container is sorted.
Definition arranged_element_collection.hpp:251
event< arranged_element_collection, delegate< void(size_t, xtd::string &item)> > item_added
Definition arranged_element_collection.hpp:468
auto erase(xtd::collections::generic::list< value_type >::iterator pos)
Erases element at specified position.
Definition arranged_element_collection.hpp:595
static void throws(xtd::helpers::exception_case exception_case, const source_location &location=source_location::current())
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:44
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:114
@ index_out_of_range
The index is out of range.
Definition exception_case.hpp:59
@ 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:63
#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::size npos
Represents a value that is not a valid position in a collection.
Definition npos.hpp:26
size_t size
Represents a size of any object in bytes.
Definition size.hpp:23
xtd::sptr< type_t > ptr
The xtd::ptr object is a shared pointer.
Definition ptr.hpp:27
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:58
@ add
The add key.
Definition keys.hpp:281
@ end
The END key.
Definition keys.hpp:151
@ i
The I key.
Definition keys.hpp:215
@ insert
The INSERT key.
Definition keys.hpp:173
@ size
Specifies that both the width and height property values of the control are defined.
Definition bounds_specified.hpp:36
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_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
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
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:38
Contains xtd::helpers::exception_case enum class.