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 {
40 template<class type_t, class sorter_t = sorter_none>
41 class arranged_element_collection : public object, public xtd::collections::generic::icollection<type_t> {
42 struct __enumerator__ : public xtd::collections::generic::ienumerator<type_t> {
43 public:
44 explicit __enumerator__(const arranged_element_collection& items, xtd::size version) : items_(items), version_(version) {}
45
46 const type_t& current() const override {
47 if (version_ != items_.items().version()) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::invalid_operation, "Collection was modified; enumeration operation may not execute.");
48 if (index_ < items_.count()) return items_[index_];
49 return default_value_;
50 }
51
52 bool move_next() override {
53 if (version_ != items_.items().version()) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::invalid_operation, "Collection was modified; enumeration operation may not execute.");
54 return ++index_ < items_.count();
55 }
56
57 void reset() override {
58 version_ = items_.items().version();
60 }
61
62 protected:
63 const arranged_element_collection& items_;
65 xtd::size version_ = 0;
66 type_t default_value_;
67 };
68
69 public:
71 class value_type : public type_t {
72 public:
74 value_type() = default;
75 value_type(const value_type&) = default;
76 value_type(value_type&&) = default;
77 template<class ...args_t>
78 value_type(args_t&& ...args) : type_t(args...) {}
79 value_type& operator =(const value_type& value) {
80 if (value.owner) owner = value.owner;
81 if (owner != nullptr && !owner->data_->inserting && !owner->data_->erasing) owner->on_item_updated(pos, static_cast<type_t&>(const_cast<value_type&>(value)));
82 type_t::operator =(value);
83 return self_;
84 }
86 if (value.owner) owner = value.owner;
87 if (owner != nullptr && !owner->data_->inserting && !owner->data_->erasing) owner->on_item_updated(pos, static_cast<type_t&>(value));
88 type_t::operator =(value);
89 return self_;
90 }
91 operator type_t() {return self_;}
92 friend std::ostream& operator <<(std::ostream& os, const value_type& value) {return os << static_cast<const type_t&>(value);}
94
95 private:
96 friend class arranged_element_collection;
97 size_t pos = size_object::max_value;
98 arranged_element_collection* owner = nullptr;
99 };
100
102
111 using reference = type_t&;
113 using const_reference = const type_t&;
115 using pointer = value_type*;
117 using const_pointer = const value_type*;
121
123
133 inline static constexpr xtd::size npos = xtd::npos;
134
143 static inline constexpr xtd::size bpos = 0;
144
161 static inline constexpr xtd::size epos = npos - 1;
163
165
187
190 arranged_element_collection(const arranged_element_collection& collection) {*data_ = *collection.data_;}
194 data_ = std::move(collection.data_);
195 collection.data_ = new_ptr<data_collection>();
196 }
197
199 arranged_element_collection(const base_type& collection) {data_->items = collection;}
202 arranged_element_collection(base_type&& collection) {data_->items = std::move(collection);}
205 arranged_element_collection(std::initializer_list<type_t> items) {add_range(items);}
210 template <std::input_iterator input_iterator_t>
211 arranged_element_collection(input_iterator_t first, input_iterator_t last) {
212 for (auto iterator = first; iterator != last; ++iterator)
213 add(*iterator);
214 }
215
216
218
223 size_type capacity() const noexcept {return data_->items.capacity();}
228 void capacity(size_type value) {data_->items.capacity(value);}
229
232 size_type count() const noexcept override {return data_->items.count();}
233
236 pointer data() {return data_->items.data();}
239 const_pointer data() const {return data_->items.data();}
240
243 const auto& items() const {return data_->items.items();}
246 auto& items() {return data_->items.items();}
247
250 virtual bool sorted() const noexcept {return data_->sorted;}
253 virtual arranged_element_collection& sorted(bool value) {
254 if (data_->sorted == value) return self_;
255 data_->sorted = value;
256 if (data_->sorted) sort();
257 return self_;
258 }
259
260
262
266 void add(const type_t& item) override {
267 data_->items.add(item);
268 size_t index = data_->items.count() - 1;
269 static_cast<value_type&>(self_[index]).owner = this;
270 static_cast<value_type&>(self_[index]).pos = index;
271 on_item_added(index, data_->items[index]);
272 if (data_->sorted) sort();
273 }
274
276 virtual void add(type_t&& item) {
277 data_->items.add(item);
278 size_t index = data_->items.count() - 1;
279 static_cast<value_type&>(self_[index]).owner = this;
280 static_cast<value_type&>(self_[index]).pos = index;
281 on_item_added(index, data_->items[index]);
282 if (data_->sorted) sort();
283 }
284
287 virtual void add_range(const arranged_element_collection& collection) {
288 for (const auto& item : collection)
289 add(item);
290 }
291
293 virtual void add_range(const std::vector<type_t>& collection) {
294 for (const auto& item : collection)
295 add(item);
296 }
297
299 virtual void add_range(const std::initializer_list<type_t>& collection) {
300 for (const auto& item : collection)
301 add(item);
302 }
303
305 template<class collection_t>
306 void add_range(collection_t&& collection) {
307 for (auto& item : collection)
308 add(value_type(item));
309 }
310
312 template<class collection_t>
313 void add_range(const collection_t& collection) {
314 for (const auto& item : collection)
315 add(item);
316 }
317
320 void clear() override {
321 while (count())
322 remove_at(0);
323 }
324
328 bool contains(const type_t& item) const noexcept override {
329 return data_->items.contains(item);
330 }
331
336 void copy_to(xtd::array<type_t>& array, xtd::size array_index) const override {
338 auto i = size_type {0};
339 for (const type_t& item : self_) {
340 if (i >= count()) return;
341 array[array_index + i++] = item;
342 }
343 }
344
350
354 virtual void insert(xtd::size index, const type_t& value) {
356 data_->inserting = true;
357 items().insert(items().begin() + index, value);
358 data_->inserting = false;
359 static_cast<value_type&>(self_[index]).owner = this;
360 static_cast<value_type&>(self_[index]).pos = index;
361 on_item_added(index, data_->items[index]);
362 if (data_->sorted) sort();
363 }
364
367 sorter_t sorter;
368 sorter(items().begin(), items().end());
369 return self_;
370 }
371
377 bool remove(const type_t& item) override {
378 if (count() == 0) return false;
379 for (auto index = size_type {0}; index < count(); ++index) {
380 if (!xtd::collections::generic::helpers::equator<type_t> {}(self_[index], item)) continue;
381 remove_at(index);
382 return true;
383 }
384 return false;
385 }
386
389 virtual void remove_at(size_t index) {
391 on_item_removed(index, const_cast<value_type&>(data_->items[index]));
392 data_->erasing = true;
393 items().erase(items().begin() + index);
394 data_->erasing = false;
395 }
396
399 xtd::array<type_t> to_array() const noexcept {
400 return data_->items.count() ? xtd::array<type_t>(data_->items.data(), data_->items.count()) : xtd::array<type_t> {};
401 }
402
403
405
415
419 clear();
420 add_range(std::move(other.data_->items));
421 return self_;
422 }
423
426 arranged_element_collection& operator =(const std::initializer_list<type_t>& items) {
427 clear();
429 return self_;
430 }
431
435 value_type& operator [](size_type index) {
437 data_->items[index].pos = index > npos / 2 ? count() - (npos - index) : index;
438 data_->items[index].owner = this;
439 return data_->items[index];
440 }
441
444 const value_type& operator [](size_type index) const {
446 data_->items[index].pos = index > npos / 2 ? count() - (npos - index) : index;
447 data_->items[index].owner = const_cast<arranged_element_collection*>(this);
448 return data_->items[index];
449 }
450
453 operator const_base_type& () const noexcept {return items();}
456 operator base_type& () noexcept {return items();}
457
458 bool operator ==(const arranged_element_collection& value) const {return data_->items == value.data_->items;}
459 bool operator !=(const arranged_element_collection& value) const {return !operator ==(value);}
461
463
467 event<arranged_element_collection, delegate<void(size_t, type_t& item)>> item_added;
468
471 event<arranged_element_collection, delegate<void(size_t, type_t& item)>> item_updated;
472
475 event<arranged_element_collection, delegate<void(size_t, type_t& item)>> item_removed;
477
479
483 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;
486 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;
488
490
495 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::items().max_size - Will be removed in version 0.4.0.")]]
496 size_type max_size() const noexcept {return data_->items.max_size();}
498
500
506 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::operator [] - Will be removed in version 0.4.0.")]]
508 data_->items[pos].pos = pos;
509 data_->items[pos].owner = this;
510 return data_->items.at(pos);
511 }
512
516 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::operator [] - Will be removed in version 0.4.0.")]]
517 const_reference at(size_type pos) const {return data_->items.at(pos);}
518
522 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::operator [~1_z] - Will be removed in version 0.4.0.")]]
523 reference back() {return data_->items.back();}
527 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::operator [~1_z] - Will be removed in version 0.4.0.")]]
528 const_reference back() const {return data_->items.back();}
529
533 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::items().crbegin - Will be removed in version 0.4.0.")]]
534 const_reverse_iterator crbegin() const noexcept {return data_->items.crbegin();}
538 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::items().crend - Will be removed in version 0.4.0.")]]
539 const_reverse_iterator crend() const noexcept {return data_->items.crend();}
540
544 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::operator [0] - Will be removed in version 0.4.0.")]]
545 reference front() {return data_->items.front();}
549 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::operator [0] - Will be removed in version 0.4.0.")]]
550 const_reference front() const {return data_->items.front();}
551
555 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::items().get_allocator - Will be removed in version 0.4.0.")]]
556 auto get_allocator() const noexcept {return data_->items.get_allocator();}
557
562 template<class ...args_t>
563 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::insert - Will be removed in version 0.4.0.")]]
565 auto index = pos - items().begin();
566 data_->inserting = true;
567 auto result = data_->items.insert(pos, args...);
568 data_->inserting = false;
569 self_[index].owner = this;
570 self_[index].pos = index;
571 on_item_added(index, data_->items[index]);
572 if (data_->sorted) sort();
573 return result;
574 }
575
579 template<class ...args_t>
580 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::add - Will be removed in version 0.4.0.")]]
581 void emplace_back(args_t&& ... args) {
582 data_->items.emplace_back(args...);
583 size_t index = data_->items.size() - 1;
584 self_[index].owner = this;
585 self_[index].pos = index;
586 on_item_added(index, data_->items[index]);
587 if (data_->sorted) sort();
588 }
589
593 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::remove_at - Will be removed in version 0.4.0.")]]
595 on_item_removed(pos - items().begin(), *pos);
596 data_->erasing = true;
597 auto result = items().erase(pos);
598 data_->erasing = false;
599 return result;
600 }
601
604 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::remove_at - Will be removed in version 0.4.0.")]]
606 on_item_removed(pos - items().begin(), const_cast<value_type&>(*pos));
607 data_->erasing = true;
608 auto result = items().erase(pos);
609 data_->erasing = false;
610 return result;
611 }
612
617 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::remove_at - Will be removed in version 0.4.0.")]]
619 auto result = items().end();
620 auto index = first - items().begin();
621 for (auto it = first; it <= last; ++it)
622 remove_at(index++);
623 return result;
624 }
625
629 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::remove_at - Will be removed in version 0.4.0.")]]
631 auto result = items().end();
632 auto index = first - items().begin();
633 for (auto it = first; it <= last; ++it)
634 remove_at(index++);
635 return result;
636 }
637
641 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::remove_at - Will be removed in version 0.4.0.")]]
642 void erase_at(size_t index) {
643 remove_at(index);
644 }
645
650 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::insert - Will be removed in version 0.4.0.")]]
652 auto index = pos - items().begin();
653 data_->inserting = true;
654 auto result = items().insert(pos, value);
655 data_->inserting = false;
656 self_[index].owner = this;
657 self_[index].pos = index;
658 on_item_added(index, data_->items[index]);
659 if (data_->sorted) sort();
660 return result;
661 }
662
666 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::insert - Will be removed in version 0.4.0.")]]
668 auto index = pos - items().begin();
669 data_->inserting = true;
670 auto result = items().insert(pos, value);
671 data_->inserting = false;
672 self_[index].owner = this;
673 self_[index].pos = index;
674 on_item_added(index, data_->items[index]);
675 if (data_->sorted) sort();
676 return result;
677 }
678
683 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::insert - Will be removed in version 0.4.0.")]]
684 void insert_at(size_t index, const type_t& value) {
685 insert(index, value);
686 }
687
690 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::remove(count() - 1) - Will be removed in version 0.4.0.")]]
691 void pop_back() {
692 if (count() != 0) remove_at(count() - 1);
693 }
694
698 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::add - Will be removed in version 0.4.0.")]]
699 void push_back(const type_t& item) {
700 add(item);
701 }
702
705 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::add - Will be removed in version 0.4.0.")]]
706 void push_back(type_t&& item) {
707 add(std::move(item));
708 }
709
713 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::add_range - Will be removed in version 0.4.0.")]]
715 add_range(collection);
716 }
717
720 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::add_range - Will be removed in version 0.4.0.")]]
721 void push_back_range(const std::vector<type_t>& collection) {
722 add_range(collection);
723 }
724
727 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::add_range - Will be removed in version 0.4.0.")]]
728 void push_back_range(const std::initializer_list<type_t>& collection) {
729 add_range(collection);
730 }
731
734 template<class collection_t>
735 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::add_range - Will be removed in version 0.4.0.")]]
736 void push_back_range(collection_t&& collection) {
737 add_range(collection);
738 }
739
742 template<class iterator_t>
743 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::add_range - Will be removed in version 0.4.0.")]]
744 void push_back_range(iterator_t begin, iterator_t end) {
746 }
747
751 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::to_array - Will be removed in version 0.4.0.")]]
752 std::vector<type_t> to_vector() const noexcept {return to_array();}
753
757 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::items().rbegin - Will be removed in version 0.4.0.")]]
758 auto rbegin() noexcept {return data_->items.rbegin();}
762 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::items().rbegin - Will be removed in version 0.4.0.")]]
763 auto rbegin() const noexcept {return data_->items.rbegin();}
764
768 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::items().rend - Will be removed in version 0.4.0.")]]
769 auto rend() noexcept {return data_->items.rend();}
773 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::items().rend - Will be removed in version 0.4.0.")]]
774 auto rend() const noexcept {return data_->items.rend();}
775
778 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::items().reserve - Will be removed in version 0.4.0.")]]
779 void reserve(size_type size) {data_->items.reserve(size);}
780
783 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::items().shrink_to_fit - Will be removed in version 0.4.0.")]]
784 void shrink_to_fit() {data_->items.shrink_to_fit();}
786
787 protected:
789
794 virtual void on_item_added(size_t index, type_t& item) {item_added(index, item);}
795
799 virtual void on_item_updated(size_t index, type_t& item) {item_updated(index, item);}
800
804 virtual void on_item_removed(size_t index, type_t& item) {item_removed(index, item);}
806
807 private:
808 bool is_read_only() const noexcept override {return false;}
809 bool is_synchronized() const noexcept override {return false;}
810 const xtd::object& sync_root() const noexcept override {return data_->sync_root;}
811
812 struct data_collection {
813 mutable xtd::collections::generic::list < value_type > items;
814 bool inserting = false;
815 bool erasing = false;
816 bool sorted = false;
817 xtd::object sync_root;
818 };
820 };
821 }
822 }
823}
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:71
Represents a collection of objects.
Definition arranged_element_collection.hpp:41
static constexpr xtd::size bpos
Definition arranged_element_collection.hpp:143
void capacity(size_type value)
Sets the total number of elements the internal data structure can hold without resizing.
Definition arranged_element_collection.hpp:228
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:794
void clear() override
Removes all items from the xtd::forms::layout::arranged_element_collection <type_t>.
Definition arranged_element_collection.hpp:320
auto & items()
Returns the underlying base type items.
Definition arranged_element_collection.hpp:246
const auto & items() const
Returns the underlying base type items.
Definition arranged_element_collection.hpp:243
void emplace_back(args_t &&... args)
Adds an element to the end.
Definition arranged_element_collection.hpp:581
static constexpr xtd::size npos
Represents a value that is not a valid position in a collection.
Definition arranged_element_collection.hpp:133
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:205
arranged_element_collection(const base_type &collection)
Copy constructor with specified base type list.
Definition arranged_element_collection.hpp:199
xtd::string & reference
Definition arranged_element_collection.hpp:111
virtual arranged_element_collection & sorted(bool value)
Sets the container is sorted.
Definition arranged_element_collection.hpp:253
auto rend() noexcept
Returns a reverse iterator to the end.
Definition arranged_element_collection.hpp:769
const_reference front() const
Access the first element.
Definition arranged_element_collection.hpp:550
arranged_element_collection(const arranged_element_collection &collection)
Default copy constructor with specified list.
Definition arranged_element_collection.hpp:190
void push_back(const type_t &item)
Adds an element to the end.
Definition arranged_element_collection.hpp:699
virtual void add_range(const std::vector< type_t > &collection)
Adds elements to the end.
Definition arranged_element_collection.hpp:293
virtual arranged_element_collection & sort()
Sorts the content.
Definition arranged_element_collection.hpp:366
arranged_element_collection(base_type &&collection)
Move constructor with specified base type list.
Definition arranged_element_collection.hpp:202
auto get_allocator() const noexcept
Returns the associated allocator.
Definition arranged_element_collection.hpp:556
size_type capacity() const noexcept
Definition arranged_element_collection.hpp:223
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:804
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:211
void insert_at(size_t index, const type_t &value)
Inserts specified element at specified index.
Definition arranged_element_collection.hpp:684
event< arranged_element_collection, delegate< void(size_t, xtd::string &item)> > item_updated
Definition arranged_element_collection.hpp:471
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:667
void push_back_range(const std::vector< type_t > &collection)
Adds elements to the end.
Definition arranged_element_collection.hpp:721
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:328
void add_range(collection_t &&collection)
Adds elements to the end.
Definition arranged_element_collection.hpp:306
const xtd::string & const_reference
Definition arranged_element_collection.hpp:113
void push_back(type_t &&item)
Adds an element to the end.
Definition arranged_element_collection.hpp:706
void pop_back()
Removes the last element of the container.
Definition arranged_element_collection.hpp:691
auto erase(xtd::collections::generic::list< value_type >::const_iterator pos)
Erases element at specified position.
Definition arranged_element_collection.hpp:605
auto rbegin() noexcept
Returns a reverse iterator to the end.
Definition arranged_element_collection.hpp:758
xtd::size size_type
Definition arranged_element_collection.hpp:109
void push_back_range(collection_t &&collection)
Adds elements to the end.
Definition arranged_element_collection.hpp:736
const_reverse_iterator crend() const noexcept
Returns a reverse iterator to the end.
Definition arranged_element_collection.hpp:539
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:266
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:630
virtual void add_range(const std::initializer_list< type_t > &collection)
Adds elements to the end.
Definition arranged_element_collection.hpp:299
void push_back_range(const arranged_element_collection &collection)
Adds elements to the end.
Definition arranged_element_collection.hpp:714
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:377
value_type & operator[](size_type index)
Access specified element.
Definition arranged_element_collection.hpp:435
reference back()
Access the last element.
Definition arranged_element_collection.hpp:523
virtual void remove_at(size_t index)
Erases element at specified index.
Definition arranged_element_collection.hpp:389
virtual void insert(xtd::size index, const type_t &value)
Inserts specified element at specified index.
Definition arranged_element_collection.hpp:354
pointer data()
Direct access to the underlying array.
Definition arranged_element_collection.hpp:236
void shrink_to_fit()
Reduces memory usage by freeing unused memory.
Definition arranged_element_collection.hpp:784
xtd::array< type_t > to_array() const noexcept
Gets an array with the elements of the container.
Definition arranged_element_collection.hpp:399
reference front()
Access the first element.
Definition arranged_element_collection.hpp:545
auto rbegin() const noexcept
Returns a reverse iterator to the end.
Definition arranged_element_collection.hpp:763
auto rend() const noexcept
Returns a reverse iterator to the end.
Definition arranged_element_collection.hpp:774
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:347
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:564
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:651
const base_type const_base_type
Definition arranged_element_collection.hpp:107
std::vector< type_t > to_vector() const noexcept
Gets an array with the elements of the container.
Definition arranged_element_collection.hpp:752
virtual void add_range(const arranged_element_collection &collection)
Adds elements to the end.
Definition arranged_element_collection.hpp:287
const_reverse_iterator crbegin() const noexcept
Returns a reverse iterator to the end.
Definition arranged_element_collection.hpp:534
const_reference back() const
Access the last element.
Definition arranged_element_collection.hpp:528
const_reference at(size_type pos) const
Access specified element with bounds checking.
Definition arranged_element_collection.hpp:517
arranged_element_collection(size_type capacity)
Constructs the container with specified count default-inserted instances of type_t....
Definition arranged_element_collection.hpp:178
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:336
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:618
arranged_element_collection(arranged_element_collection &&collection)
Move constructor with specified list.
Definition arranged_element_collection.hpp:193
value_type * pointer
Definition arranged_element_collection.hpp:115
const value_type * const_pointer
Definition arranged_element_collection.hpp:117
virtual void add(type_t &&item)
Adds an item to the xtd::forms::layout::arranged_element_collection <type_t>.
Definition arranged_element_collection.hpp:276
void erase_at(size_t index)
Erases element at specified index.
Definition arranged_element_collection.hpp:642
const_pointer data() const
Direct access to the underlying array.
Definition arranged_element_collection.hpp:239
xtd::collections::object_model::read_only_collection< value_type > read_only_collection
Definition arranged_element_collection.hpp:119
void reserve(size_type size)
Reserves storage.
Definition arranged_element_collection.hpp:779
event< arranged_element_collection, delegate< void(size_t, xtd::string &item)> > item_removed
Definition arranged_element_collection.hpp:475
void push_back_range(iterator_t begin, iterator_t end)
Adds elements to the end.
Definition arranged_element_collection.hpp:744
size_type max_size() const noexcept
Returns the maximum possible number of elements.
Definition arranged_element_collection.hpp:496
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:186
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:410
void push_back_range(const std::initializer_list< type_t > &collection)
Adds elements to the end.
Definition arranged_element_collection.hpp:728
static constexpr xtd::size epos
Definition arranged_element_collection.hpp:161
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:799
typename xtd::collections::generic::list< value_type >::base_type base_type
Definition arranged_element_collection.hpp:105
void add_range(const collection_t &collection)
Adds elements to the end.
Definition arranged_element_collection.hpp:313
reference at(size_type pos)
Access specified element with bounds checking.
Definition arranged_element_collection.hpp:507
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:232
virtual bool sorted() const noexcept
Checks whether the container is sorted.
Definition arranged_element_collection.hpp:250
event< arranged_element_collection, delegate< void(size_t, xtd::string &item)> > item_added
Definition arranged_element_collection.hpp:467
auto erase(xtd::collections::generic::list< value_type >::iterator pos)
Erases element at specified position.
Definition arranged_element_collection.hpp:594
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:61
@ argument_out_of_range
The argument is out of range.
Definition exception_case.hpp:35
@ invalid_operation
The operation is not valid.
Definition exception_case.hpp:65
#define self_
The self_ expression is a reference value expression whose value is the reference of the implicit obj...
Definition self.hpp:20
constexpr xtd::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.