6 #include <xtd/argument_out_of_range_exception> 7 #include <xtd/event_args> 8 #include <xtd/event_handler> 30 template<
typename type_t,
typename sorter_t = sorter_none>
40 template <
typename ...args_t>
41 value_type(args_t&& ...args) : type_t(args...) {}
43 if (value.owner) owner = value.owner;
44 if (owner !=
nullptr && !owner->inserting_ && !owner->erasing_) owner->
item_updated(pos, static_cast<type_t&>(const_cast<value_type&>(value)));
45 type_t::operator =(value);
49 if (value.owner) owner = value.owner;
50 if (owner !=
nullptr && !owner->inserting_ && !owner->erasing_) owner->
item_updated(pos, static_cast<type_t&>(value));
51 type_t::operator =(value);
54 operator type_t() {
return *
this;}
55 friend std::ostream& operator <<(std::ostream& os,
const value_type& value) {
return os << static_cast<const type_t&>(value);}
60 size_t pos = std::numeric_limits<size_t>::max();
78 using pointer =
typename std::allocator_traits<allocator_type>::pointer;
80 using const_pointer =
typename std::allocator_traits<allocator_type>::const_pointer;
82 using iterator =
typename std::vector<value_type>::iterator;
95 inline static const size_t npos = std::numeric_limits<size_t>::max();
115 for (
auto item : collection)
140 collection_[pos].pos = pos;
141 collection_[pos].owner =
this;
142 return collection_.at(pos);
212 bool empty() const noexcept {
return collection_.empty();}
234 bool sorted() const noexcept {
return sorted_;}
238 if (sorted_ != value) {
255 size_t index = pos -
begin();
257 iterator result = collection_.insert(pos, value);
259 (*this)[index].owner =
this;
260 (*this)[index].pos = index;
269 size_t index = pos -
begin();
271 iterator result = collection_.insert(pos, value);
273 (*this)[index].owner =
this;
274 (*this)[index].pos = index;
291 template<
typename ...args_t>
293 size_t index = pos -
begin();
295 iterator result = collection_.insert(pos, args...);
297 (*this)[index].owner =
this;
298 (*this)[index].pos = index;
306 template<
typename ...args_t>
308 collection_.push_back(args...);
309 size_t index = collection_.size() - 1;
310 (*this)[index].owner =
this;
311 (*this)[index].pos = index;
321 iterator result = collection_.erase(pos);
330 iterator result = collection_.erase(pos);
340 for (
iterator it = first; it <= last; ++it)
369 collection_.push_back(item);
370 size_t index = collection_.size() - 1;
371 (*this)[index].owner =
this;
372 (*this)[index].pos = index;
379 collection_.push_back(item);
380 size_t index = collection_.size() - 1;
381 (*this)[index].owner =
this;
382 (*this)[index].pos = index;
390 for (value_type item : collection)
396 for (value_type item : collection)
402 for (value_type item : collection)
407 template<
typename collection_t>
409 for (
auto& item : collection)
414 template<
typename iterator_t>
416 for (
auto it = begin; it !=
end; ++it)
429 std::vector<type_t> array;
430 std::for_each(collection_.begin(), collection_.end(), [&](
auto item) {array.push_back(item);});
445 collection_[pos].pos = pos;
446 collection_[pos].owner =
this;
447 return collection_[pos];
452 collection_[pos].pos = pos;
454 return collection_[pos];
475 mutable std::vector<value_type, allocator_type> collection_;
476 bool inserting_ =
false;
477 bool erasing_ =
false;
478 bool sorted_ =
false;
The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
Definition: system_report.h:17
#define csf_
Provides information about the current stack frame.
Definition: current_stack_frame.h:30
Represents an event.
Definition: event.h:21
Contains xtd::forms::layout::sorter_none class.
The exception that is thrown when one of the arguments provided to a method is out of range...
Definition: argument_out_of_range_exception.h:20
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes...
Definition: object.h:32
size_t size
Represents a size of any object in bytes.
Definition: types.h:195