8#include <xtd/argument_out_of_range_exception>
9#include <xtd/event_args>
10#include <xtd/event_handler>
13#include <xtd/size_object>
34 template<
class type_t,
class sorter_t = sorter_none>
44 template<
class ...args_t>
45 value_type(args_t&& ...args) : type_t(args...) {}
47 if (value.owner) owner = value.owner;
48 if (owner !=
nullptr && !owner->inserting_ && !owner->erasing_) owner->
on_item_updated(pos,
static_cast<type_t&
>(
const_cast<value_type&
>(value)));
49 type_t::operator =(value);
53 if (value.owner) owner = value.owner;
54 if (owner !=
nullptr && !owner->inserting_ && !owner->erasing_) owner->
on_item_updated(pos,
static_cast<type_t&
>(value));
55 type_t::operator =(value);
58 operator type_t() {
return *
this;}
59 friend std::ostream& operator <<(std::ostream& os,
const value_type& value) {
return os << static_cast<const type_t&>(value);}
63 friend class arranged_element_collection;
65 arranged_element_collection* owner =
nullptr;
82 using pointer =
typename std::allocator_traits<allocator_type>::pointer;
84 using const_pointer =
typename std::allocator_traits<allocator_type>::const_pointer;
86 using iterator =
typename std::vector<value_type>::iterator;
119 for (
auto item : collection)
144 collection_[pos].pos = pos;
145 collection_[pos].owner =
this;
146 return collection_.at(pos);
216 bool empty() const noexcept {
return collection_.empty();}
238 virtual bool sorted() const noexcept {
return sorted_;}
242 if (sorted_ != value) {
259 size_t index = pos -
begin();
261 iterator result = collection_.insert(pos, value);
263 (*this)[index].owner =
this;
264 (*this)[index].pos = index;
273 size_t index = pos -
begin();
275 iterator result = collection_.insert(pos, value);
277 (*this)[index].owner =
this;
278 (*this)[index].pos = index;
287 virtual void insert_at(
size_t index,
const value_type& value) {
287 virtual void insert_at(
size_t index,
const value_type& value) {
…}
295 template<
class ...args_t>
297 size_t index = pos -
begin();
299 iterator result = collection_.insert(pos, args...);
301 (*this)[index].owner =
this;
302 (*this)[index].pos = index;
310 template<
class ...args_t>
312 collection_.push_back(args...);
313 size_t index = collection_.size() - 1;
314 (*this)[index].owner =
this;
315 (*this)[index].pos = index;
325 iterator result = collection_.erase(pos);
334 iterator result = collection_.erase(pos);
373 collection_.push_back(item);
374 size_t index = collection_.size() - 1;
375 (*this)[index].owner =
this;
376 (*this)[index].pos = index;
383 collection_.push_back(item);
384 size_t index = collection_.size() - 1;
385 (*this)[index].owner =
this;
386 (*this)[index].pos = index;
394 for (value_type item : collection)
400 for (value_type item : collection)
406 for (value_type item : collection)
411 template<
class collection_t>
413 for (
auto& item : collection)
418 template<
class iterator_t>
420 for (
auto it =
begin; it !=
end; ++it)
447 collection_[pos].pos = pos;
448 collection_[pos].owner =
this;
449 return collection_[pos];
454 collection_[pos].pos = pos;
456 return collection_[pos];
502 mutable std::vector<value_type, allocator_type> collection_;
503 bool inserting_ =
false;
504 bool erasing_ =
false;
505 bool sorted_ =
false;
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Definition array.hpp:61
virtual size_type size() const noexcept
Returns the number of elements in the container, i.e. std::distance(xtd::array::begin(),...
Definition basic_array.hpp:229
static constexpr size_t max_value
Definition box_integer.hpp:67
static void throws(xtd::helpers::exception_case exception_case, const source_location &location=source_location::current())
Throws an exption with specified exception case.
object()=default
Create a new instance of the ultimate base class object.
@ argument_out_of_range
The argument is out of range.
Definition exception_case.hpp:35
size_t size
Represents a size of any object in bytes.
Definition size.hpp:23
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8
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.