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>
20#include <xtd/read_only_span>
22#include <xtd/usize_object>
44 template<
typename type_t,
typename sorter_t = sorter_none>
54 template<
typename ...args_t>
55 value_type(args_t&& ...args) : type_t(args...) {}
57 if (value.owner) owner = value.owner;
58 if (owner !=
nullptr && !owner->data_->inserting && !owner->data_->erasing) owner->on_item_updated(pos,
static_cast<type_t&
>(
const_cast<value_type&
>(value)));
59 type_t::operator =(value);
63 if (value.owner) owner = value.owner;
64 if (owner !=
nullptr && !owner->data_->inserting && !owner->data_->erasing) owner->on_item_updated(pos,
static_cast<type_t&
>(value));
65 type_t::operator =(value);
68 operator type_t() {
return self_;}
73 friend class arranged_element_collection;
75 arranged_element_collection* owner =
nullptr;
143 data_ = std::move(collection.data_);
159 template <std::input_iterator input_iterator_t>
181 [[nodiscard]]
auto count() const noexcept ->
size_type override {
return data_->items.count();}
185 [[nodiscard]]
auto data() ->
pointer {
return data_->items.data();}
192 [[nodiscard]]
const auto&
items()
const {
return data_->items.items();}
195 [[nodiscard]]
auto&
items() {
return data_->items.items();}
199 [[nodiscard]]
virtual auto sorted() const noexcept ->
bool {
return data_->sorted;}
203 if (data_->sorted == value)
return self_;
204 data_->sorted = value;
205 if (data_->sorted)
sort();
215 auto add(
const type_t& item) ->
void override {
216 data_->items.add(item);
218 static_cast<value_type&
>(
self_[
index]).owner =
this;
221 if (data_->sorted)
sort();
225 virtual auto add(type_t&& item) ->
void {
226 data_->items.add(item);
228 static_cast<value_type&
>(
self_[
index]).owner =
this;
231 if (data_->sorted)
sort();
237 for (
const auto& item : collection)
242 virtual auto add_range(
const std::vector<type_t>& collection) ->
void {
243 for (
const auto& item : collection)
248 virtual auto add_range(
const std::initializer_list<type_t>& collection) ->
void {
249 for (
const auto& item : collection)
254 template<
typename collection_t>
256 for (
auto& item : collection)
261 template<
typename collection_t>
262 auto add_range(
const collection_t& collection) ->
void {
263 for (
const auto& item : collection)
277 [[nodiscard]]
auto contains(
const type_t& item)
const noexcept ->
bool override {
278 return data_->items.contains(item);
288 for (
const type_t& item :
self_) {
290 array[array_index +
i++] = item;
300 const type_t& current()
const override {
303 return items_[index_];
306 bool move_next()
override {
308 return ++index_ < items_.count();
311 void reset()
override {
312 version_ = items_.items().version();
330 data_->inserting =
true;
332 data_->inserting =
false;
333 static_cast<value_type&
>(
self_[
index]).owner =
this;
336 if (data_->sorted)
sort();
351 auto remove(
const type_t& item) ->
bool override {
352 if (
count() == 0)
return false;
366 data_->erasing =
true;
368 data_->erasing =
false;
434 data_->items[
index].owner =
this;
435 return data_->items[
index];
444 return data_->items[
index];
515 [[nodiscard]]
auto operator ==(
const arranged_element_collection& value)
const ->
bool {
return data_->items == value.data_->items;}
552 [[deprecated(
"Replaced by xtd::forms::layout::arranged_element_collection::items().max_size - Will be removed in version 1.2.0.")]]
563 [[deprecated(
"Replaced by xtd::forms::layout::arranged_element_collection::operator [] - Will be removed in version 1.2.0.")]]
565 data_->items[pos].pos = pos;
566 data_->items[pos].owner =
this;
567 return data_->items.at(pos);
573 [[deprecated(
"Replaced by xtd::forms::layout::arranged_element_collection::operator [] - Will be removed in version 1.2.0.")]]
579 [[deprecated(
"Replaced by xtd::forms::layout::arranged_element_collection::operator [~1_i] - Will be removed in version 1.2.0.")]]
584 [[deprecated(
"Replaced by xtd::forms::layout::arranged_element_collection::operator [~1_i] - Will be removed in version 1.2.0.")]]
590 [[deprecated(
"Replaced by xtd::forms::layout::arranged_element_collection::items().crbegin - Will be removed in version 1.2.0.")]]
595 [[deprecated(
"Replaced by xtd::forms::layout::arranged_element_collection::items().crend - Will be removed in version 1.2.0.")]]
601 [[deprecated(
"Replaced by xtd::forms::layout::arranged_element_collection::operator [0] - Will be removed in version 1.2.0.")]]
606 [[deprecated(
"Replaced by xtd::forms::layout::arranged_element_collection::operator [0] - Will be removed in version 1.2.0.")]]
612 [[deprecated(
"Replaced by xtd::forms::layout::arranged_element_collection::items().get_allocator - Will be removed in version 1.2.0.")]]
613 [[nodiscard]]
auto get_allocator() const noexcept {
return data_->items.get_allocator();}
619 template<
typename ...args_t>
620 [[deprecated(
"Replaced by xtd::forms::layout::arranged_element_collection::insert - Will be removed in version 1.2.0.")]]
623 data_->inserting =
true;
624 auto result = data_->items.insert(pos, args...);
625 data_->inserting =
false;
629 if (data_->sorted)
sort();
636 template<
typename ...args_t>
637 [[deprecated(
"Replaced by xtd::forms::layout::arranged_element_collection::add - Will be removed in version 1.2.0.")]]
639 data_->items.emplace_back(args...);
644 if (data_->sorted)
sort();
650 [[deprecated(
"Replaced by xtd::forms::layout::arranged_element_collection::remove_at - Will be removed in version 1.2.0.")]]
653 data_->erasing =
true;
654 auto result =
items().erase(pos);
655 data_->erasing =
false;
661 [[deprecated(
"Replaced by xtd::forms::layout::arranged_element_collection::remove_at - Will be removed in version 1.2.0.")]]
664 data_->erasing =
true;
665 auto result =
items().erase(pos);
666 data_->erasing =
false;
674 [[deprecated(
"Replaced by xtd::forms::layout::arranged_element_collection::remove_at - Will be removed in version 1.2.0.")]]
676 auto result =
items().end();
686 [[deprecated(
"Replaced by xtd::forms::layout::arranged_element_collection::remove_at - Will be removed in version 1.2.0.")]]
688 auto result =
items().end();
698 [[deprecated(
"Replaced by xtd::forms::layout::arranged_element_collection::remove_at - Will be removed in version 1.2.0.")]]
707 [[deprecated(
"Replaced by xtd::forms::layout::arranged_element_collection::insert - Will be removed in version 1.2.0.")]]
710 data_->inserting =
true;
711 auto result =
items().insert(pos, value);
712 data_->inserting =
false;
716 if (data_->sorted)
sort();
723 [[deprecated(
"Replaced by xtd::forms::layout::arranged_element_collection::insert - Will be removed in version 1.2.0.")]]
726 data_->inserting =
true;
727 auto result =
items().insert(pos, value);
728 data_->inserting =
false;
732 if (data_->sorted)
sort();
740 [[deprecated(
"Replaced by xtd::forms::layout::arranged_element_collection::insert - Will be removed in version 1.2.0.")]]
747 [[deprecated(
"Replaced by xtd::forms::layout::arranged_element_collection::remove(count() - 1) - Will be removed in version 1.2.0.")]]
755 [[deprecated(
"Replaced by xtd::forms::layout::arranged_element_collection::add - Will be removed in version 1.2.0.")]]
762 [[deprecated(
"Replaced by xtd::forms::layout::arranged_element_collection::add - Will be removed in version 1.2.0.")]]
764 add(std::move(item));
770 [[deprecated(
"Replaced by xtd::forms::layout::arranged_element_collection::add_range - Will be removed in version 1.2.0.")]]
777 [[deprecated(
"Replaced by xtd::forms::layout::arranged_element_collection::add_range - Will be removed in version 1.2.0.")]]
784 [[deprecated(
"Replaced by xtd::forms::layout::arranged_element_collection::add_range - Will be removed in version 1.2.0.")]]
791 template<
typename collection_t>
792 [[deprecated(
"Replaced by xtd::forms::layout::arranged_element_collection::add_range - Will be removed in version 1.2.0.")]]
799 template<
typename iterator_t>
800 [[deprecated(
"Replaced by xtd::forms::layout::arranged_element_collection::add_range - Will be removed in version 1.2.0.")]]
808 [[deprecated(
"Replaced by xtd::forms::layout::arranged_element_collection::to_array - Will be removed in version 1.2.0.")]]
814 [[deprecated(
"Replaced by xtd::forms::layout::arranged_element_collection::items().rbegin - Will be removed in version 1.2.0.")]]
815 [[nodiscard]]
auto rbegin() noexcept {
return data_->items.rbegin();}
819 [[deprecated(
"Replaced by xtd::forms::layout::arranged_element_collection::items().rbegin - Will be removed in version 1.2.0.")]]
820 [[nodiscard]]
auto rbegin() const noexcept {
return data_->items.rbegin();}
825 [[deprecated(
"Replaced by xtd::forms::layout::arranged_element_collection::items().rend - Will be removed in version 1.2.0.")]]
826 [[nodiscard]]
auto rend() noexcept {
return data_->items.rend();}
830 [[deprecated(
"Replaced by xtd::forms::layout::arranged_element_collection::items().rend - Will be removed in version 1.2.0.")]]
831 [[nodiscard]]
auto rend() const noexcept {
return data_->items.rend();}
835 [[deprecated(
"Replaced by xtd::forms::layout::arranged_element_collection::items().reserve - Will be removed in version 1.2.0.")]]
840 [[deprecated(
"Replaced by xtd::forms::layout::arranged_element_collection::items().shrink_to_fit - Will be removed in version 1.2.0.")]]
865 [[nodiscard]]
auto is_read_only() const noexcept ->
bool override {
return false;}
866 [[nodiscard]]
auto is_synchronized() const noexcept ->
bool override {
return false;}
867 [[nodiscard]]
auto sync_root() const noexcept -> const
xtd::
object&
override {
return data_->sync_root;}
869 struct data_collection {
870 mutable xtd::collections::generic::list < value_type >
items;
871 bool inserting =
false;
872 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:84
typename xtd::collections::generic::helpers::raw_array< value_type >::base_type base_type
Represents the list base type.
Definition list.hpp:92
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 a range that has start and end indexes.
Definition range.hpp:38
Definition __span_definitions.hpp:16
Represents a non-owning view over a contiguous sequence of objects.
Definition span.hpp:62
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:245
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:286
Contains xtd::forms::layout::sorter_none class.
Implements a function object for performing comparisons. Unless specialised, invokes operator== on ty...
Definition equator.hpp:39
Represents a type that can be used to index a collection either from the beginning or the end.
Definition index.hpp:38
auto get_offset(value_type length) const noexcept -> xtd::usize
Calculates the offset from the start of the collection using the specified collection length.
Contains xtd::helpers::throw_helper class.