CodePorting.Translator Cs2Cpp
CodePorting.Translator.Cs2Cpp.Framework
list.h
1
2#pragma once
3
4#include <system/details/collections_helper.h>
5#include <system/details/comparer_type.h>
6#include <system/object.h>
7#include <system/collections/ilist.h>
8#include <system/array.h>
9#include <system/exceptions.h>
10#include <system/collections/base_enumerator.h>
11#include <system/collections/icomparer.h>
12#include <system/collections/algorithms.h>
13#include <system/collections/read_only_collection.h>
14#include <system/predicate.h>
15#include <system/comparison.h>
16#include <system/action.h>
17#include <system/converter.h>
18#include <system/cycles_detection.h>
19#include <system/multicast_delegate.h>
20
21#include <fwd.h>
22
23#include <vector>
24#include <algorithm>
25#include <utility>
26#include <cstddef>
27
28namespace System { namespace Collections { namespace Generic {
29
31template<typename T> class List;
32
36template<typename T>
37class ListPtr : public SharedPtr<List<T>>
38{
39public:
41 ListPtr(std::nullptr_t = nullptr) {}
44 ListPtr(const SharedPtr<List<T> >& obj) : SharedPtr<List<T>>(obj) { }
45
49 typename std::vector<T>::reference operator[](int idx) { return (*this)->operator[](idx); }
53 typename std::vector<T>::const_reference operator[](int idx) const { return (*this)->operator[](idx); }
54
57 bool operator == (std::nullptr_t) const
58 {
59 return SmartPtr<List<T>>::operator == (nullptr);
60 }
61};
62
123template<typename T>
124class ASPOSECPP_SHARED_CLASS List
125 : virtual public Object
127{
128 ASPOSE_COLLECTION_POINTER_MODE_CONTROL(T)
129
130public:
132 typedef T ValueType;
135
136private:
138 RTTI_INFO_TEMPLATE_CLASS(System::Collections::Generic::List<T>, System::BaseTypesInfo<BaseType>);
139
140public:
142 typedef std::vector<T, ASPOSE_COLLECTION_ALLOCATOR_TYPE> vector_t;
143
145 typedef typename vector_t::iterator iterator;
147 typedef typename vector_t::const_iterator const_iterator;
149 typedef typename vector_t::reverse_iterator reverse_iterator;
151 typedef typename vector_t::const_reverse_iterator const_reverse_iterator;
152
153protected:
158
159public:
164
166 List() : ASPOSE_COLLECTION_INIT_ALLOCATOR() {}
170 List(int capacity) : ASPOSE_COLLECTION_INIT_ALLOCATOR()
171 {
172 if (capacity < 0)
173 {
174 throw ArgumentOutOfRangeException(u"capacity");
175 }
176 m_data.reserve(capacity);
177 }
181 List(IEnumerablePtr collection) : ASPOSE_COLLECTION_INIT_ALLOCATOR()
182 {
183 AddRange(collection);
184 TrimExcess();
185 }
186
190 void AddInitializer(int size, const T inits[])
191 {
192 for (int i = 0; i < size; ++i)
193 m_data.push_back(inits[i]);
194 }
195
198 iterator begin() noexcept { return m_data.begin(); }
201 iterator end() noexcept { return m_data.end(); }
202
205 const_iterator begin() const noexcept { return m_data.begin(); }
208 const_iterator end() const noexcept { return m_data.end(); }
209
212 const_iterator cbegin() const noexcept { return m_data.cbegin(); }
215 const_iterator cend() const noexcept { return m_data.cend(); }
216
219 reverse_iterator rbegin() noexcept { return m_data.rbegin(); }
222 reverse_iterator rend() noexcept { return m_data.rend(); }
223
226 const_reverse_iterator rbegin() const noexcept { return m_data.rbegin(); }
229 const_reverse_iterator rend() const noexcept { return m_data.rend(); }
230
233 const_reverse_iterator crbegin() const noexcept { return m_data.crbegin(); }
236 const_reverse_iterator crend() const noexcept { return m_data.crend(); }
237
238 // IEnumerable<T> interface
243 class Enumerator : public SimpleEnumerator<vector_t>
244 {
245 public:
248 Enumerator(const ThisPtr& data) : SimpleEnumerator<vector_t>(data, data->m_data) { }
250 RTTI_INFO_TEMPLATE_CLASS(List<T>::Enumerator, System::BaseTypesInfo<System::Object>);
251 };
255 {
256 return MakeObject<Enumerator>(std::move(MakeSharedPtr(this)));
257 }
258
259 // end of IEnumerable<T> interface
260
261 // ICollection<T> interface
264 int get_Count() const override
265 {
266 return (int)m_data.size();
267 }
270 void Add(const T& item) override
271 {
272 m_data.push_back(item);
273 }
275 void Clear() override
276 {
277 m_data.clear();
278 }
282 bool Contains(const T& item) const override
283 {
284 return FindInData(m_data.begin(), m_data.end(), item) != m_data.end();
285 }
289 bool Remove(const T& item) override
290 {
291 iterator it = FindInData(m_data.begin(), m_data.end(), item);
292 if (it != m_data.end())
293 {
294 m_data.erase(it);
295 return true;
296 }
297 return false;
298 }
299
300 //inherits get_IsReadOnly()
304 void CopyTo(System::ArrayPtr<T> array, int arrayIndex) override
305 {
306 this->CopyTo(0, array, arrayIndex, ASPOSECPP_CHECKED_CAST(int, m_data.size()));
307 }
308
309 // end of ICollection<T> interface
310
311 // IList<T> interface
315 int IndexOf(const T& item) const override
316 {
317 const_iterator it = FindInData(m_data.begin(), m_data.end(), item);
318 if (it != m_data.end())
319 {
320 return ASPOSECPP_CHECKED_CAST(int, it - m_data.begin());
321 }
322
323 return -1;
324 }
328 void Insert(int index, const T& item) override
329 {
330 if (index < 0 || static_cast<size_t>(index) > m_data.size()) {
331 throw ArgumentOutOfRangeException(u"index");
332 }
333
334 m_data.insert(m_data.begin() + index, item);
335 }
338 void RemoveAt(int index) override
339 {
340 if (Details::IsOutOfBounds(index, m_data)) {
341 throw ArgumentOutOfRangeException(u"index");
342 }
343 m_data.erase(m_data.begin() + index);
344 }
345
349 T idx_get(int index) const override
350 {
351 return operator[](index);
352 }
356 void idx_set(int index, T value) override
357 {
358 operator[](index) = value;
359 }
360
361 // end of IList<T> interface
364 int get_Capacity() const
365 {
366 return (int)m_data.capacity();
367 }
370 void set_Capacity(int capacity)
371 {
372 if (capacity < (int)m_data.size()) {
373 throw ArgumentOutOfRangeException(u"capacity");
374 }
375 m_data.reserve(capacity);
376 }
377
381 void AddRange(IEnumerablePtr collection)
382 {
383 InsertRange(static_cast<int>(m_data.size()), collection);
384 }
385
389 {
390 return MakeObject<System::Collections::ObjectModel::ReadOnlyCollection<T>>(this);
391 }
392
396 int BinarySearch(const T &item) const
397 {
398 return _net_binnary_search(m_data, 0, ASPOSECPP_CHECKED_CAST(int, m_data.size()), item);
399 }
404 int BinarySearch(const T &item, const SharedPtr<System::Collections::Generic::IComparer<T> >& comparer) const
405 {
406 return _net_binnary_search(m_data, 0, ASPOSECPP_CHECKED_CAST(int, m_data.size()), item, comparer);
407 }
414 int BinarySearch(int index, int count, const T &item, const SharedPtr<System::Collections::Generic::IComparer<T> >& comparer) const
415 {
416 if (index < 0 || count < 0) {
417 throw ArgumentOutOfRangeException(u"index or count");
418 }
419
420 if (Details::IsOutOfSize(index + count, m_data)) {
421 throw ArgumentException(u"index or count");
422 }
423
424 return _net_binnary_search(m_data, index, count, item, comparer);
425 }
426
431 template <typename OutputType>
433 {
434 if (converter.IsNull()) {
435 throw System::ArgumentNullException(u"converter");
436 }
437 SharedPtr<List<OutputType>> res = System::MakeObject<List<OutputType>>((int)m_data.size());
438 for (size_t i = 0; i < m_data.size(); i++) {
439 res->Add(converter(m_data[i]));
440 }
441 return res;
442 }
443
446 void CopyTo(const System::ArrayPtr<T>& array)
447 {
448 this->CopyTo(0, array, 0, ASPOSECPP_CHECKED_CAST(int, m_data.size()));
449 }
456 void CopyTo(int index, const System::ArrayPtr<T>& array, int arrayIndex, int count)
457 {
458 if (!array) {
459 throw ArgumentNullException(u"array");
460 }
461
462 if (index < 0 || arrayIndex < 0 || count < 0) {
463 throw ArgumentOutOfRangeException(u"index, arrayIndex or count");
464 }
465
466 if (Details::IsOutOfSize(index + count, m_data)
467 || Details::IsOutOfSize(arrayIndex + count, array->data()) ) {
468 throw ArgumentException(u"index, arrayIndex or count");
469 }
470
471 std::copy(m_data.begin() + index, m_data.begin() + index + count, array->data().begin() + arrayIndex);
472 }
473
478 {
479 if (match.IsNull()) {
480 throw ArgumentNullException(u"match");
481 }
482 return FindIndex(match) != -1;
483 }
488 {
489 if (predicate.IsNull()) {
490 throw ArgumentNullException(u"predicate");
491 }
492 for (iterator it = m_data.begin(); it != m_data.end(); ++it)
493 {
494 if (predicate(*it))
495 return (*it);
496 }
497 return System::Default<T>();
498 }
503 {
504 if (match.IsNull()) {
505 throw ArgumentNullException(u"match");
506 }
507 ListPtr<T> list = MakeObject<List<T>>();
508 for (iterator it = m_data.begin(); it != m_data.end(); ++it)
509 {
510 if (match(*it))
511 list->Add(*it);
512 }
513 return list;
514 }
519 {
520 return FindIndex(0, ASPOSECPP_CHECKED_CAST(int, m_data.size()), match);
521 }
526 int FindIndex(int startIndex, System::Predicate<T> match)
527 {
528 return FindIndex(startIndex, ASPOSECPP_CHECKED_CAST(int, m_data.size()) - startIndex, match);
529 }
535 int FindIndex(int startIndex, int count, System::Predicate<T> match)
536 {
537 if (match.IsNull()) {
538 throw ArgumentNullException(u"match");
539 }
540
541 if (count < 0 || startIndex < 0
542 || Details::IsOutOfSize(startIndex + count, m_data))
543 {
544 throw ArgumentOutOfRangeException(u"startIndex or count");
545 }
546
547 if (m_data.empty()) {
548 return -1;
549 }
550
551 int const num = startIndex + count;
552 for (int index = startIndex; index < num; ++index)
553 {
554 auto& item = m_data[index];
555 if (match(item)) {
556 return index;
557 }
558 }
559 return -1;
560 }
565 {
566 if (match.IsNull()) {
567 throw ArgumentNullException(u"match");
568 }
569 T res = System::Default<T>();
570 for (iterator it = m_data.begin(); it != m_data.end(); ++it)
571 {
572 if (match(*it))
573 res = (*it);
574 }
575 return res;
576 }
577
581 {
582 if (action.IsNull()) {
583 throw ArgumentNullException(u"action");
584 }
585 auto data_size = m_data.size();
586 for (iterator it = m_data.begin(); it != m_data.end(); ++it)
587 {
588 action(*it);
589 if (m_data.size() != data_size)
590 {
591 throw InvalidOperationException();
592 }
593 }
594 }
595
600 ThisPtr GetRange(int index, int count)
601 {
602 if (index < 0 || count < 0) {
603 throw ArgumentOutOfRangeException(u"index or count");
604 }
605
606 if (Details::IsOutOfSize(index + count, m_data)) {
607 throw ArgumentException(u"index or count");
608 }
609
610 ThisPtr rv = MakeObject<List<T> >(count);
611 for (auto i = index; i < (index + count); ++i)
612 {
613 rv->m_data.push_back(m_data[i]);
614 }
615
616 return rv;
617 }
618
623 int IndexOf(const T& item, int index) const
624 {
625 if (Details::IsOutOfBounds(index, m_data)) {
626 throw ArgumentOutOfRangeException(u"index");
627 }
628 auto it = FindInData(m_data.begin() + index, m_data.end(), item);
629 if (it != m_data.end())
630 {
631 return ASPOSECPP_CHECKED_CAST(int, it - m_data.begin());
632 }
633
634 return -1;
635 }
636
642 void InsertRange(int index, IEnumerablePtr collection)
643 {
644 if (!collection) {
645 throw ArgumentNullException(u"collection");
646 }
647
648 if (index < 0 || static_cast<size_t>(index) > m_data.size()) {
649 throw ArgumentOutOfRangeException(u"index");
650 }
651
652 if (collection.GetObjectOrNull() == this) {
653 m_data.reserve(m_data.size() * 2);
654 m_data.insert(m_data.begin() + index, m_data.begin(), m_data.end());
655 }
656 else
657 {
658 IEnumeratorPtr it = collection->GetEnumerator();
659 while (it->MoveNext())
660 {
661 m_data.insert(m_data.begin() + index++, it->Current());
662 }
663 }
664 }
665
669 int32_t LastIndexOf(const T& item) const
670 {
671 auto rit = FindInData(m_data.rbegin(), m_data.rend(), item);
672 if (rit != m_data.rend())
673 {
674 return ASPOSECPP_CHECKED_CAST(int, rit.base() - m_data.begin() - 1);
675 }
676
677 return -1;
678 }
679
686 int32_t LastIndexOf(const T& item, int32_t index) const
687 {
688 using namespace Collections::Generic::Details;
689 if (index < 0 || IsOutOfBounds(index, m_data))
690 {
691 throw ArgumentOutOfRangeException(u"startIndex or count");
692 }
693
694 auto rbegin = m_data.rbegin() + m_data.size() - index - 1;
695 auto rend = m_data.rend();
696 auto rit = FindInData(rbegin, rend, item);
697 if (rit != rend)
698 {
699 return ASPOSECPP_CHECKED_CAST(int, rit.base() - m_data.begin()) - 1;
700 }
701 return -1;
702 }
703
711 int32_t LastIndexOf(const T& item, int32_t index, int32_t count) const
712 {
713 using namespace Collections::Generic::Details;
714 if (index < 0 || count < 0
715 || IsOutOfBounds(index, m_data) || IsOutOfSize(count, m_data)
716 || (index - count + 1) < 0)
717 {
718 throw ArgumentOutOfRangeException(u"index or count");
719 }
720
721 auto rbegin = m_data.rbegin() + m_data.size() - index - 1;
722 auto rend = rbegin + count;
723 auto rit = FindInData(rbegin, rend, item);
724
725 if (rit != rend)
726 {
727 return ASPOSECPP_CHECKED_CAST(int, rit.base() - m_data.begin()) - 1;
728 }
729 return -1;
730 }
731
736 {
737 if (match.IsNull()) {
738 throw ArgumentNullException(u"match");
739 }
740
741 typename vector_t::size_type removed = 0;
742
743 for (typename vector_t::size_type index = 0; index < m_data.size(); )
744 {
745 if (match(m_data[index]))
746 {
747 m_data.erase(m_data.begin() + index);
748 ++removed;
749 }
750 else
751 {
752 ++index;
753 }
754 }
755
756 return ASPOSECPP_CHECKED_CAST(int, removed);
757 }
761 void RemoveRange(int index, int count)
762 {
763 if (index < 0 || count < 0) {
764 throw ArgumentOutOfRangeException(u"index or count");
765 }
766
767 if (Details::IsOutOfSize(index + count, m_data)) {
768 throw ArgumentException(u"index or count");
769 }
770
771 m_data.erase(m_data.begin() + index, m_data.begin() + index + count);
772 }
774 void Reverse()
775 {
776 std::reverse(m_data.begin(), m_data.end());
777 }
781 void Reverse(int index, int count)
782 {
783 if (index < 0 || count < 0) {
784 throw ArgumentOutOfRangeException(u"index or count");
785 }
786
787 if (Details::IsOutOfSize(index + count, m_data)) {
788 throw ArgumentException(u"index or count");
789 }
790
791 std::reverse(m_data.begin() + index, m_data.begin() + index + count);
792 }
796 {
797 ComparerAdapter<T> adapter(comparator);
798 std::sort(m_data.begin(), m_data.end(), adapter);
799 }
801 void Sort()
802 {
803 std::sort(m_data.begin(), m_data.end(), Details::ComparerType<ValueType>());
804 }
809 void Sort(int index, int count, SharedPtr<System::Collections::Generic::IComparer<T> > comparator)
810 {
811 if (index < 0 || count < 0) {
812 throw ArgumentOutOfRangeException(u"index or count");
813 }
814
815 if (Details::IsOutOfSize(index + count, m_data)) {
816 throw ArgumentException(u"index or count");
817 }
818
819 ComparerAdapter<T> adapter(comparator);
820 std::sort(m_data.begin() + index, m_data.begin() + index + count, adapter);
821 }
824 void Sort(Comparison<T> comparison, bool) //second (bool) param to solve ambiguous call issue
825 {
826 if (comparison.IsNull()) {
827 throw ArgumentNullException(u"comparison");
828 }
829 std::sort(m_data.begin(), m_data.end(), comparison);
830 }
831
835 {
836 typename vector_t::size_type size = m_data.size();
837 auto result = MakeObject<Array<T> >(ASPOSECPP_CHECKED_CAST(int, size));
838 std::copy(m_data.begin(), m_data.end(), result->data().begin());
839
840 return result;
841 }
844 {
845 m_data.shrink_to_fit();
846 }
847
852 {
853 if (match.IsNull())
854 {
855 throw ArgumentNullException(u"match");
856 }
857 for (iterator it = m_data.begin(); it != m_data.end(); ++it)
858 {
859 if (!match(*it))
860 return false;
861 }
862 return true;
863 }
864
868 typename vector_t::reference operator[](int index)
869 {
870 if (Details::IsOutOfBounds(index, m_data)) {
871 throw ArgumentOutOfRangeException(u"index");
872 }
873 return m_data[static_cast<typename vector_t::size_type>(index)];
874 }
878 typename vector_t::const_reference operator[](int index) const
879 {
880 if (Details::IsOutOfBounds(index, m_data)) {
881 throw ArgumentOutOfRangeException(u"index");
882 }
883 return m_data[static_cast<typename vector_t::size_type>(index)];
884 }
885
888 vector_t& data() { return m_data; }
891 const vector_t& data() const { return m_data; }
894 void _add_range(std::initializer_list<T> list)
895 {
896 std::for_each(list.begin(), list.end(), [this](const T &v) { m_data.push_back(v); });
897 }
898
900 System::Details::VirtualizedIteratorBase<T>* virtualizeBeginIterator() override
901 {
902 return new System::Details::NativeIteratorWrapper<T, iterator>(begin(), end());
903 }
905 System::Details::VirtualizedIteratorBase<T>* virtualizeEndIterator() override
906 {
907 return new System::Details::NativeIteratorWrapper<T, iterator>(end(), end());
908 }
910 System::Details::VirtualizedIteratorBase<T>* virtualizeBeginConstIterator() const override
911 {
912 return new System::Details::NativeConstIteratorWrapper<T, const_iterator>(begin(), end());
913 }
915 System::Details::VirtualizedIteratorBase<T>* virtualizeEndConstIterator() const override
916 {
917 return new System::Details::NativeConstIteratorWrapper<T, const_iterator>(end(), end());
918 }
919
920private:
928 template <typename Q, typename I>
929 typename std::enable_if<Details::IsEqualExist<Q>::value, I>::type FindInData(I begin, I end, const Q &item) const
930 {
931 return std::find(begin, end, item);
932 }
940 template <typename Q, typename I>
941 typename std::enable_if<!Details::IsEqualExist<Q>::value, I>::type FindInData(I begin, I end, const Q &item) const
942 {
943 throw System::NotImplementedException(ASPOSE_CURRENT_FUNCTION);
944 }
952 template <typename Q, typename I>
953 I FindInData(I begin, I end, const System::SharedPtr<Q> &item) const
954 {
955 return std::find_if(begin, end, [&item](const System::SharedPtr<Q> &element)
956 {
957 return element == nullptr ? item == nullptr : element.ToObjectPtr()->Equals(item.ToObjectPtr());
958 });
959 }
960
961protected:
963 ~List() override {}
964
965#ifdef __DBG_FOR_EACH_MEMBER
966 public:
969 void DBG_for_each_member(DBG::for_each_member_visitor &visitor) const override
970 {
971 visitor.add_self(this);
972 DBG::for_each_of_Object(this, m_data, visitor);
973 }
974
977 const char* DBG_class_name() const override { return "List<T>"; }
978#endif
979
980#ifdef ASPOSE_GET_SHARED_MEMBERS
981 DEFINE_GET_SHARED_MEMBERS(m_data)
982#endif
983};
984
985}}} // namespace System::Collections::Generic
Interface that compares two objects in greater-equal-less sense. Objects of this class should only be...
Definition: icomparer.h:20
System::Details::VirtualizedConstIterator< T > const_iterator
Const iterator type.
Definition: ienumerable.h:216
System::Details::VirtualizedIterator< T > iterator
Iterator type.
Definition: ienumerable.h:214
Interface of indexed container of elements. Objects of this class should only be allocated using Syst...
Definition: ilist.h:19
Enumerator to iterate through list elements. Objects of this class should only be allocated using Sys...
Definition: list.h:244
RTTI_INFO_TEMPLATE_CLASS(List< T >::Enumerator, System::BaseTypesInfo< System::Object >)
RTTI information.
Enumerator(const ThisPtr &data)
Creates enumerator iterating through specific list.
Definition: list.h:248
List forward declaration.
Definition: list.h:127
List()
Creates empty list.
Definition: list.h:166
vector_t::const_reference operator[](int index) const
Accessor function.
Definition: list.h:878
vector_t::reference operator[](int index)
Accessor function.
Definition: list.h:868
int32_t LastIndexOf(const T &item, int32_t index) const
Searches for the specified object and returns the zero-based index of the last occurrence within the ...
Definition: list.h:686
void Sort(const SharedPtr< System::Collections::Generic::IComparer< T > > &comparator)
Sorts elements in the list.
Definition: list.h:795
vector_t::const_iterator const_iterator
Const iterator type.
Definition: list.h:147
vector_t::const_reverse_iterator const_reverse_iterator
Const reverse iterator type.
Definition: list.h:151
bool Exists(System::Predicate< T > match)
Checks if element adhering to specific predicate exists in list.
Definition: list.h:477
const_reverse_iterator rend() const noexcept
Gets a reverse iterator for a non-existent element before the start of the const-qualified collection...
Definition: list.h:229
void CopyTo(System::ArrayPtr< T > array, int arrayIndex) override
Copies list elements into existing array elements.
Definition: list.h:304
System::Details::VirtualizedIteratorBase< T > * virtualizeEndConstIterator() const override
Gets the implementation of end const iterator for the current container.
Definition: list.h:915
void Sort(int index, int count, SharedPtr< System::Collections::Generic::IComparer< T > > comparator)
Sorts elements in the list slice.
Definition: list.h:809
System::Details::VirtualizedIteratorBase< T > * virtualizeBeginConstIterator() const override
Gets the implementation of begin const iterator for the current container.
Definition: list.h:910
int32_t LastIndexOf(const T &item, int32_t index, int32_t count) const
Searches for the specified object and returns the zero-based index of the last occurrence within the ...
Definition: list.h:711
SharedPtr< IEnumerable< T > > IEnumerablePtr
Container holding elements of same type we hold.
Definition: list.h:161
std::vector< T, ASPOSE_COLLECTION_ALLOCATOR_TYPE > vector_t
Underlying data type.
Definition: list.h:142
iterator begin() noexcept
Gets iterator to the first element of collection.
Definition: list.h:198
void Reverse()
Reverses elements order of the whole list.
Definition: list.h:774
void InsertRange(int index, IEnumerablePtr collection)
Inserts data range at specific position.
Definition: list.h:642
SharedPtr< List< T > > ThisPtr
Pointer type.
Definition: list.h:155
int IndexOf(const T &item) const override
Gets first index of specific item.
Definition: list.h:315
const_reverse_iterator crend() const noexcept
Gets a reverse iterator for a non-existent const-qualified element before the start of the collection...
Definition: list.h:236
SharedPtr< System::Collections::ObjectModel::ReadOnlyCollection< T > > AsReadOnly()
Gets read-only reference to this collection.
Definition: list.h:388
int get_Capacity() const
Gets current list capacity.
Definition: list.h:364
void set_Capacity(int capacity)
Sets list capacity.
Definition: list.h:370
int32_t LastIndexOf(const T &item) const
Searches for the specified object and returns the zero-based index of the last occurrence within the ...
Definition: list.h:669
vector_t::reverse_iterator reverse_iterator
Reverse iterator type.
Definition: list.h:149
void _add_range(std::initializer_list< T > list)
C++ specific.
Definition: list.h:894
System::Details::VirtualizedIteratorBase< T > * virtualizeBeginIterator() override
Gets the implementation of begin iterator for the current container.
Definition: list.h:900
void Add(const T &item) override
Adds element to the end of list.
Definition: list.h:270
bool TrueForAll(System::Predicate< T > match)
Determines whether every element in the collection matches the conditions defined by the specified pr...
Definition: list.h:851
const_iterator cend() const noexcept
Gets iterator for a non-existent const-qualified element behind the end of the collection.
Definition: list.h:215
int RemoveAll(Predicate< T > match)
Removes all elements matching specific predicate.
Definition: list.h:735
void ForEach(System::Action< T > action)
Applies action to all elements in list.
Definition: list.h:580
iterator end() noexcept
Gets iterator for a non-existent element behind the end of the collection.
Definition: list.h:201
IEnumeratorPtr GetEnumerator() override
Gets enumerator to iterate through list elements.
Definition: list.h:254
void Sort(Comparison< T > comparison, bool)
Sorts elements in the list.
Definition: list.h:824
void Reverse(int index, int count)
Reverses elements order of the list slice.
Definition: list.h:781
int FindIndex(int startIndex, int count, System::Predicate< T > match)
Looks for element adhering to specific predicate.
Definition: list.h:535
vector_t & data()
Underlying data structure access function.
Definition: list.h:888
List(int capacity)
Creates list with pre-defined capacity.
Definition: list.h:170
const_reverse_iterator crbegin() const noexcept
Gets a reverse iterator to the last const-qualified element of collection (first in reverse).
Definition: list.h:233
void idx_set(int index, T value) override
Sets element at specific position.
Definition: list.h:356
System::Details::VirtualizedIteratorBase< T > * virtualizeEndIterator() override
Gets the implementation of end iterator for the current container.
Definition: list.h:905
T Find(System::Predicate< T > predicate)
Looks for element adhering to specific predicate.
Definition: list.h:487
int BinarySearch(int index, int count, const T &item, const SharedPtr< System::Collections::Generic::IComparer< T > > &comparer) const
Looks for item in a sorted list.
Definition: list.h:414
int IndexOf(const T &item, int index) const
Looks for specific item in list.
Definition: list.h:623
T FindLast(System::Predicate< T > match)
Looks for last element adhering to specific predicate.
Definition: list.h:564
ThisPtr GetRange(int index, int count)
Creates slice of list.
Definition: list.h:600
void CopyTo(int index, const System::ArrayPtr< T > &array, int arrayIndex, int count)
Copies elements starting from the specified index into existing array elements.
Definition: list.h:456
int BinarySearch(const T &item) const
Looks for item in a sorted list.
Definition: list.h:396
vector_t::iterator iterator
Iterator type.
Definition: list.h:145
void Sort()
Sorts elements in the list using default comparator.
Definition: list.h:801
void Insert(int index, const T &item) override
Inserts item at specified position.
Definition: list.h:328
const_iterator cbegin() const noexcept
Gets iterator to the first const-qualified element of collection.
Definition: list.h:212
int FindIndex(System::Predicate< T > match)
Looks for element adhering to specific predicate.
Definition: list.h:518
T idx_get(int index) const override
Gets element at specific position.
Definition: list.h:349
ArrayPtr< T > ToArray() const
Converst list to array.
Definition: list.h:834
void CopyTo(const System::ArrayPtr< T > &array)
Copies all elements into existing array elements.
Definition: list.h:446
const_iterator begin() const noexcept
Gets iterator to the first element of the const-qualified collection.
Definition: list.h:205
void RemoveAt(int index) override
Removes item at specified position.
Definition: list.h:338
ListPtr< T > FindAll(System::Predicate< T > match)
Looks for elements adhering to specific predicate.
Definition: list.h:502
int get_Count() const override
Gets number of elements in current list.
Definition: list.h:264
bool Remove(const T &item) override
Removes first instance of specific item from list.
Definition: list.h:289
int BinarySearch(const T &item, const SharedPtr< System::Collections::Generic::IComparer< T > > &comparer) const
Looks for item in a sorted list.
Definition: list.h:404
vector_t m_data
Underlting data structure.
Definition: list.h:157
void Clear() override
Deletes all elements.
Definition: list.h:275
void AddRange(IEnumerablePtr collection)
Adds all elements from collection (or itself) to the end of current list.
Definition: list.h:381
IList< T > BaseType
Interface type.
Definition: list.h:134
void TrimExcess()
Makes list capacity to fit its size.
Definition: list.h:843
const_iterator end() const noexcept
Gets iterator for a non-existent element behind the end of the const-qualified collection.
Definition: list.h:208
List(IEnumerablePtr collection)
Copy constructor.
Definition: list.h:181
SharedPtr< List< OutputType > > ConvertAll(Converter< T, OutputType > converter)
Creates a list of elements converted to different type.
Definition: list.h:432
~List() override
Destructor.
Definition: list.h:963
int FindIndex(int startIndex, System::Predicate< T > match)
Looks for element adhering to specific predicate.
Definition: list.h:526
const vector_t & data() const
Underlying data structure access function.
Definition: list.h:891
void RemoveRange(int index, int count)
Removes slice of list.
Definition: list.h:761
bool Contains(const T &item) const override
Checks if item is present in list.
Definition: list.h:282
reverse_iterator rbegin() noexcept
Gets a reverse iterator to the last element of collection (first in reverse).
Definition: list.h:219
void AddInitializer(int size, const T inits[])
Adds elements to list; used when translating initializers.
Definition: list.h:190
reverse_iterator rend() noexcept
Gets a reverse iterator for a non-existent element before the start of the collection.
Definition: list.h:222
const_reverse_iterator rbegin() const noexcept
Gets a reverse iterator to the last element of the const-qualified collection (first in reverse).
Definition: list.h:226
T ValueType
This type.
Definition: list.h:132
SharedPtr< IEnumerator< T > > IEnumeratorPtr
Enumerator type.
Definition: list.h:163
List pointer with access operators. This type is a pointer to manage other object's deletion....
Definition: list.h:38
std::vector< T >::const_reference operator[](int idx) const
Accessor.
Definition: list.h:53
std::vector< T >::reference operator[](int idx)
Accessor.
Definition: list.h:49
bool operator==(std::nullptr_t) const
Checks if List pointer is null.
Definition: list.h:57
ListPtr(std::nullptr_t=nullptr)
Initializes null-pointer.
Definition: list.h:41
ListPtr(const SharedPtr< List< T > > &obj)
Initializes pointer to specified list.
Definition: list.h:44
Iterator class for simple containers holding elements directly using rbegin() and rend() functions....
Definition: base_enumerator.h:81
Represents a pointer to the method that compares two objects of the same type. This type should be al...
Definition: comparison.h:93
Base class that enables using methods available for System.Object class in C#. All non-trivial classe...
Definition: object.h:62
Pointer class to wrap types being allocated on heap. Use it to manage memory for classes inheriting O...
Definition: smart_ptr.h:180
SmartPtr< Object > ToObjectPtr() const
Converts any pointer type to pointer to Object. Doesn't require Pointee_ type to be complete.
Definition: object.h:832
auto begin() -> decltype(std::declval< Q >().begin())
Accessor for begin() method of an underling collection. Only compiles if SmartPtr_ is specialization ...
Definition: smart_ptr.h:830
Object * GetObjectOrNull() const
Gets pointed object (if any) or nullptr. Same as get().
Definition: smart_ptr.h:783
class System::SmartPtr::Data m_data
An instance of Data class.
class ASPOSECPP_SHARED_CLASS List
Definition: ienumerable.h:18
int _net_binnary_search(const containterT< T, Allocator > &container, int index, int count, T value, const SharedPtr< System::Collections::Generic::IComparer< T > > &comparer)
Implements binary search in random access container.
Definition: algorithms.h:23
Definition: db_command.h:9
bool Equals(const TA &a, const TB &b)
Determines the equality of two values applying operator==() to them.
Definition: primitive_types.h:77
MulticastDelegate< void(Args...)> Action
Delegate type that references methods that have no return value.
Definition: action.h:40
SmartPtr< X > MakeSharedPtr(X *p)
Converts raw pointer to smart pointer.
Definition: smart_ptr.h:1650
MulticastDelegate< TOutput(TInput)> Converter
Represents a pointer to the invokable entity that accepts a single argument of the TInput type and re...
Definition: converter.h:14
MulticastDelegate< bool(T)> Predicate
Represents a pointer to a predicate - an invokable entity that accepts a single argument and returns ...
Definition: predicate.h:41
Adapter to use IComparer within STL environment. Uses IComparer if set; otherwise,...
Definition: icomparer.h:44