xtd 0.2.0
Loading...
Searching...
No Matches
list.hpp
Go to the documentation of this file.
1
4#pragma once
6#include "helpers/equator.hpp"
7#include "comparer.hpp"
8#include "ilist.hpp"
9#define __XTD_CORE_INTERNAL__
12#undef __XTD_CORE_INTERNAL__
14#include "../../action.hpp"
15#include "../../comparison.hpp"
16#include "../../converter.hpp"
17#include "../../intptr.hpp"
18#include "../../is.hpp"
19#include "../../object.hpp"
20#include "../../optional.hpp"
21#include "../../new_ptr.hpp"
22#include "../../predicate.hpp"
23#include "../../self.hpp"
24#include "../../string.hpp"
25
27namespace xtd {
29 namespace collections {
31 namespace generic {
78 template<class type_t, class allocator_t>
79 class list : public xtd::object, public xtd::collections::generic::ilist<type_t>, public xtd::iequatable<xtd::collections::generic::list<type_t, allocator_t >> {
80 struct __comparer__ {
81 __comparer__(const xtd::collections::generic::icomparer<type_t>& comparer) : comparer_(comparer) {}
82 bool operator()(const type_t& e1, const type_t& e2) const {return comparer_.compare(e1, e2) < 0;}
84 };
85
86 struct __comparison_comparer__ {
87 __comparison_comparer__(xtd::comparison<const type_t&> comparison) : comparison_(comparison) {}
88 bool operator()(const type_t& e1, const type_t& e2) const {return comparison_(e1, e2) < 0;}
90 };
91
92 struct __enumerator__ : public ienumerator<type_t> {
93 public:
94 explicit __enumerator__(const list& items, xtd::size version) : items_(items), version_(version) {}
95
96 const type_t& current() const override {
97 if (version_ != items_.data_->items.version()) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::invalid_operation, "Collection was modified; enumeration operation may not execute.");
98 if (index_ < items_.count()) return items_[index_];
99 return default_value_;
100 }
101
102 bool move_next() override {
103 if (version_ != items_.data_->items.version()) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::invalid_operation, "Collection was modified; enumeration operation may not execute.");
104 return ++index_ < items_.count();
105 }
106
107 void reset() override {
108 version_ = items_.data_->items.version();
109 index_ = list::npos;
110 }
111
112 protected:
113 const list& items_;
114 xtd::size index_ = list::npos;
115 xtd::size version_ = 0;
116 type_t default_value_;
117 };
118
119 public:
121
124 using value_type = typename ilist<type_t>::value_type;
126 using base_type = typename __xtd_raw_array_data__<value_type>::base_type;
138 using const_pointer = const value_type*;
142
144
154 list() noexcept = default;
161 explicit list(size_type capacity) {self_.capacity(capacity);}
172 list(const list& list) {*data_ = *list.data_;}
176 data_ = std::move(list.data_);
177 list.data_ = new_ptr<list_data>();
178 }
179
181 list(const base_type& list) {data_->items = list;}
184 list(base_type&& list) {data_->items = std::move(list);}
187 list(std::initializer_list<type_t> items) {add_range(items);}
192 template <std::input_iterator input_iterator_t>
193 list(input_iterator_t first, input_iterator_t last) {
194 for (auto iterator = first; iterator != last; ++iterator)
195 add(*iterator);
196 }
197
198
200
224 size_type capacity() const noexcept {return data_->items.capacity();}
248 void capacity(size_type value) {
251 if (value == capacity()) return;
252 if (value < capacity()) data_->items.shrink_to_fit();
253 data_->items.reserve(value);
254 }
255
277 size_type count() const noexcept override {return data_->items.size();}
278
282 pointer data() noexcept {return reinterpret_cast<pointer>(data_->items.data());}
286 const_pointer data() const noexcept {return reinterpret_cast<const_pointer>(data_->items.data());}
287
290 const auto& items() const noexcept {return data_->items;}
293 auto& items() noexcept {return data_->items;}
295
297
312 void add(const type_t& item) override {data_->items.push_back(item);}
326 void add(type_t&& item) {data_->items.push_back(std::move(item));}
327
336 void add_range(const xtd::collections::generic::ienumerable<type_t>& enumerable) {insert_range(count(), enumerable);}
337
346 void add_range(std::initializer_list<type_t> il) {insert_range(count(), il);}
347
349 template<class enumerable_t>
350 void add_range(const enumerable_t& enumerable) {insert_range(count(), enumerable);}
352
358
384 xtd::size binary_search(const type_t& item, const xtd::collections::generic::icomparer<type_t>& comparer) const noexcept {return binary_search(0, count(), item, comparer);}
401 auto first = data_->items.begin();
402 auto last = data_->items.begin();
403 std::advance(first, index);
404 std::advance(last, index + count);
405 auto position = std::lower_bound(first, last, item, __comparer__{comparer});
406
407 if (position != data_->items.end() && !comparer.compare(item, *position))
408 return std::distance(data_->items.begin(), position);
409 return ~std::distance(data_->items.begin(), position);
410 }
411
416 void clear() override {data_->items.clear();}
417
421 bool contains(const type_t& value) const noexcept override {
422 return index_of(value) != npos;
423 }
424
432 template<class output_t, class converter_t>
434 auto result = list<output_t> {};
435 auto apply_converter = xtd::converter<output_t, const type_t&> {converter};
436 for (const auto& item : self_)
437 result.add(apply_converter(item));
438 return result;
439 }
440
459 void copy_to(xtd::array<type_t>& array, size_type array_index) const override {copy_to(0, array, array_index, count());}
476 auto i = size_type {0}, c = size_type {0};
477 for (const type_t& item : self_) {
478 if (i >= index + count) return;
479 if (i >= index) {
480 array[array_index + c] = item;
481 c += 1;
482 }
483 i += 1;
484 }
485 }
486
492 data_->items.reserve(capacity);
493 return self_.capacity();
494 }
495
502 bool equals(const object& obj) const noexcept override {return is<list<value_type>>(obj) && equals(static_cast<const list<value_type>& > (obj));}
506 bool equals(const list& obj) const noexcept override {
507 if (count() != obj.count()) return false;
508 for (size_type i = 0; i < count(); i++)
509 if (!helpers::equator<type_t> {}(self_[i], obj[i])) return false;
510 return true;
511 }
512
524 template<class predicate_t>
525 bool exists(predicate_t match) const {
526 return find_index(match) != npos;
527 }
528
540 template<class predicate_t>
541 optional<type_t> find(predicate_t match) const {
542 auto index = find_index(match);
543 if (index == npos) return nullopt;
544 return self_[index];
545 }
546
558 template<class predicate_t>
559 list find_all(predicate_t match) const {
561 auto result = list {};
562 for (const auto& item : self_)
563 if (predicate(item)) result.add(item);
564 return result;
565 }
566
572 template<class predicate_t>
573 xtd::size find_index(predicate_t match) const {return find_index(0, count(), match);}
581 template<class predicate_t>
582 xtd::size find_index(xtd::size start_index, predicate_t match) const {return find_index(start_index, count() - start_index, match);}
591 template<class predicate_t>
592 xtd::size find_index(xtd::size start_index, xtd::size count, predicate_t match) const {
595 for (auto index = start_index; index < start_index + count; ++index)
596 if (predicate(self_[index])) return index;
597 return npos;
598 }
599
611 template<class predicate_t>
612 optional<type_t> find_last(predicate_t match) const {
613 auto index = find_last_index(match);
614 if (index == npos) return nullopt;
615 return self_[index];
616 }
617
623 template<class predicate_t>
624 xtd::size find_last_index(predicate_t match) const {return find_last_index(count() - 1, count(), match);}
632 template<class predicate_t>
633 xtd::size find_last_index(xtd::size start_index, predicate_t match) const {return find_last_index(start_index, start_index + 1, match);}
642 template<class predicate_t>
643 xtd::size find_last_index(xtd::size start_index, xtd::size count, predicate_t match) const {
646 auto end_index = start_index + 1 - count;
647 for (auto index = start_index; ; --index) {
648 if (predicate(self_[index])) return index;
649 if (index == end_index) break;
650 }
651 return npos;
652 }
653
662 template<class action_t>
663 void for_each(action_t action) {
664 auto apply_action = xtd::action<const type_t&> {action};
665 for (const auto& item : self_)
666 apply_action(item);
667 }
668
671 enumerator<value_type> get_enumerator() const noexcept override {
672 return {new_ptr<__enumerator__>(self_, data_->items.version())};
673 }
674
689 return list<type_t> {data_->items.begin() + index, data_->items.begin() + index + count};
690 }
691
695 size_type index_of(const type_t& value) const noexcept override {
696 if (count() == 0) return npos;
697 return index_of(value, 0, count());
698 }
699
704 size_type index_of(const type_t& value, size_type index) const {return index_of(value, index, count() - index);}
711 size_type index_of(const type_t& value, size_type index, size_type count) const {
712 return find_index(index, count, delegate_(auto n) {return helpers::equator<type_t> {}(n, value);});
713 }
714
720 void insert(size_type index, const type_t& value) override {
722 data_->items.insert(data_->items.begin() + index, value);
723 }
729 void insert(size_type index, type_t&& value) {
731 data_->items.insert(data_->items.begin() + index, std::move(value));
732 }
733
743 void insert_range(size_type index, const xtd::collections::generic::ienumerable<type_t>& enumerable) {
745
746 // If the collection is this instance, it must be copied to avoid an infinite loop.
747 if (static_cast<const void*>(&enumerable) == static_cast<const void*>(this)) {
748 insert_range(index, list(enumerable));
749 return;
750 }
751
752 data_->items.insert(data_->items.begin() + index, enumerable.begin(), enumerable.end());
753 }
763 void insert_range(size_type index, const std::initializer_list<type_t>& items) {
765 data_->items.insert(data_->items.begin() + index, items.begin(), items.end());
766 }
767
769 template<class collection_t>
770 void insert_range(size_type index, const collection_t& items) {
772
773 // If the collection is this instance, it must be copied to avoid an infinite loop.
774 if (static_cast<const void*>(&items) == static_cast<const void*>(this)) {
775 insert_range(index, list(items));
776 return;
777 }
778
779 data_->items.insert(data_->items.begin() + index, items.begin(), items.end());
780 }
782
786 size_type last_index_of(const type_t& value) const noexcept {
787 if (count() == 0) return npos;
788 return last_index_of(value, count() - 1, count());
789 }
795 size_type last_index_of(const type_t& value, size_type index) const {
796 return last_index_of(value, index, index + 1);
797 }
798
804 size_type last_index_of(const type_t& value, size_type index, size_type count) const {
805 return find_last_index(index, count, delegate_(auto n) {return helpers::equator<type_t> {}(n, value);});
806 }
807
813 bool remove(const type_t& item) noexcept override {
814 auto index = index_of(item);
815 if (index == npos) return false;
816 remove_at(index);
817 return true;
818 }
819
831 template<class predicate_t>
832 xtd::size remove_all(predicate_t match) {
834 auto count = xtd::size {0};
835 auto iterator = data_->items.begin();
836 while (iterator != data_->items.end())
837 if (!predicate(*iterator)) iterator++;
838 else {
839 iterator = data_->items.erase(iterator);
840 ++count;
841 }
842 return count;
843 }
844
848 void remove_at(size_type index) override {
850 data_->items.erase(data_->items.begin() + index);
851 }
852
863 data_->items.erase(data_->items.begin() + index, data_->items.begin() + index + count);
864 }
865
871 virtual void resize(size_type count) {resize(count, value_type {});}
878 virtual void resize(size_type count, const value_type& value) {
880 if (count == self_.count()) return;
881 data_->items.resize(count, value);
882 }
883
890 void reverse() {reverse(0, count());}
902 data_->items.increment_version();
903 std::reverse(data_->items.begin() + index, data_->items.begin() + index + count);
904 }
905
913 return list<type_t> {data_->items.begin() + start, data_->items.begin() + start + length};
914 }
915
926
933 data_->items.increment_version();
934 std::sort(data_->items.begin(), data_->items.end(), __comparison_comparer__ {comparison});
935 return self_;
936 }
937
946
957 data_->items.increment_version();
958 std::sort(data_->items.begin() + index, data_->items.begin() + index + count, __comparer__ {comparer});
959 return self_;
960 }
961
970
973 string to_string() const noexcept override {return xtd::string::format("[{}]", xtd::string::join(", ", self_));}
974
995 void trim_excess() {data_->items.shrink_to_fit();}
996
1008 template<class prediacate_t>
1009 bool true_for_all(prediacate_t match) const {
1011 for (const auto& item : self_)
1012 if (!predicate(item)) return false;
1013 return true;
1014 }
1015
1016
1018
1023 list& operator =(const list& other) = default;
1027 list& operator =(list&& other) noexcept {
1028 data_->items = std::move(other.data_->items);
1029 return self_;
1030 }
1031
1034 list& operator =(const std::initializer_list<type_t>& items) {
1035 data_->items = items;
1036 return self_;
1037 }
1038
1043 const_reference operator [](size_type index) const override {
1045 return data_->items[index];
1046 }
1047
1053 return data_->items[index];
1054 }
1055
1058 operator const_base_type& () const noexcept {return data_->items;}
1061 operator base_type& () noexcept {return data_->items;}
1063
1064 private:
1065 bool is_fixed_size() const noexcept override {return false;}
1066 bool is_read_only() const noexcept override {return false;}
1067 bool is_synchronized() const noexcept override {return false;}
1068 const xtd::object& sync_root() const noexcept override {return data_->sync_root;}
1069
1070 struct list_data {
1071 __xtd_raw_array_data__<value_type> items;
1072 xtd::object sync_root;
1073 };
1074
1076 };
1077
1079 // C++17 deduction guides for xtd::collections::generic::list
1080 // {
1081 template<class type_t>
1082 list(std::initializer_list<type_t>) -> list<type_t, helpers::allocator<type_t >>;
1083
1084 template<class type_t>
1086
1087 template<class type_t>
1088 list(const ilist<type_t>&) -> list<type_t, helpers::allocator<type_t >>;
1089
1090 template<class type_t>
1091 list(const std::vector<type_t>&) -> list<type_t, helpers::allocator<type_t >>;
1092
1093 template<class type_t, class allocator_t = helpers::allocator<type_t>>
1095
1096 template<class type_t>
1097 list(std::vector<type_t>&&) -> list<type_t, helpers::allocator<type_t >>;
1098
1099 template<class type_t, class allocator_t = helpers::allocator<type_t>>
1101 // }
1103 }
1104 }
1105}
1106
1109 template <class enumerable_t, class source_t>
1110 inline xtd::collections::generic::list<source_t> enumerable<enumerable_t, source_t>::to_list() const noexcept {
1111 return xtd::linq::enumerable::to_list(base());
1112 }
1113}
1114
1115namespace xtd::linq {
1116 template <class source_t>
1117 inline auto enumerable::to_list(const xtd::collections::generic::ienumerable<source_t>& source) noexcept {
1118 auto result = xtd::collections::generic::list<source_t> {};
1119 result = xtd::collections::generic::list<source_t> {source};
1120 return result;
1121 }
1122}
Contains xtd::collections::generic::list definitions.
Contains xtd_raw_array_data class.
Contains xtd::action delegate.
Contains xtd::collections::generic::helpers::allocator alias.
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Definition array.hpp:63
Provides a base class for implementations of the xtd::collections::generic::icomparer <type_t> generi...
Definition comparer.hpp:33
result_type compare(const first_argument_type &x, const second_argument_type &y) const noexcept override
Compares two entities and returns a value indicating whether one is less than, equal to,...
Definition comparer.hpp:66
static const comparer< xtd::any_object > default_comparer
Definition comparer.hpp:50
virtual const_iterator begin() const
Returns an iterator to the first element of the enumerable.
Definition enumerable_iterators.hpp:141
virtual const_iterator end() const
Returns an iterator to the element following the last element of the enumerable.
Definition enumerable_iterators.hpp:156
list< source_t > to_list() const noexcept
Creates a xtd::collections::generic::list <type_t> from an xtd::collections::generic::ienumerable <ty...
Exposes a method that compares two objects.
Definition icomparer.hpp:30
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:79
xtd::size find_last_index(xtd::size start_index, predicate_t match) const
Searches for an element that matches the conditions defined by the specified predicate,...
Definition list.hpp:633
list< type_t > & sort()
Sorts the elements in the entire xtd::collections::generic::list <type_t> using the default comparer.
Definition list.hpp:925
void add(const type_t &item) override
Adds an object to the end of the xtd::collections::generic::list <type_t>.
Definition list.hpp:312
xtd::size binary_search(const type_t &item, const xtd::collections::generic::icomparer< type_t > &comparer) const noexcept
Searches the entire sorted xtd::collections::generic::list <type_t> for an element using the specifie...
Definition list.hpp:384
list< type_t > & sort(const xtd::collections::generic::icomparer< type_t > &comparer)
Sorts the elements in the entire xtd::collections::generic::list <type_t> using the specified compare...
Definition list.hpp:943
xtd::size binary_search(const type_t &item) const noexcept
Searches the entire sorted xtd::collections::generic::list <type_t> for an element using the default ...
Definition list.hpp:372
list get_range(size_type index, size_type count)
Creates a shallow copy of a range of elements in the source xtd::collections::generic::list <type_t>.
Definition list.hpp:687
list< type_t > slice(size_type start, size_type length) const
Creates a shallow copy of a range of elements in the source xtd::collections::generic::list <type_t>.
Definition list.hpp:911
list< type_t > & sort(xtd::size index, xtd::size count, const xtd::collections::generic::icomparer< type_t > &comparer)
Sorts the elements in a range of elements in xtd::collections::generic::list <type_t> using the speci...
Definition list.hpp:955
list(base_type &&list)
Move constructor with specified base type list.
Definition list.hpp:184
bool equals(const object &obj) const noexcept override
Determines whether the specified object is equal to the current object.
Definition list.hpp:502
void for_each(action_t action)
Performs the specified action on each element of the xtd::collections::generic::list <type_t>.
Definition list.hpp:663
void remove_range(size_type index, size_type count)
Removes a range of elements from the xtd::collections::generic::list <type_t>.
Definition list.hpp:861
void capacity(size_type value)
Sets the total number of elements the internal data structure can hold without resizing.
Definition list.hpp:248
list find_all(predicate_t match) const
Retrieves all the elements that match the conditions defined by the specified predicate.
Definition list.hpp:559
const value_type * const_pointer
Definition list.hpp:138
const base_type const_base_type
Definition list.hpp:128
bool remove(const type_t &item) noexcept override
Removes the first occurrence of a specific object from the xtd::collections::generic::list <type_t>.
Definition list.hpp:813
xtd::size find_last_index(predicate_t match) const
Searches for an element that matches the conditions defined by the specified predicate,...
Definition list.hpp:624
bool true_for_all(prediacate_t match) const
Determines whether every element in the xtd::collections::generic::list <type_t> matches the conditio...
Definition list.hpp:1009
xtd::array< value_type > to_array() const noexcept
Copies the elements of the xtd::collections::generic::list <type_t> to a new array.
Definition list.hpp:969
void reverse()
Reverses the order of the elements in the entire xtd::collections::generic::list <type_t>.
Definition list.hpp:890
void remove_at(size_type index) override
Removes the element at the specified index of the xtd::collections::generic::list <type_t>.
Definition list.hpp:848
void copy_to(size_type index, xtd::array< type_t > &array, size_type array_index, size_type count) const
Copies the entire xtd::collections::generic::list <type_t> to a compatible one-dimensional array,...
Definition list.hpp:474
const_reference operator[](size_type index) const override
Returns a reference to the element at specified location index.
Definition list.hpp:1043
void copy_to(xtd::array< type_t > &array, size_type array_index) const override
Copies the entire xtd::colllections::generic::list <type_t> to a compatible one-dimensional array,...
Definition list.hpp:459
size_type last_index_of(const type_t &value, size_type index, size_type count) const
Determines the last index of a specific item in the xtd::collections::generic::list <type_t>.
Definition list.hpp:804
void clear() override
Removes all elements from the xtd::collections::generic::list <type_t>.
Definition list.hpp:416
string to_string() const noexcept override
Returns a xtd::string that represents the current object.
Definition list.hpp:973
xtd::size find_last_index(xtd::size start_index, xtd::size count, predicate_t match) const
Searches for an element that matches the conditions defined by the specified predicate,...
Definition list.hpp:643
list(std::initializer_list< type_t > items)
Constructs the container with the contents of the specified initializer list, and allocator.
Definition list.hpp:187
size_type index_of(const type_t &value) const noexcept override
Determines the index of a specific item in the xtd::collections::generic::list <type_t>.
Definition list.hpp:695
size_type last_index_of(const type_t &value, size_type index) const
Determines the index of a specific item in the xtd::collections::generic::list <type_t>.
Definition list.hpp:795
list(const list &list)
Default copy constructor with specified list.
Definition list.hpp:172
xtd::size binary_search(xtd::size index, xtd::size count, const type_t &item, const xtd::collections::generic::icomparer< type_t > &comparer) const
Searches a range of elements in the sorted xtd::collections::generic::list <type_t> for an element us...
Definition list.hpp:399
list() noexcept=default
Initializes a new instance of the xtd::collections::generic::list class that is empty.
void copy_to(xtd::array< type_t > &array) const
Copies the entire xtd::collections::generic::list <type_t> to a compatible one-dimensional array.
Definition list.hpp:451
auto & items() noexcept
Returns the underlying base type items.
Definition list.hpp:293
xtd::size size_type
Definition list.hpp:130
xtd::size find_index(predicate_t match) const
Searches for an element that matches the conditions defined by the specified predicate,...
Definition list.hpp:573
const value_type & const_reference
Definition list.hpp:134
list< type_t > & sort(xtd::comparison< const type_t & > comparison)
Sorts the elements in the entire xtd::collections::generic::list <type_t> using the specified xtd::co...
Definition list.hpp:932
xtd::size find_index(xtd::size start_index, predicate_t match) const
Searches for an element that matches the conditions defined by the specified predicate,...
Definition list.hpp:582
xtd::size ensure_capacity(xtd::size capacity)
Ensures that the capacity of this list is at least the specified capacity. If the current capacity is...
Definition list.hpp:491
bool equals(const list &obj) const noexcept override
Indicates whether the current object is equal to another object of the same type.
Definition list.hpp:506
void reverse(size_type index, size_type count)
Reverses the order of the elements in the specified range.
Definition list.hpp:900
size_type count() const noexcept override
Gets the number of elements contained in the xtd::collections::generic::list <type_t>.
Definition list.hpp:277
typename ilist< xtd::any_object >::value_type value_type
Definition list.hpp:124
list(list &&list)
Move constructor with specified list.
Definition list.hpp:175
list & operator=(const list &other)=default
Copy assignment operator. Replaces the contents with a copy of the contents of other.
list(input_iterator_t first, input_iterator_t last)
Constructs the container with the contents of the range [first, last).
Definition list.hpp:193
value_type & reference
Definition list.hpp:132
enumerator< value_type > get_enumerator() const noexcept override
Returns an enumerator that iterates through the xtd::collections::generic::list <type_t>.
Definition list.hpp:671
void add_range(const xtd::collections::generic::ienumerable< type_t > &enumerable)
Adds copy of elements from the specified collection to the end of the xtd::collections::generic::list...
Definition list.hpp:336
virtual void resize(size_type count, const value_type &value)
Resizes the container to contain count elements, does nothing if count == size(). / @param count The ...
Definition list.hpp:878
read_only_collection as_read_only() const noexcept
Returns a read-only xtd::collections::object_model::read_only_collection <type_t> wrapper for the cur...
Definition list.hpp:357
void add(type_t &&item)
Adds an object to the end of the xtd::collections::generic::list <type_t>.
Definition list.hpp:326
typename __xtd_raw_array_data__< value_type >::base_type base_type
Definition list.hpp:126
list(const xtd::collections::generic::ienumerable< type_t > &collection)
Initializes a new instance of the xtd::collections::generic::list <type_t> class that contains elemen...
Definition list.hpp:169
xtd::size remove_all(predicate_t match)
Removes all the elements that match the conditions defined by the specified predicate.
Definition list.hpp:832
xtd::size find_index(xtd::size start_index, xtd::size count, predicate_t match) const
Searches for an element that matches the conditions defined by the specified predicate,...
Definition list.hpp:592
void trim_excess()
Sets the capacity to the actual number of elements in the xtd::collections::generic::list <type_t>,...
Definition list.hpp:995
list< output_t > convert_all(converter_t converter) const
Converts the elements in the current xtd::colllections::generic::list <type_t> to another type,...
Definition list.hpp:433
pointer data() noexcept
Returns pointer to the underlying array serving as element storage.
Definition list.hpp:282
list(const base_type &list)
Copy constructor with specified base type list.
Definition list.hpp:181
bool exists(predicate_t match) const
Determines whether the xtd::collections::generic::list <type_t> contains elements that match the cond...
Definition list.hpp:525
void add_range(std::initializer_list< type_t > il)
Adds copy of elements from the specified collection to the end of the xtd::collections::generic::list...
Definition list.hpp:346
value_type * pointer
Definition list.hpp:136
size_type index_of(const type_t &value, size_type index) const
Determines the index of a specific item in the xtd::collections::generic::list <type_t>.
Definition list.hpp:704
const auto & items() const noexcept
Returns the underlying base type items.
Definition list.hpp:290
optional< type_t > find_last(predicate_t match) const
Searches for an element that matches the conditions defined by the specified predicate,...
Definition list.hpp:612
xtd::collections::object_model::read_only_collection< value_type > read_only_collection
Definition list.hpp:140
const_pointer data() const noexcept
Returns pointer to the underlying array serving as element storage.
Definition list.hpp:286
bool contains(const type_t &value) const noexcept override
Determines whether an element is in the xtd::colllections::generic::list <type_t>.
Definition list.hpp:421
size_type capacity() const noexcept
Definition list.hpp:224
optional< type_t > find(predicate_t match) const
Searches for an element that matches the conditions defined by the specified predicate,...
Definition list.hpp:541
Provides the base class for a generic read-only collection.
Definition read_only_collection.hpp:38
static void throws(xtd::helpers::exception_case exception_case, const source_location &location=source_location::current())
Throws an exption with specified exception case.
Defines a generalized method that a value type or class implements to create a type-specific method f...
Definition iequatable.hpp:22
static auto to_list(const ienumerable< source_t > &source) noexcept
Creates a xtd::collections::generic::list <type_t> from an xtd::collections::generic::ienumerable <ty...
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.hpp:44
Represents the version number of an assembly, operating system, or the xtd. This class cannot be inhe...
Definition version.hpp:114
Contains xtd::comparison delegate.
Contains xtd::converter alias.
Contains xtd::collections::generic::helpers::equator struct.
Contains xtd::collections::generic::comparer <type_t> class.
Contains xtd::collections::generic::ilist <type_t> interface.
xtd::delegate< int32(type_t x, type_t y)> comparison
Represents the method that compares two objects of the same type.
Definition comparison.hpp:33
xtd::delegate< output_t(input_t input)> converter
Represents a method that converts an object from one type to another type.
Definition converter.hpp:33
@ index_out_of_range
The index is out of range.
Definition exception_case.hpp:59
@ out_of_memory
Out of memory.
Definition exception_case.hpp:85
@ 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:63
#define self_
The self_ expression is a reference value expression whose value is the reference of the implicit obj...
Definition self.hpp:20
#define delegate_
The declaration of a delegate type is similar to a method signature. It has a return value and any nu...
Definition delegate.hpp:900
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
std::optional< type_t > optional
Represents the optional alias on std::optional.
Definition optional.hpp:25
constexpr null_opt nullopt
Represents a nullopt value. Used to indicate that an std::optional does not contain a value.
Definition nullopt.hpp:26
ptr< type_t > new_ptr(args_t &&... args)
The xtd::new_ptr operator creates a xtd::ptr object.
Definition new_ptr.hpp:24
xtd::func< bool, type_t > predicate
Represents a delegate that defines a set of criteria and determines whether the specified object meet...
Definition predicate.hpp:16
delegate< void(arguments_t...)> action
Represents a xtd::delegate that has variable parameters and does not return a value.
Definition action.hpp:20
bool is(xtd::any value)
Checks if the result of an expression is compatible with a given type.
Definition is.hpp:485
@ other
The operating system is other.
Definition platform_id.hpp:58
@ add
The Add key.
Definition console_key.hpp:170
@ c
The C key.
Definition console_key.hpp:92
@ n
The N key.
Definition console_key.hpp:114
@ i
The I key.
Definition console_key.hpp:104
@ insert
The INS (INSERT) key.
Definition console_key.hpp:62
Contains xtd::intptr type.
Contains xtd::is method.
The xtd::extensions namespace contains interface extensions.
Definition collection_common.hpp:14
The xtd::collections::generic namespace contains interfaces and classes that define generic collectio...
Definition comparer.hpp:16
The xtd::collections namespace contains interfaces and classes that define various collections of obj...
Definition any_pair.hpp:10
Provides classes and interfaces that support queries that use Language-Integrated Query (LINQ).
Definition enumerable.hpp:45
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
constexpr size_type length() const noexcept
Returns the length of the current read_only_span.
Definition read_only_span.hpp:229
Contains xtd::new_ptr method.
Contains xtd::object class.
Contains xtd::optional type.
Contains xtd::predicate delegate.
Contains xtd::collections::object_model::read_only_collection class.
Contains self_ keyword.
Contains xtd::string alias.
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:38