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 m_data.reserve(m_data.size() + size);
193 for (int i = 0; i < size; ++i)
194 m_data.push_back(inits[i]);
195 }
196
199 iterator begin() noexcept { return m_data.begin(); }
202 iterator end() noexcept { return m_data.end(); }
203
206 const_iterator begin() const noexcept { return m_data.begin(); }
209 const_iterator end() const noexcept { return m_data.end(); }
210
213 const_iterator cbegin() const noexcept { return m_data.cbegin(); }
216 const_iterator cend() const noexcept { return m_data.cend(); }
217
220 reverse_iterator rbegin() noexcept { return m_data.rbegin(); }
223 reverse_iterator rend() noexcept { return m_data.rend(); }
224
227 const_reverse_iterator rbegin() const noexcept { return m_data.rbegin(); }
230 const_reverse_iterator rend() const noexcept { return m_data.rend(); }
231
234 const_reverse_iterator crbegin() const noexcept { return m_data.crbegin(); }
237 const_reverse_iterator crend() const noexcept { return m_data.crend(); }
238
239 // IEnumerable<T> interface
244 class Enumerator : public SimpleEnumerator<vector_t>
245 {
246 public:
249 Enumerator(const ThisPtr& data) : SimpleEnumerator<vector_t>(data, data->m_data) { }
251 RTTI_INFO_TEMPLATE_CLASS(List<T>::Enumerator, System::BaseTypesInfo<System::Object>);
252 };
256 {
257 return MakeObject<Enumerator>(std::move(MakeSharedPtr(this)));
258 }
259
260 // end of IEnumerable<T> interface
261
262 // ICollection<T> interface
265 int get_Count() const override
266 {
267 return (int)m_data.size();
268 }
271 void Add(const T& item) override
272 {
273 m_data.push_back(item);
274 }
276 void Clear() override
277 {
278 m_data.clear();
279 }
283 bool Contains(const T& item) const override
284 {
285 return FindInData(m_data.begin(), m_data.end(), item) != m_data.end();
286 }
290 bool Remove(const T& item) override
291 {
292 iterator it = FindInData(m_data.begin(), m_data.end(), item);
293 if (it != m_data.end())
294 {
295 m_data.erase(it);
296 return true;
297 }
298 return false;
299 }
300
301 //inherits get_IsReadOnly()
305 void CopyTo(System::ArrayPtr<T> array, int arrayIndex) override
306 {
307 this->CopyTo(0, array, arrayIndex, ASPOSECPP_CHECKED_CAST(int, m_data.size()));
308 }
309
310 // end of ICollection<T> interface
311
312 // IList<T> interface
316 int IndexOf(const T& item) const override
317 {
318 const_iterator it = FindInData(m_data.begin(), m_data.end(), item);
319 if (it != m_data.end())
320 {
321 return ASPOSECPP_CHECKED_CAST(int, it - m_data.begin());
322 }
323
324 return -1;
325 }
329 void Insert(int index, const T& item) override
330 {
331 if (index < 0 || static_cast<size_t>(index) > m_data.size()) {
332 throw ArgumentOutOfRangeException(u"index");
333 }
334
335 m_data.insert(m_data.begin() + index, item);
336 }
339 void RemoveAt(int index) override
340 {
341 if (Details::IsOutOfBounds(index, m_data)) {
342 throw ArgumentOutOfRangeException(u"index");
343 }
344 m_data.erase(m_data.begin() + index);
345 }
346
350 T idx_get(int index) const override
351 {
352 return operator[](index);
353 }
357 void idx_set(int index, T value) override
358 {
359 operator[](index) = value;
360 }
361
362 // end of IList<T> interface
365 int get_Capacity() const
366 {
367 return (int)m_data.capacity();
368 }
371 void set_Capacity(int capacity)
372 {
373 if (capacity < (int)m_data.size()) {
374 throw ArgumentOutOfRangeException(u"capacity");
375 }
376 m_data.reserve(capacity);
377 }
378
382 void AddRange(IEnumerablePtr collection)
383 {
384 InsertRange(static_cast<int>(m_data.size()), collection);
385 }
386
390 {
391 return MakeObject<System::Collections::ObjectModel::ReadOnlyCollection<T>>(this);
392 }
393
397 int BinarySearch(const T &item) const
398 {
399 return _net_binnary_search(m_data, 0, ASPOSECPP_CHECKED_CAST(int, m_data.size()), item);
400 }
405 int BinarySearch(const T &item, const SharedPtr<System::Collections::Generic::IComparer<T> >& comparer) const
406 {
407 return _net_binnary_search(m_data, 0, ASPOSECPP_CHECKED_CAST(int, m_data.size()), item, comparer);
408 }
415 int BinarySearch(int index, int count, const T &item, const SharedPtr<System::Collections::Generic::IComparer<T> >& comparer) const
416 {
417 if (index < 0 || count < 0) {
418 throw ArgumentOutOfRangeException(u"index or count");
419 }
420
421 if (Details::IsOutOfSize(index + count, m_data)) {
422 throw ArgumentException(u"index or count");
423 }
424
425 return _net_binnary_search(m_data, index, count, item, comparer);
426 }
427
432 template <typename OutputType>
434 {
435 if (converter.IsNull()) {
436 throw System::ArgumentNullException(u"converter");
437 }
438 SharedPtr<List<OutputType>> res = System::MakeObject<List<OutputType>>((int)m_data.size());
439 for (size_t i = 0; i < m_data.size(); i++) {
440 res->Add(converter(m_data[i]));
441 }
442 return res;
443 }
444
447 void CopyTo(const System::ArrayPtr<T>& array)
448 {
449 this->CopyTo(0, array, 0, ASPOSECPP_CHECKED_CAST(int, m_data.size()));
450 }
457 void CopyTo(int index, const System::ArrayPtr<T>& array, int arrayIndex, int count)
458 {
459 if (!array) {
460 throw ArgumentNullException(u"array");
461 }
462
463 if (index < 0 || arrayIndex < 0 || count < 0) {
464 throw ArgumentOutOfRangeException(u"index, arrayIndex or count");
465 }
466
467 if (Details::IsOutOfSize(index + count, m_data)
468 || Details::IsOutOfSize(arrayIndex + count, array->data()) ) {
469 throw ArgumentException(u"index, arrayIndex or count");
470 }
471
472 std::copy(m_data.begin() + index, m_data.begin() + index + count, array->data().begin() + arrayIndex);
473 }
474
479 {
480 if (match.IsNull()) {
481 throw ArgumentNullException(u"match");
482 }
483 return FindIndex(match) != -1;
484 }
489 {
490 if (predicate.IsNull()) {
491 throw ArgumentNullException(u"predicate");
492 }
493 for (iterator it = m_data.begin(); it != m_data.end(); ++it)
494 {
495 if (predicate(*it))
496 return (*it);
497 }
498 return System::Default<T>();
499 }
504 {
505 if (match.IsNull()) {
506 throw ArgumentNullException(u"match");
507 }
508 ListPtr<T> list = MakeObject<List<T>>();
509 for (iterator it = m_data.begin(); it != m_data.end(); ++it)
510 {
511 if (match(*it))
512 list->Add(*it);
513 }
514 return list;
515 }
520 {
521 return FindIndex(0, ASPOSECPP_CHECKED_CAST(int, m_data.size()), match);
522 }
527 int FindIndex(int startIndex, System::Predicate<T> match)
528 {
529 return FindIndex(startIndex, ASPOSECPP_CHECKED_CAST(int, m_data.size()) - startIndex, match);
530 }
536 int FindIndex(int startIndex, int count, System::Predicate<T> match)
537 {
538 if (match.IsNull()) {
539 throw ArgumentNullException(u"match");
540 }
541
542 if (count < 0 || startIndex < 0
543 || Details::IsOutOfSize(startIndex + count, m_data))
544 {
545 throw ArgumentOutOfRangeException(u"startIndex or count");
546 }
547
548 if (m_data.empty()) {
549 return -1;
550 }
551
552 int const num = startIndex + count;
553 for (int index = startIndex; index < num; ++index)
554 {
555 auto& item = m_data[index];
556 if (match(item)) {
557 return index;
558 }
559 }
560 return -1;
561 }
566 {
567 if (match.IsNull()) {
568 throw ArgumentNullException(u"match");
569 }
570 T res = System::Default<T>();
571 for (iterator it = m_data.begin(); it != m_data.end(); ++it)
572 {
573 if (match(*it))
574 res = (*it);
575 }
576 return res;
577 }
578
582 {
583 if (action.IsNull()) {
584 throw ArgumentNullException(u"action");
585 }
586 auto data_size = m_data.size();
587 for (iterator it = m_data.begin(); it != m_data.end(); ++it)
588 {
589 action(*it);
590 if (m_data.size() != data_size)
591 {
592 throw InvalidOperationException();
593 }
594 }
595 }
596
601 ThisPtr GetRange(int index, int count)
602 {
603 if (index < 0 || count < 0) {
604 throw ArgumentOutOfRangeException(u"index or count");
605 }
606
607 if (Details::IsOutOfSize(index + count, m_data)) {
608 throw ArgumentException(u"index or count");
609 }
610
611 ThisPtr rv = MakeObject<List<T> >(count);
612 for (auto i = index; i < (index + count); ++i)
613 {
614 rv->m_data.push_back(m_data[i]);
615 }
616
617 return rv;
618 }
619
624 int IndexOf(const T& item, int index) const
625 {
626 if (Details::IsOutOfBounds(index, m_data)) {
627 throw ArgumentOutOfRangeException(u"index");
628 }
629 auto it = FindInData(m_data.begin() + index, m_data.end(), item);
630 if (it != m_data.end())
631 {
632 return ASPOSECPP_CHECKED_CAST(int, it - m_data.begin());
633 }
634
635 return -1;
636 }
637
643 void InsertRange(int index, IEnumerablePtr collection)
644 {
645 if (!collection) {
646 throw ArgumentNullException(u"collection");
647 }
648
649 if (index < 0 || static_cast<size_t>(index) > m_data.size()) {
650 throw ArgumentOutOfRangeException(u"index");
651 }
652
653 if (collection.GetObjectOrNull() == this) {
654 m_data.reserve(m_data.size() * 2);
655 m_data.insert(m_data.begin() + index, m_data.begin(), m_data.end());
656 }
657 else
658 {
659 IEnumeratorPtr it = collection->GetEnumerator();
660 while (it->MoveNext())
661 {
662 m_data.insert(m_data.begin() + index++, it->Current());
663 }
664 }
665 }
666
670 int32_t LastIndexOf(const T& item) const
671 {
672 auto rit = FindInData(m_data.rbegin(), m_data.rend(), item);
673 if (rit != m_data.rend())
674 {
675 return ASPOSECPP_CHECKED_CAST(int, rit.base() - m_data.begin() - 1);
676 }
677
678 return -1;
679 }
680
687 int32_t LastIndexOf(const T& item, int32_t index) const
688 {
689 using namespace Collections::Generic::Details;
690 if (index < 0 || IsOutOfBounds(index, m_data))
691 {
692 throw ArgumentOutOfRangeException(u"startIndex or count");
693 }
694
695 auto rbegin = m_data.rbegin() + m_data.size() - index - 1;
696 auto rend = m_data.rend();
697 auto rit = FindInData(rbegin, rend, item);
698 if (rit != rend)
699 {
700 return ASPOSECPP_CHECKED_CAST(int, rit.base() - m_data.begin()) - 1;
701 }
702 return -1;
703 }
704
712 int32_t LastIndexOf(const T& item, int32_t index, int32_t count) const
713 {
714 using namespace Collections::Generic::Details;
715 if (index < 0 || count < 0
716 || IsOutOfBounds(index, m_data) || IsOutOfSize(count, m_data)
717 || (index - count + 1) < 0)
718 {
719 throw ArgumentOutOfRangeException(u"index or count");
720 }
721
722 auto rbegin = m_data.rbegin() + m_data.size() - index - 1;
723 auto rend = rbegin + count;
724 auto rit = FindInData(rbegin, rend, item);
725
726 if (rit != rend)
727 {
728 return ASPOSECPP_CHECKED_CAST(int, rit.base() - m_data.begin()) - 1;
729 }
730 return -1;
731 }
732
737 {
738 if (match.IsNull()) {
739 throw ArgumentNullException(u"match");
740 }
741
742 typename vector_t::size_type removed = 0;
743
744 for (typename vector_t::size_type index = 0; index < m_data.size(); )
745 {
746 if (match(m_data[index]))
747 {
748 m_data.erase(m_data.begin() + index);
749 ++removed;
750 }
751 else
752 {
753 ++index;
754 }
755 }
756
757 return ASPOSECPP_CHECKED_CAST(int, removed);
758 }
762 void RemoveRange(int index, int count)
763 {
764 if (index < 0 || count < 0) {
765 throw ArgumentOutOfRangeException(u"index or count");
766 }
767
768 if (Details::IsOutOfSize(index + count, m_data)) {
769 throw ArgumentException(u"index or count");
770 }
771
772 m_data.erase(m_data.begin() + index, m_data.begin() + index + count);
773 }
775 void Reverse()
776 {
777 std::reverse(m_data.begin(), m_data.end());
778 }
782 void Reverse(int index, int count)
783 {
784 if (index < 0 || count < 0) {
785 throw ArgumentOutOfRangeException(u"index or count");
786 }
787
788 if (Details::IsOutOfSize(index + count, m_data)) {
789 throw ArgumentException(u"index or count");
790 }
791
792 std::reverse(m_data.begin() + index, m_data.begin() + index + count);
793 }
797 {
798 ComparerAdapter<T> adapter(comparator);
799 std::sort(m_data.begin(), m_data.end(), adapter);
800 }
802 void Sort()
803 {
804 std::sort(m_data.begin(), m_data.end(), Details::ComparerType<ValueType>());
805 }
810 void Sort(int index, int count, SharedPtr<System::Collections::Generic::IComparer<T> > comparator)
811 {
812 if (index < 0 || count < 0) {
813 throw ArgumentOutOfRangeException(u"index or count");
814 }
815
816 if (Details::IsOutOfSize(index + count, m_data)) {
817 throw ArgumentException(u"index or count");
818 }
819
820 ComparerAdapter<T> adapter(comparator);
821 std::sort(m_data.begin() + index, m_data.begin() + index + count, adapter);
822 }
825 void Sort(Comparison<T> comparison, bool) //second (bool) param to solve ambiguous call issue
826 {
827 if (comparison.IsNull()) {
828 throw ArgumentNullException(u"comparison");
829 }
830 std::sort(m_data.begin(), m_data.end(), comparison);
831 }
832
836 {
837 typename vector_t::size_type size = m_data.size();
838 auto result = MakeObject<Array<T> >(ASPOSECPP_CHECKED_CAST(int, size));
839 std::copy(m_data.begin(), m_data.end(), result->data().begin());
840
841 return result;
842 }
845 {
846 m_data.shrink_to_fit();
847 }
848
853 {
854 if (match.IsNull())
855 {
856 throw ArgumentNullException(u"match");
857 }
858 for (iterator it = m_data.begin(); it != m_data.end(); ++it)
859 {
860 if (!match(*it))
861 return false;
862 }
863 return true;
864 }
865
869 typename vector_t::reference operator[](int index)
870 {
871 if (Details::IsOutOfBounds(index, m_data)) {
872 throw ArgumentOutOfRangeException(u"index");
873 }
874 return m_data[static_cast<typename vector_t::size_type>(index)];
875 }
879 typename vector_t::const_reference operator[](int index) const
880 {
881 if (Details::IsOutOfBounds(index, m_data)) {
882 throw ArgumentOutOfRangeException(u"index");
883 }
884 return m_data[static_cast<typename vector_t::size_type>(index)];
885 }
886
889 vector_t& data() { return m_data; }
892 const vector_t& data() const { return m_data; }
895 void _add_range(std::initializer_list<T> list)
896 {
897 std::for_each(list.begin(), list.end(), [this](const T &v) { m_data.push_back(v); });
898 }
899
901 System::Details::VirtualizedIteratorBase<T>* virtualizeBeginIterator() override
902 {
903 return new System::Details::NativeIteratorWrapper<T, iterator>(begin(), end());
904 }
906 System::Details::VirtualizedIteratorBase<T>* virtualizeEndIterator() override
907 {
908 return new System::Details::NativeIteratorWrapper<T, iterator>(end(), end());
909 }
911 System::Details::VirtualizedIteratorBase<T>* virtualizeBeginConstIterator() const override
912 {
913 return new System::Details::NativeConstIteratorWrapper<T, const_iterator>(begin(), end());
914 }
916 System::Details::VirtualizedIteratorBase<T>* virtualizeEndConstIterator() const override
917 {
918 return new System::Details::NativeConstIteratorWrapper<T, const_iterator>(end(), end());
919 }
920
921private:
929 template <typename Q, typename I>
930 typename std::enable_if<Details::IsEqualExist<Q>::value, I>::type FindInData(I begin, I end, const Q &item) const
931 {
932 return std::find(begin, end, item);
933 }
941 template <typename Q, typename I>
942 typename std::enable_if<!Details::IsEqualExist<Q>::value, I>::type FindInData(I begin, I end, const Q &item) const
943 {
944 throw System::NotImplementedException(ASPOSE_CURRENT_FUNCTION);
945 }
953 template <typename Q, typename I>
954 I FindInData(I begin, I end, const System::SharedPtr<Q> &item) const
955 {
956 return std::find_if(begin, end, [&item](const System::SharedPtr<Q> &element)
957 {
958 return element == nullptr ? item == nullptr : element.ToObjectPtr()->Equals(item.ToObjectPtr());
959 });
960 }
961
962protected:
964 ~List() override {}
965
966#ifdef __DBG_FOR_EACH_MEMBER
967 public:
970 void DBG_for_each_member(DBG::for_each_member_visitor &visitor) const override
971 {
972 visitor.add_self(this);
973 DBG::for_each_of_Object(this, m_data, visitor);
974 }
975
978 const char* DBG_class_name() const override { return "List<T>"; }
979#endif
980
981#ifdef ASPOSE_GET_SHARED_MEMBERS
982 DEFINE_GET_SHARED_MEMBERS(m_data)
983#endif
984};
985
986}}} // 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:245
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:249
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:879
vector_t::reference operator[](int index)
Accessor function.
Definition: list.h:869
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:687
void Sort(const SharedPtr< System::Collections::Generic::IComparer< T > > &comparator)
Sorts elements in the list.
Definition: list.h:796
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:478
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:230
void CopyTo(System::ArrayPtr< T > array, int arrayIndex) override
Copies list elements into existing array elements.
Definition: list.h:305
System::Details::VirtualizedIteratorBase< T > * virtualizeEndConstIterator() const override
Gets the implementation of end const iterator for the current container.
Definition: list.h:916
void Sort(int index, int count, SharedPtr< System::Collections::Generic::IComparer< T > > comparator)
Sorts elements in the list slice.
Definition: list.h:810
System::Details::VirtualizedIteratorBase< T > * virtualizeBeginConstIterator() const override
Gets the implementation of begin const iterator for the current container.
Definition: list.h:911
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:712
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:199
void Reverse()
Reverses elements order of the whole list.
Definition: list.h:775
void InsertRange(int index, IEnumerablePtr collection)
Inserts data range at specific position.
Definition: list.h:643
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:316
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:237
SharedPtr< System::Collections::ObjectModel::ReadOnlyCollection< T > > AsReadOnly()
Gets read-only reference to this collection.
Definition: list.h:389
int get_Capacity() const
Gets current list capacity.
Definition: list.h:365
void set_Capacity(int capacity)
Sets list capacity.
Definition: list.h:371
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:670
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:895
System::Details::VirtualizedIteratorBase< T > * virtualizeBeginIterator() override
Gets the implementation of begin iterator for the current container.
Definition: list.h:901
void Add(const T &item) override
Adds element to the end of list.
Definition: list.h:271
bool TrueForAll(System::Predicate< T > match)
Determines whether every element in the collection matches the conditions defined by the specified pr...
Definition: list.h:852
void AddInitializer(int size, const T *inits)
Adds elements to list; used when translating initializers.
Definition: list.h:190
const_iterator cend() const noexcept
Gets iterator for a non-existent const-qualified element behind the end of the collection.
Definition: list.h:216
int RemoveAll(Predicate< T > match)
Removes all elements matching specific predicate.
Definition: list.h:736
void ForEach(System::Action< T > action)
Applies action to all elements in list.
Definition: list.h:581
iterator end() noexcept
Gets iterator for a non-existent element behind the end of the collection.
Definition: list.h:202
IEnumeratorPtr GetEnumerator() override
Gets enumerator to iterate through list elements.
Definition: list.h:255
void Sort(Comparison< T > comparison, bool)
Sorts elements in the list.
Definition: list.h:825
void Reverse(int index, int count)
Reverses elements order of the list slice.
Definition: list.h:782
int FindIndex(int startIndex, int count, System::Predicate< T > match)
Looks for element adhering to specific predicate.
Definition: list.h:536
vector_t & data()
Underlying data structure access function.
Definition: list.h:889
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:234
void idx_set(int index, T value) override
Sets element at specific position.
Definition: list.h:357
System::Details::VirtualizedIteratorBase< T > * virtualizeEndIterator() override
Gets the implementation of end iterator for the current container.
Definition: list.h:906
T Find(System::Predicate< T > predicate)
Looks for element adhering to specific predicate.
Definition: list.h:488
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:415
int IndexOf(const T &item, int index) const
Looks for specific item in list.
Definition: list.h:624
T FindLast(System::Predicate< T > match)
Looks for last element adhering to specific predicate.
Definition: list.h:565
ThisPtr GetRange(int index, int count)
Creates slice of list.
Definition: list.h:601
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:457
int BinarySearch(const T &item) const
Looks for item in a sorted list.
Definition: list.h:397
vector_t::iterator iterator
Iterator type.
Definition: list.h:145
void Sort()
Sorts elements in the list using default comparator.
Definition: list.h:802
void Insert(int index, const T &item) override
Inserts item at specified position.
Definition: list.h:329
const_iterator cbegin() const noexcept
Gets iterator to the first const-qualified element of collection.
Definition: list.h:213
int FindIndex(System::Predicate< T > match)
Looks for element adhering to specific predicate.
Definition: list.h:519
T idx_get(int index) const override
Gets element at specific position.
Definition: list.h:350
ArrayPtr< T > ToArray() const
Converst list to array.
Definition: list.h:835
void CopyTo(const System::ArrayPtr< T > &array)
Copies all elements into existing array elements.
Definition: list.h:447
const_iterator begin() const noexcept
Gets iterator to the first element of the const-qualified collection.
Definition: list.h:206
void RemoveAt(int index) override
Removes item at specified position.
Definition: list.h:339
ListPtr< T > FindAll(System::Predicate< T > match)
Looks for elements adhering to specific predicate.
Definition: list.h:503
int get_Count() const override
Gets number of elements in current list.
Definition: list.h:265
bool Remove(const T &item) override
Removes first instance of specific item from list.
Definition: list.h:290
int BinarySearch(const T &item, const SharedPtr< System::Collections::Generic::IComparer< T > > &comparer) const
Looks for item in a sorted list.
Definition: list.h:405
vector_t m_data
Underlting data structure.
Definition: list.h:157
void Clear() override
Deletes all elements.
Definition: list.h:276
void AddRange(IEnumerablePtr collection)
Adds all elements from collection (or itself) to the end of current list.
Definition: list.h:382
IList< T > BaseType
Interface type.
Definition: list.h:134
void TrimExcess()
Makes list capacity to fit its size.
Definition: list.h:844
const_iterator end() const noexcept
Gets iterator for a non-existent element behind the end of the const-qualified collection.
Definition: list.h:209
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:433
~List() override
Destructor.
Definition: list.h:964
int FindIndex(int startIndex, System::Predicate< T > match)
Looks for element adhering to specific predicate.
Definition: list.h:527
const vector_t & data() const
Underlying data structure access function.
Definition: list.h:892
void RemoveRange(int index, int count)
Removes slice of list.
Definition: list.h:762
bool Contains(const T &item) const override
Checks if item is present in list.
Definition: list.h:283
reverse_iterator rbegin() noexcept
Gets a reverse iterator to the last element of collection (first in reverse).
Definition: list.h:220
reverse_iterator rend() noexcept
Gets a reverse iterator for a non-existent element before the start of the collection.
Definition: list.h:223
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:227
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:98
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