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 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<class ...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 value_type& value) {return os << static_cast<const type_t&>(value);}
67
68 private:
69 friend class arranged_element_collection;
70 size_t pos = size_object::max_value;
71 arranged_element_collection* owner = nullptr;
72 };
73
75
84 using reference = type_t&;
86 using const_reference = const type_t&;
88 using pointer = value_type*;
90 using const_pointer = const value_type*;
94
96
106 inline static constexpr xtd::size npos = xtd::npos;
107
116 static inline constexpr xtd::size bpos = 0;
117
134 static inline constexpr xtd::size epos = npos - 1;
136
138
160
163 arranged_element_collection(const arranged_element_collection& collection) {*data_ = *collection.data_;}
167 data_ = std::move(collection.data_);
168 collection.data_ = new_ptr<data_collection>();
169 }
170
172 arranged_element_collection(const base_type& collection) {data_->items = collection;}
175 arranged_element_collection(base_type&& collection) {data_->items = std::move(collection);}
178 arranged_element_collection(std::initializer_list<type_t> items) {add_range(items);}
183 template <std::input_iterator input_iterator_t>
184 arranged_element_collection(input_iterator_t first, input_iterator_t last) {
185 for (auto iterator = first; iterator != last; ++iterator)
186 add(*iterator);
187 }
188
189
191
196 size_type capacity() const noexcept {return data_->items.capacity();}
201 void capacity(size_type value) {data_->items.capacity(value);}
202
205 size_type count() const noexcept override {return data_->items.count();}
206
209 pointer data() {return data_->items.data();}
212 const_pointer data() const {return data_->items.data();}
213
216 const auto& items() const {return data_->items.items();}
219 auto& items() {return data_->items.items();}
220
223 virtual bool sorted() const noexcept {return data_->sorted;}
226 virtual arranged_element_collection& sorted(bool value) {
227 if (data_->sorted == value) return self_;
228 data_->sorted = value;
229 if (data_->sorted) sort();
230 return self_;
231 }
232
233
235
239 void add(const type_t& item) override {
240 data_->items.add(item);
241 size_t index = data_->items.count() - 1;
242 static_cast<value_type&>(self_[index]).owner = this;
243 static_cast<value_type&>(self_[index]).pos = index;
244 on_item_added(index, data_->items[index]);
245 if (data_->sorted) sort();
246 }
247
249 virtual void add(type_t&& item) {
250 data_->items.add(item);
251 size_t index = data_->items.count() - 1;
252 static_cast<value_type&>(self_[index]).owner = this;
253 static_cast<value_type&>(self_[index]).pos = index;
254 on_item_added(index, data_->items[index]);
255 if (data_->sorted) sort();
256 }
257
260 virtual void add_range(const arranged_element_collection& collection) {
261 for (const auto& item : collection)
262 add(item);
263 }
264
266 virtual void add_range(const std::vector<type_t>& collection) {
267 for (const auto& item : collection)
268 add(item);
269 }
270
272 virtual void add_range(const std::initializer_list<type_t>& collection) {
273 for (const auto& item : collection)
274 add(item);
275 }
276
278 template<class collection_t>
279 void add_range(collection_t&& collection) {
280 for (auto& item : collection)
281 add(value_type(item));
282 }
283
285 template<class collection_t>
286 void add_range(const collection_t& collection) {
287 for (const auto& item : collection)
288 add(item);
289 }
290
293 void clear() override {
294 while (count())
295 remove_at(0);
296 }
297
301 bool contains(const type_t& item) const noexcept override {
302 return data_->items.contains(item);
303 }
304
309 void copy_to(xtd::array<type_t>& array, xtd::size array_index) const override {
311 auto i = size_type {0};
312 for (const type_t& item : self_) {
313 if (i >= count()) return;
314 array[array_index + i++] = item;
315 }
316 }
317
321 struct arranged_element_collection_enumerator : public xtd::collections::generic::ienumerator<type_t> {
322 explicit arranged_element_collection_enumerator(const arranged_element_collection& items, xtd::size version) : items_(items), version_(version) {}
323
324 const type_t& current() const override {
326 if (version_ != items_.items().version()) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::invalid_operation, "Collection was modified; enumeration operation may not execute.");
327 return items_[index_];
328 }
329
330 bool move_next() override {
331 if (version_ != items_.items().version()) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::invalid_operation, "Collection was modified; enumeration operation may not execute.");
332 return ++index_ < items_.count();
333 }
334
335 void reset() override {
336 version_ = items_.items().version();
338 }
339
340 private:
342 const arranged_element_collection& items_;
343 size_type version_ = 0;
344 };
345
347 }
348
352 virtual void insert(xtd::size index, const type_t& value) {
354 data_->inserting = true;
355 items().insert(items().begin() + index, value);
356 data_->inserting = false;
357 static_cast<value_type&>(self_[index]).owner = this;
358 static_cast<value_type&>(self_[index]).pos = index;
359 on_item_added(index, data_->items[index]);
360 if (data_->sorted) sort();
361 }
362
365 sorter_t sorter;
366 sorter(items().begin(), items().end());
367 return self_;
368 }
369
375 bool remove(const type_t& item) override {
376 if (count() == 0) return false;
377 for (auto index = size_type {0}; index < count(); ++index) {
378 if (!xtd::collections::generic::helpers::equator<type_t> {}(self_[index], item)) continue;
379 remove_at(index);
380 return true;
381 }
382 return false;
383 }
384
387 virtual void remove_at(size_t index) {
389 on_item_removed(index, const_cast<value_type&>(data_->items[index]));
390 data_->erasing = true;
391 items().erase(items().begin() + index);
392 data_->erasing = false;
393 }
394
397 xtd::array<type_t> to_array() const noexcept {
398 return data_->items.count() ? xtd::array<type_t>(data_->items.data(), data_->items.count()) : xtd::array<type_t> {};
399 }
400
401
403
413
417 clear();
418 add_range(std::move(other.data_->items));
419 return self_;
420 }
421
424 arranged_element_collection& operator =(const std::initializer_list<type_t>& items) {
425 clear();
427 return self_;
428 }
429
433 value_type& operator [](size_type index) {
435 data_->items[index].pos = index > npos / 2 ? count() - (npos - index) : index;
436 data_->items[index].owner = this;
437 return data_->items[index];
438 }
439
442 const value_type& operator [](size_type index) const {
444 data_->items[index].pos = index > npos / 2 ? count() - (npos - index) : index;
445 data_->items[index].owner = const_cast<arranged_element_collection*>(this);
446 return data_->items[index];
447 }
448
451 operator const_base_type& () const noexcept {return items();}
454 operator base_type& () noexcept {return items();}
455
456 bool operator ==(const arranged_element_collection& value) const {return data_->items == value.data_->items;}
457 bool operator !=(const arranged_element_collection& value) const {return !operator ==(value);}
459
461
465 event<arranged_element_collection, delegate<void(size_t, type_t& item)>> item_added;
466
469 event<arranged_element_collection, delegate<void(size_t, type_t& item)>> item_updated;
470
473 event<arranged_element_collection, delegate<void(size_t, type_t& item)>> item_removed;
475
477
481 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;
484 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;
486
488
493 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::items().max_size - Will be removed in version 0.4.0.")]]
494 size_type max_size() const noexcept {return data_->items.max_size();}
496
498
504 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::operator [] - Will be removed in version 0.4.0.")]]
506 data_->items[pos].pos = pos;
507 data_->items[pos].owner = this;
508 return data_->items.at(pos);
509 }
510
514 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::operator [] - Will be removed in version 0.4.0.")]]
515 const_reference at(size_type pos) const {return data_->items.at(pos);}
516
520 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::operator [~1_z] - Will be removed in version 0.4.0.")]]
521 reference back() {return data_->items.back();}
525 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::operator [~1_z] - Will be removed in version 0.4.0.")]]
526 const_reference back() const {return data_->items.back();}
527
531 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::items().crbegin - Will be removed in version 0.4.0.")]]
532 const_reverse_iterator crbegin() const noexcept {return data_->items.crbegin();}
536 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::items().crend - Will be removed in version 0.4.0.")]]
537 const_reverse_iterator crend() const noexcept {return data_->items.crend();}
538
542 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::operator [0] - Will be removed in version 0.4.0.")]]
543 reference front() {return data_->items.front();}
547 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::operator [0] - Will be removed in version 0.4.0.")]]
548 const_reference front() const {return data_->items.front();}
549
553 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::items().get_allocator - Will be removed in version 0.4.0.")]]
554 auto get_allocator() const noexcept {return data_->items.get_allocator();}
555
560 template<class ...args_t>
561 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::insert - Will be removed in version 0.4.0.")]]
563 auto index = pos - items().begin();
564 data_->inserting = true;
565 auto result = data_->items.insert(pos, args...);
566 data_->inserting = false;
567 self_[index].owner = this;
568 self_[index].pos = index;
569 on_item_added(index, data_->items[index]);
570 if (data_->sorted) sort();
571 return result;
572 }
573
577 template<class ...args_t>
578 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::add - Will be removed in version 0.4.0.")]]
579 void emplace_back(args_t&& ... args) {
580 data_->items.emplace_back(args...);
581 size_t index = data_->items.size() - 1;
582 self_[index].owner = this;
583 self_[index].pos = index;
584 on_item_added(index, data_->items[index]);
585 if (data_->sorted) sort();
586 }
587
591 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::remove_at - Will be removed in version 0.4.0.")]]
593 on_item_removed(pos - items().begin(), *pos);
594 data_->erasing = true;
595 auto result = items().erase(pos);
596 data_->erasing = false;
597 return result;
598 }
599
602 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::remove_at - Will be removed in version 0.4.0.")]]
604 on_item_removed(pos - items().begin(), const_cast<value_type&>(*pos));
605 data_->erasing = true;
606 auto result = items().erase(pos);
607 data_->erasing = false;
608 return result;
609 }
610
615 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::remove_at - Will be removed in version 0.4.0.")]]
617 auto result = items().end();
618 auto index = first - items().begin();
619 for (auto it = first; it <= last; ++it)
620 remove_at(index++);
621 return result;
622 }
623
627 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::remove_at - Will be removed in version 0.4.0.")]]
629 auto result = items().end();
630 auto index = first - items().begin();
631 for (auto it = first; it <= last; ++it)
632 remove_at(index++);
633 return result;
634 }
635
639 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::remove_at - Will be removed in version 0.4.0.")]]
640 void erase_at(size_t index) {
641 remove_at(index);
642 }
643
648 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::insert - Will be removed in version 0.4.0.")]]
650 auto index = pos - items().begin();
651 data_->inserting = true;
652 auto result = items().insert(pos, value);
653 data_->inserting = false;
654 self_[index].owner = this;
655 self_[index].pos = index;
656 on_item_added(index, data_->items[index]);
657 if (data_->sorted) sort();
658 return result;
659 }
660
664 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::insert - Will be removed in version 0.4.0.")]]
666 auto index = pos - items().begin();
667 data_->inserting = true;
668 auto result = items().insert(pos, value);
669 data_->inserting = false;
670 self_[index].owner = this;
671 self_[index].pos = index;
672 on_item_added(index, data_->items[index]);
673 if (data_->sorted) sort();
674 return result;
675 }
676
681 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::insert - Will be removed in version 0.4.0.")]]
682 void insert_at(size_t index, const type_t& value) {
683 insert(index, value);
684 }
685
688 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::remove(count() - 1) - Will be removed in version 0.4.0.")]]
689 void pop_back() {
690 if (count() != 0) remove_at(count() - 1);
691 }
692
696 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::add - Will be removed in version 0.4.0.")]]
697 void push_back(const type_t& item) {
698 add(item);
699 }
700
703 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::add - Will be removed in version 0.4.0.")]]
704 void push_back(type_t&& item) {
705 add(std::move(item));
706 }
707
711 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::add_range - Will be removed in version 0.4.0.")]]
713 add_range(collection);
714 }
715
718 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::add_range - Will be removed in version 0.4.0.")]]
719 void push_back_range(const std::vector<type_t>& collection) {
720 add_range(collection);
721 }
722
725 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::add_range - Will be removed in version 0.4.0.")]]
726 void push_back_range(const std::initializer_list<type_t>& collection) {
727 add_range(collection);
728 }
729
732 template<class collection_t>
733 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::add_range - Will be removed in version 0.4.0.")]]
734 void push_back_range(collection_t&& collection) {
735 add_range(collection);
736 }
737
740 template<class iterator_t>
741 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::add_range - Will be removed in version 0.4.0.")]]
742 void push_back_range(iterator_t begin, iterator_t end) {
744 }
745
749 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::to_array - Will be removed in version 0.4.0.")]]
750 std::vector<type_t> to_vector() const noexcept {return to_array();}
751
755 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::items().rbegin - Will be removed in version 0.4.0.")]]
756 auto rbegin() noexcept {return data_->items.rbegin();}
760 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::items().rbegin - Will be removed in version 0.4.0.")]]
761 auto rbegin() const noexcept {return data_->items.rbegin();}
762
766 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::items().rend - Will be removed in version 0.4.0.")]]
767 auto rend() noexcept {return data_->items.rend();}
771 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::items().rend - Will be removed in version 0.4.0.")]]
772 auto rend() const noexcept {return data_->items.rend();}
773
776 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::items().reserve - Will be removed in version 0.4.0.")]]
777 void reserve(size_type size) {data_->items.reserve(size);}
778
781 [[deprecated("Replaced by xtd::forms::layout::arranged_element_collection::items().shrink_to_fit - Will be removed in version 0.4.0.")]]
782 void shrink_to_fit() {data_->items.shrink_to_fit();}
784
785 protected:
787
792 virtual void on_item_added(size_t index, type_t& item) {item_added(index, item);}
793
797 virtual void on_item_updated(size_t index, type_t& item) {item_updated(index, item);}
798
802 virtual void on_item_removed(size_t index, type_t& item) {item_removed(index, item);}
804
805 private:
806 bool is_read_only() const noexcept override {return false;}
807 bool is_synchronized() const noexcept override {return false;}
808 const xtd::object& sync_root() const noexcept override {return data_->sync_root;}
809
810 struct data_collection {
811 mutable xtd::collections::generic::list < value_type > items;
812 bool inserting = false;
813 bool erasing = false;
814 bool sorted = false;
815 xtd::object sync_root;
816 };
818 };
819 }
820 }
821}
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Definition array.hpp:64
virtual const base_type & items() const noexcept
Returns the underlying base type items.
Definition basic_array.hpp:113
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:80
typename xtd::collections::generic::helpers::raw_array< value_type >::base_type base_type
Represents the list base type.
Definition list.hpp:88
const auto & items() const noexcept
Returns the underlying base type items.
Definition list.hpp:251
Provides the base class for a generic read-only collection.
Definition read_only_collection.hpp:38
Represents the value type of the collection.
Definition arranged_element_collection.hpp:44
Represents a collection of objects.
Definition arranged_element_collection.hpp:41
static constexpr xtd::size bpos
Definition arranged_element_collection.hpp:116
void capacity(size_type value)
Sets the total number of elements the internal data structure can hold without resizing.
Definition arranged_element_collection.hpp:201
virtual void on_item_added(size_t index, type_t &item)
Raises the xtd::forms::layout::arranged_element_collection::item_added event.
Definition arranged_element_collection.hpp:792
void clear() override
Removes all items from the xtd::forms::layout::arranged_element_collection <type_t>.
Definition arranged_element_collection.hpp:293
auto & items()
Returns the underlying base type items.
Definition arranged_element_collection.hpp:219
const auto & items() const
Definition arranged_element_collection.hpp:216
void emplace_back(args_t &&... args)
Adds an element to the end.
Definition arranged_element_collection.hpp:579
static constexpr xtd::size npos
Definition arranged_element_collection.hpp:106
arranged_element_collection(std::initializer_list< type_t > items)
Constructs the container with the contents of the specified initializer list, and allocator.
Definition arranged_element_collection.hpp:178
arranged_element_collection(const base_type &collection)
Copy constructor with specified base type list.
Definition arranged_element_collection.hpp:172
xtd::string & reference
Definition arranged_element_collection.hpp:84
virtual arranged_element_collection & sorted(bool value)
Sets the container is sorted.
Definition arranged_element_collection.hpp:226
auto rend() noexcept
Returns a reverse iterator to the end.
Definition arranged_element_collection.hpp:767
const_reference front() const
Access the first element.
Definition arranged_element_collection.hpp:548
arranged_element_collection(const arranged_element_collection &collection)
Default copy constructor with specified list.
Definition arranged_element_collection.hpp:163
void push_back(const type_t &item)
Adds an element to the end.
Definition arranged_element_collection.hpp:697
virtual void add_range(const std::vector< type_t > &collection)
Adds elements to the end.
Definition arranged_element_collection.hpp:266
virtual arranged_element_collection & sort()
Sorts the content.
Definition arranged_element_collection.hpp:364
arranged_element_collection(base_type &&collection)
Move constructor with specified base type list.
Definition arranged_element_collection.hpp:175
auto get_allocator() const noexcept
Returns the associated allocator.
Definition arranged_element_collection.hpp:554
size_type capacity() const noexcept
Definition arranged_element_collection.hpp:196
virtual void on_item_removed(size_t index, type_t &item)
Raises the xtd::forms::layout::arranged_element_collection::item_removed event.
Definition arranged_element_collection.hpp:802
arranged_element_collection(input_iterator_t first, input_iterator_t last)
Constructs the container with the contents of the range [first, last).
Definition arranged_element_collection.hpp:184
void insert_at(size_t index, const type_t &value)
Inserts specified element at specified index.
Definition arranged_element_collection.hpp:682
event< arranged_element_collection, delegate< void(size_t, xtd::string &item)> > item_updated
Definition arranged_element_collection.hpp:469
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:665
void push_back_range(const std::vector< type_t > &collection)
Adds elements to the end.
Definition arranged_element_collection.hpp:719
bool contains(const type_t &item) const noexcept override
Determines whether the xtd::forms::layout::arranged_element_collection <type_t> contains a specific v...
Definition arranged_element_collection.hpp:301
void add_range(collection_t &&collection)
Adds elements to the end.
Definition arranged_element_collection.hpp:279
const xtd::string & const_reference
Definition arranged_element_collection.hpp:86
void push_back(type_t &&item)
Adds an element to the end.
Definition arranged_element_collection.hpp:704
void pop_back()
Removes the last element of the container.
Definition arranged_element_collection.hpp:689
auto erase(xtd::collections::generic::list< value_type >::const_iterator pos)
Erases element at specified position.
Definition arranged_element_collection.hpp:603
auto rbegin() noexcept
Returns a reverse iterator to the end.
Definition arranged_element_collection.hpp:756
xtd::size size_type
Definition arranged_element_collection.hpp:82
void push_back_range(collection_t &&collection)
Adds elements to the end.
Definition arranged_element_collection.hpp:734
const_reverse_iterator crend() const noexcept
Returns a reverse iterator to the end.
Definition arranged_element_collection.hpp:537
void add(const type_t &item) override
Adds an item to the xtd::forms::layout::arranged_element_collection <type_t>.
Definition arranged_element_collection.hpp:239
arranged_element_collection()=default
Initializes a new instance of the xtd::forms::layout::arranged_element_collection class that is empty...
auto erase(xtd::collections::generic::list< value_type >::const_iterator first, xtd::collections::generic::list< value_type >::const_iterator last)
Erases elements at specified range.
Definition arranged_element_collection.hpp:628
virtual void add_range(const std::initializer_list< type_t > &collection)
Adds elements to the end.
Definition arranged_element_collection.hpp:272
void push_back_range(const arranged_element_collection &collection)
Adds elements to the end.
Definition arranged_element_collection.hpp:712
bool remove(const type_t &item) override
Removes the first occurrence of a specific object from the xtd::forms::layout::arranged_element_colle...
Definition arranged_element_collection.hpp:375
value_type & operator[](size_type index)
Access specified element.
Definition arranged_element_collection.hpp:433
reference back()
Access the last element.
Definition arranged_element_collection.hpp:521
virtual void remove_at(size_t index)
Erases element at specified index.
Definition arranged_element_collection.hpp:387
virtual void insert(xtd::size index, const type_t &value)
Inserts specified element at specified index.
Definition arranged_element_collection.hpp:352
pointer data()
Direct access to the underlying array.
Definition arranged_element_collection.hpp:209
void shrink_to_fit()
Reduces memory usage by freeing unused memory.
Definition arranged_element_collection.hpp:782
xtd::array< type_t > to_array() const noexcept
Gets an array with the elements of the container.
Definition arranged_element_collection.hpp:397
reference front()
Access the first element.
Definition arranged_element_collection.hpp:543
auto rbegin() const noexcept
Returns a reverse iterator to the end.
Definition arranged_element_collection.hpp:761
auto rend() const noexcept
Returns a reverse iterator to the end.
Definition arranged_element_collection.hpp:772
xtd::collections::generic::enumerator< type_t > get_enumerator() const noexcept override
Returns an enumerator that iterates through the xtd::forms::layout::arranged_element_collection <type...
Definition arranged_element_collection.hpp:320
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:562
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:649
const base_type const_base_type
Definition arranged_element_collection.hpp:80
std::vector< type_t > to_vector() const noexcept
Gets an array with the elements of the container.
Definition arranged_element_collection.hpp:750
virtual void add_range(const arranged_element_collection &collection)
Adds elements to the end.
Definition arranged_element_collection.hpp:260
const_reverse_iterator crbegin() const noexcept
Returns a reverse iterator to the end.
Definition arranged_element_collection.hpp:532
const_reference back() const
Access the last element.
Definition arranged_element_collection.hpp:526
const_reference at(size_type pos) const
Access specified element with bounds checking.
Definition arranged_element_collection.hpp:515
arranged_element_collection(size_type capacity)
Constructs the container with specified count default-inserted instances of type_t....
Definition arranged_element_collection.hpp:151
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:309
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:616
arranged_element_collection(arranged_element_collection &&collection)
Move constructor with specified list.
Definition arranged_element_collection.hpp:166
value_type * pointer
Definition arranged_element_collection.hpp:88
const value_type * const_pointer
Definition arranged_element_collection.hpp:90
virtual void add(type_t &&item)
Adds an item to the xtd::forms::layout::arranged_element_collection <type_t>.
Definition arranged_element_collection.hpp:249
void erase_at(size_t index)
Erases element at specified index.
Definition arranged_element_collection.hpp:640
const_pointer data() const
Direct access to the underlying array.
Definition arranged_element_collection.hpp:212
xtd::collections::object_model::read_only_collection< value_type > read_only_collection
Definition arranged_element_collection.hpp:92
void reserve(size_type size)
Reserves storage.
Definition arranged_element_collection.hpp:777
event< arranged_element_collection, delegate< void(size_t, xtd::string &item)> > item_removed
Definition arranged_element_collection.hpp:473
void push_back_range(iterator_t begin, iterator_t end)
Adds elements to the end.
Definition arranged_element_collection.hpp:742
size_type max_size() const noexcept
Returns the maximum possible number of elements.
Definition arranged_element_collection.hpp:494
arranged_element_collection(const xtd::collections::generic::ienumerable< type_t > &collection)
Initializes a new instance of the xtd::forms::layout::arranged_element_collection <type_t> class that...
Definition arranged_element_collection.hpp:159
arranged_element_collection & operator=(const arranged_element_collection &other)
Copy assignment operator. Replaces the contents with a copy of the contents of other.
Definition arranged_element_collection.hpp:408
void push_back_range(const std::initializer_list< type_t > &collection)
Adds elements to the end.
Definition arranged_element_collection.hpp:726
static constexpr xtd::size epos
Definition arranged_element_collection.hpp:134
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:797
typename xtd::collections::generic::list< value_type >::base_type base_type
Definition arranged_element_collection.hpp:78
void add_range(const collection_t &collection)
Adds elements to the end.
Definition arranged_element_collection.hpp:286
reference at(size_type pos)
Access specified element with bounds checking.
Definition arranged_element_collection.hpp:505
size_type count() const noexcept override
Gets the number of elements contained in the xtd::forms::layout::arranged_element_collection <type_t>...
Definition arranged_element_collection.hpp:205
virtual bool sorted() const noexcept
Checks whether the container is sorted.
Definition arranged_element_collection.hpp:223
event< arranged_element_collection, delegate< void(size_t, xtd::string &item)> > item_added
Definition arranged_element_collection.hpp:465
auto erase(xtd::collections::generic::list< value_type >::iterator pos)
Erases element at specified position.
Definition arranged_element_collection.hpp:592
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:115
@ index_out_of_range
The index is out of range.
Definition exception_case.hpp:61
@ argument_out_of_range
The argument is out of range.
Definition exception_case.hpp:35
@ invalid_operation
The operation is not valid.
Definition exception_case.hpp:65
#define self_
The self_ expression is a reference value expression whose value is the reference of the implicit obj...
Definition self.hpp:20
constexpr xtd::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:60
@ 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:39
Contains xtd::helpers::throw_helper class.