8#include <xtd/collections/generic/helpers/equator>
9#include <xtd/collections/generic/list>
12#include <xtd/argument_out_of_range_exception>
13#include <xtd/event_args>
14#include <xtd/event_handler>
18#include <xtd/usize_object>
40 template<
typename type_t,
typename sorter_t = sorter_none>
50 template<
typename ...args_t>
51 value_type(args_t&& ...args) : type_t(args...) {}
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);
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);
64 operator type_t() {
return self_;}
69 friend class arranged_element_collection;
71 arranged_element_collection* owner =
nullptr;
139 data_ = std::move(collection.data_);
155 template <std::input_iterator input_iterator_t>
177 [[nodiscard]]
auto count() const noexcept ->
size_type override {
return data_->items.count();}
181 [[nodiscard]]
auto data() ->
pointer {
return data_->items.data();}
188 [[nodiscard]]
const auto&
items()
const {
return data_->items.items();}
191 [[nodiscard]]
auto&
items() {
return data_->items.items();}
195 [[nodiscard]]
virtual auto sorted() const noexcept ->
bool {
return data_->sorted;}
199 if (data_->sorted == value)
return self_;
200 data_->sorted = value;
201 if (data_->sorted)
sort();
211 auto add(
const type_t& item) ->
void override {
212 data_->items.add(item);
214 static_cast<value_type&
>(
self_[index]).owner =
this;
215 static_cast<value_type&
>(
self_[index]).pos = index;
217 if (data_->sorted)
sort();
221 virtual auto add(type_t&& item) ->
void {
222 data_->items.add(item);
224 static_cast<value_type&
>(
self_[index]).owner =
this;
225 static_cast<value_type&
>(
self_[index]).pos = index;
227 if (data_->sorted)
sort();
233 for (
const auto& item : collection)
238 virtual auto add_range(
const std::vector<type_t>& collection) ->
void {
239 for (
const auto& item : collection)
244 virtual auto add_range(
const std::initializer_list<type_t>& collection) ->
void {
245 for (
const auto& item : collection)
250 template<
typename collection_t>
252 for (
auto& item : collection)
257 template<
typename collection_t>
258 auto add_range(
const collection_t& collection) ->
void {
259 for (
const auto& item : collection)
273 [[nodiscard]]
auto contains(
const type_t& item)
const noexcept ->
bool override {
274 return data_->items.contains(item);
284 for (
const type_t& item :
self_) {
286 array[array_index +
i++] = item;
296 const type_t& current()
const override {
299 return items_[index_];
302 bool move_next()
override {
304 return ++index_ < items_.count();
307 void reset()
override {
308 version_ = items_.items().version();
326 data_->inserting =
true;
328 data_->inserting =
false;
329 static_cast<value_type&
>(
self_[index]).owner =
this;
330 static_cast<value_type&
>(
self_[index]).pos = index;
332 if (data_->sorted)
sort();
347 auto remove(
const type_t& item) ->
bool override {
348 if (
count() == 0)
return false;
362 data_->erasing =
true;
364 data_->erasing =
false;
384 data_->items.reverse(index,
count);
429 data_->items[index].pos = index >
npos / 2 ?
count() - (
npos - index) : index;
430 data_->items[index].owner =
this;
431 return data_->items[index];
438 data_->items[index].pos = index >
npos / 2 ?
count() - (
npos - index) : index;
440 return data_->items[index];
450 [[nodiscard]]
auto operator ==(
const arranged_element_collection& value)
const ->
bool {
return data_->items == value.data_->items;}
487 [[deprecated(
"Replaced by xtd::forms::layout::arranged_element_collection::items().max_size - Will be removed in version 1.2.0.")]]
498 [[deprecated(
"Replaced by xtd::forms::layout::arranged_element_collection::operator [] - Will be removed in version 1.2.0.")]]
500 data_->items[pos].pos = pos;
501 data_->items[pos].owner =
this;
502 return data_->items.at(pos);
508 [[deprecated(
"Replaced by xtd::forms::layout::arranged_element_collection::operator [] - Will be removed in version 1.2.0.")]]
514 [[deprecated(
"Replaced by xtd::forms::layout::arranged_element_collection::operator [~1_i] - Will be removed in version 1.2.0.")]]
519 [[deprecated(
"Replaced by xtd::forms::layout::arranged_element_collection::operator [~1_i] - Will be removed in version 1.2.0.")]]
525 [[deprecated(
"Replaced by xtd::forms::layout::arranged_element_collection::items().crbegin - Will be removed in version 1.2.0.")]]
530 [[deprecated(
"Replaced by xtd::forms::layout::arranged_element_collection::items().crend - Will be removed in version 1.2.0.")]]
536 [[deprecated(
"Replaced by xtd::forms::layout::arranged_element_collection::operator [0] - Will be removed in version 1.2.0.")]]
541 [[deprecated(
"Replaced by xtd::forms::layout::arranged_element_collection::operator [0] - Will be removed in version 1.2.0.")]]
547 [[deprecated(
"Replaced by xtd::forms::layout::arranged_element_collection::items().get_allocator - Will be removed in version 1.2.0.")]]
548 [[nodiscard]]
auto get_allocator() const noexcept {
return data_->items.get_allocator();}
554 template<
typename ...args_t>
555 [[deprecated(
"Replaced by xtd::forms::layout::arranged_element_collection::insert - Will be removed in version 1.2.0.")]]
557 auto index = pos -
items().begin();
558 data_->inserting =
true;
559 auto result = data_->items.insert(pos, args...);
560 data_->inserting =
false;
561 self_[index].owner =
this;
562 self_[index].pos = index;
564 if (data_->sorted)
sort();
571 template<
typename ...args_t>
572 [[deprecated(
"Replaced by xtd::forms::layout::arranged_element_collection::add - Will be removed in version 1.2.0.")]]
574 data_->items.emplace_back(args...);
576 self_[index].owner =
this;
577 self_[index].pos = index;
579 if (data_->sorted)
sort();
585 [[deprecated(
"Replaced by xtd::forms::layout::arranged_element_collection::remove_at - Will be removed in version 1.2.0.")]]
588 data_->erasing =
true;
589 auto result =
items().erase(pos);
590 data_->erasing =
false;
596 [[deprecated(
"Replaced by xtd::forms::layout::arranged_element_collection::remove_at - Will be removed in version 1.2.0.")]]
599 data_->erasing =
true;
600 auto result =
items().erase(pos);
601 data_->erasing =
false;
609 [[deprecated(
"Replaced by xtd::forms::layout::arranged_element_collection::remove_at - Will be removed in version 1.2.0.")]]
611 auto result =
items().end();
621 [[deprecated(
"Replaced by xtd::forms::layout::arranged_element_collection::remove_at - Will be removed in version 1.2.0.")]]
623 auto result =
items().end();
633 [[deprecated(
"Replaced by xtd::forms::layout::arranged_element_collection::remove_at - Will be removed in version 1.2.0.")]]
642 [[deprecated(
"Replaced by xtd::forms::layout::arranged_element_collection::insert - Will be removed in version 1.2.0.")]]
645 data_->inserting =
true;
646 auto result =
items().insert(pos, value);
647 data_->inserting =
false;
648 self_[index].owner =
this;
649 self_[index].pos = index;
651 if (data_->sorted)
sort();
658 [[deprecated(
"Replaced by xtd::forms::layout::arranged_element_collection::insert - Will be removed in version 1.2.0.")]]
661 data_->inserting =
true;
662 auto result =
items().insert(pos, value);
663 data_->inserting =
false;
664 self_[index].owner =
this;
665 self_[index].pos = index;
667 if (data_->sorted)
sort();
675 [[deprecated(
"Replaced by xtd::forms::layout::arranged_element_collection::insert - Will be removed in version 1.2.0.")]]
682 [[deprecated(
"Replaced by xtd::forms::layout::arranged_element_collection::remove(count() - 1) - Will be removed in version 1.2.0.")]]
690 [[deprecated(
"Replaced by xtd::forms::layout::arranged_element_collection::add - Will be removed in version 1.2.0.")]]
697 [[deprecated(
"Replaced by xtd::forms::layout::arranged_element_collection::add - Will be removed in version 1.2.0.")]]
699 add(std::move(item));
705 [[deprecated(
"Replaced by xtd::forms::layout::arranged_element_collection::add_range - Will be removed in version 1.2.0.")]]
712 [[deprecated(
"Replaced by xtd::forms::layout::arranged_element_collection::add_range - Will be removed in version 1.2.0.")]]
719 [[deprecated(
"Replaced by xtd::forms::layout::arranged_element_collection::add_range - Will be removed in version 1.2.0.")]]
726 template<
typename collection_t>
727 [[deprecated(
"Replaced by xtd::forms::layout::arranged_element_collection::add_range - Will be removed in version 1.2.0.")]]
734 template<
typename iterator_t>
735 [[deprecated(
"Replaced by xtd::forms::layout::arranged_element_collection::add_range - Will be removed in version 1.2.0.")]]
743 [[deprecated(
"Replaced by xtd::forms::layout::arranged_element_collection::to_array - Will be removed in version 1.2.0.")]]
749 [[deprecated(
"Replaced by xtd::forms::layout::arranged_element_collection::items().rbegin - Will be removed in version 1.2.0.")]]
750 [[nodiscard]]
auto rbegin() noexcept {
return data_->items.rbegin();}
754 [[deprecated(
"Replaced by xtd::forms::layout::arranged_element_collection::items().rbegin - Will be removed in version 1.2.0.")]]
755 [[nodiscard]]
auto rbegin() const noexcept {
return data_->items.rbegin();}
760 [[deprecated(
"Replaced by xtd::forms::layout::arranged_element_collection::items().rend - Will be removed in version 1.2.0.")]]
761 [[nodiscard]]
auto rend() noexcept {
return data_->items.rend();}
765 [[deprecated(
"Replaced by xtd::forms::layout::arranged_element_collection::items().rend - Will be removed in version 1.2.0.")]]
766 [[nodiscard]]
auto rend() const noexcept {
return data_->items.rend();}
770 [[deprecated(
"Replaced by xtd::forms::layout::arranged_element_collection::items().reserve - Will be removed in version 1.2.0.")]]
775 [[deprecated(
"Replaced by xtd::forms::layout::arranged_element_collection::items().shrink_to_fit - Will be removed in version 1.2.0.")]]
800 [[nodiscard]]
auto is_read_only() const noexcept ->
bool override {
return false;}
801 [[nodiscard]]
auto is_synchronized() const noexcept ->
bool override {
return false;}
802 [[nodiscard]]
auto sync_root() const noexcept -> const
xtd::
object&
override {
return data_->sync_root;}
804 struct data_collection {
805 mutable xtd::collections::generic::list < value_type >
items;
806 bool inserting =
false;
807 bool erasing =
false;
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Definition array.hpp:64
virtual auto items() const noexcept -> const base_type &
Returns the underlying base type items.
Definition basic_array.hpp:111
virtual auto length() const noexcept -> size_type
Gets a size that represents the total number of elements in all the dimensions of the array.
Definition basic_array.hpp:122
static constexpr xtd::usize max_value
Definition box_integer.hpp:71
virtual auto size() const noexcept -> xtd::usize
Definition collection_common.hpp:43
virtual auto operator<<(const type_t &item) -> icollection< type_t > &
Definition collection_common.hpp:52
virtual auto begin() const -> const_iterator
Definition enumerable_iterators.hpp:147
virtual auto end() const -> const_iterator
Definition enumerable_iterators.hpp:162
Defines methods to manipulate generic collections.
Definition icollection.hpp:45
virtual auto sync_root() const noexcept -> const xtd::object &=0
Gets an object that can be used to synchronize access to the the xtd::collections::generic::icollecti...
virtual auto clear() -> void=0
Removes all items from the xtd::collections::generic::icollection <type_t>.
virtual auto is_synchronized() const noexcept -> bool=0
Gets a value indicating whether access to the xtd::collections::generic::icollection <type_t> is sync...
virtual auto count() const noexcept -> xtd::usize=0
Gets the number of elements contained in the xtd::collections::generic::icollection <type_t>.
typename xtd::collections::generic::ienumerable< type_t >::value_type value_type
Represents the xtd::collections::generic::icollection value type.
Definition icollection.hpp:51
virtual auto is_read_only() const noexcept -> bool=0
Gets a value indicating whether the xtd::collections::generic::icollection <type_t> is read-only.
Exposes the enumerator, which supports a simple iteration over a collection of a specified type.
Definition ienumerable.hpp:40
typename xtd::collections::generic::extensions::enumerable_iterators< type_t, xtd::collections::generic::ienumerable< type_t > >::const_iterator const_iterator
Represents the const iterator of xtd::collections::generic::ienumerable value type.
Definition ienumerable.hpp:50
typename xtd::collections::generic::extensions::enumerable_iterators< type_t, xtd::collections::generic::ienumerable< type_t > >::iterator iterator
Represents the iterator of xtd::collections::generic::ienumerable value type.
Definition ienumerable.hpp:48
Supports a simple iteration over a generic collection.
Definition ienumerator.hpp:58
Represents a strongly typed list of objects that can be accessed by index. Provides methods to search...
Definition list.hpp:82
typename xtd::collections::generic::helpers::raw_array< value_type >::base_type base_type
Represents the list base type.
Definition list.hpp:90
Provides the base class for a generic read-only collection.
Definition read_only_collection.hpp:39
static auto throws(xtd::helpers::exception_case exception_case, const source_location &location=source_location::current()) -> void
Throws an exption with specified exception case.
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.hpp:40
object()=default
Create a new instance of the ultimate base class object.
Represents the version number of an assembly, operating system, or the xtd. This class cannot be inhe...
Definition version.hpp:115
@ index_out_of_range
The index is out of range.
Definition exception_case.hpp:61
@ argument_out_of_range
The argument is out of range.
Definition exception_case.hpp:35
@ invalid_operation
The operation is not valid.
Definition exception_case.hpp:65
#define self_
The self_ expression is a reference value expression whose value is the reference of the implicit obj...
Definition self.hpp:20
constexpr auto npos
Represents a value that is not a valid position in a collection.
Definition npos.hpp:26
xtd::sptr< type_t > ptr
The xtd::ptr object is a shared pointer.
Definition ptr.hpp:27
std::size_t usize
Represents an unsigned size of any object in bytes.
Definition usize.hpp:22
auto new_ptr(args_t &&... args) -> xtd::ptr< type_t >
The xtd::new_ptr operator creates a xtd::ptr object.
Definition new_ptr.hpp:24
@ other
The operating system is other.
Definition platform_id.hpp:60
The xtd::collections namespace contains interfaces and classes that define various collections of obj...
Definition any_pair.hpp:10
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8
auto first() const -> read_only_span< type_t, count >
Obtains a subspan consisting of the first count elements of the sequence.
Definition read_only_span.hpp:263
auto last() const -> read_only_span< type_t, count >
Obtains a subspan consisting of the last N elements of the sequence.
Definition read_only_span.hpp:288
Contains xtd::forms::layout::sorter_none class.
Implements a function object for performing comparisons. Unless specialised, invokes operator== on ty...
Definition equator.hpp:39
Contains xtd::helpers::throw_helper class.