CodePorting.Translator Cs2Cpp
CodePorting.Translator.Cs2Cpp.Framework
array.h
1
3#ifndef _aspose_system_array_h_
4#define _aspose_system_array_h_
5
6#include <system/details/collections_helper.h>
7#include <system/details/comparer_type.h>
8#include <system/details/equality_helper.h>
9#include <system/details/array_view.h>
10#include <system/details/stack_array.h>
11#include <system/object.h>
12#include <system/collections/icomparer.h>
13#include <system/collections/ienumerable.h>
14#include <system/collections/ilist.h>
15#include <system/exceptions.h>
16#include <system/collections/algorithms.h>
17#include <system/converter.h>
18#include <system/predicate.h>
19#include <system/action.h>
20#include <system/select_type.h>
21#include <system/cycles_detection.h>
22
23#include <fwd.h>
24
25#include <map>
26#include <vector>
27#include <functional>
28#include <initializer_list>
29#include <utility>
30#include <limits>
31#include <type_traits>
32
33#undef min
34#undef max
35
36namespace System
37{
38
39 namespace Details {
40 template <typename X, typename IdxType>
41 inline typename Array<X>::UnderlyingType& GetByIndex(const SmartPtr<Array<X>> *ptr, IdxType idx)
42 {
43 return (**ptr).operator[](static_cast<int>(idx));
44 }
45
48 template <typename Integral, bool = std::numeric_limits<Integral>::is_signed>
49 struct NegativeValueChecker
50 {
54 static void Check(const Integral &value)
55 {
56 if (value < 0)
57 throw System::OverflowException(u"Negative array size");
58 }
59 };
62 template <typename Integral>
63 struct NegativeValueChecker<Integral, false>
64 {
66 static void Check(const Integral&) {}
67 };
68
71 template <typename Integral, bool = (sizeof(Integral) > sizeof(int)) || (!std::numeric_limits<Integral>::is_signed && (sizeof(Integral) == sizeof(int)))>
72 struct IntPositiveOverflowChecker
73 {
77 static void Check(const Integral& value)
78 {
79 if (value >= static_cast<Integral>((std::numeric_limits<int>::max)()))
80 throw System::OverflowException(u"Array size too big for signed integer");
81 }
82 };
85 template <typename Integral>
86 struct IntPositiveOverflowChecker<Integral, false>
87 {
89 static void Check(const Integral &value) { ASPOSE_UNUSED(value); }
90 };
91
97 template <typename Integral>
98 int FixArraySize(const Integral &value)
99 {
100 NegativeValueChecker<Integral>::Check(value);
101 IntPositiveOverflowChecker<Integral>::Check(value);
102 return static_cast<int>(value);
103 }
104 }
105
108
137 template<typename T>
138 ArrayPtr<T> MakeArray(std::initializer_list<T> init)
139 {
140 System::Details::MakeObjectLeakageDetector::SignatureBacktraceSentry signature_sentry;
141 System::Details::MakeObjectLeakageDetector::SetSignature<Array<T>>(init);
142
143 Detail::OwnNextObject ownershipSentry;
144
145 Array<T> *const arr = new Array<T>(init);
146
147 ownershipSentry.CreatedSuccessfully(arr);
148 signature_sentry.CreatedSuccessfully(arr);
149
150 return ArrayPtr<T>(arr);
151 }
152
157 template <class T, class... Args> ArrayPtr<T> MakeArray(Args&&... args)
158 {
159 System::Details::MakeObjectLeakageDetector::SignatureBacktraceSentry signature_sentry;
160 System::Details::MakeObjectLeakageDetector::SetSignature<Array<T>>(std::forward<Args>(args)...);
161
162 Detail::OwnNextObject ownershipSentry;
163
164 Array<T>* const arr = new Array<T>(std::forward<Args>(args)...);
165
166 ownershipSentry.CreatedSuccessfully(arr);
167 signature_sentry.CreatedSuccessfully(arr);
168
169 return ArrayPtr<T>(arr);
170 }
171
178 template <class T, class Integral, class... Args>
179 typename std::enable_if<std::is_integral<Integral>::value, ArrayPtr<T>>::type MakeArray(Integral size, Args&&... args)
180 {
181 System::Details::MakeObjectLeakageDetector::SignatureBacktraceSentry signature_sentry;
182 System::Details::MakeObjectLeakageDetector::SetSignature<Array<T>>(Details::FixArraySize(size), std::forward<Args>(args)...);
183
184 Detail::OwnNextObject ownershipSentry;
185
186 Array<T>* const arr = new Array<T>(Details::FixArraySize(size), std::forward<Args>(args)...);
187
188 ownershipSentry.CreatedSuccessfully(arr);
189 signature_sentry.CreatedSuccessfully(arr);
190
191 return ArrayPtr<T>(arr);
192 }
193
255 template<typename T>
256 class ASPOSECPP_SHARED_CLASS Array
257 : virtual public Object
259 {
260 typedef Array<T> ThisType;
262
263 typedef ::System::BaseTypesInfo<BaseType> ThisTypeBaseTypesInfo;
264 RTTI_INFO_TEMPLATE_CLASS(ThisType, ThisTypeBaseTypesInfo);
265
266 public:
268 using ValueType = T;
270 using UnderlyingType = typename System::Details::SelectType<T>::type;
271
272 protected:
274 typedef System::Details::CollectionHelpers::ContainerPointerMode<UnderlyingType> pointer_mode_t;
276 typedef std::vector<UnderlyingType, typename pointer_mode_t::allocator_type> vector_t;
281#ifdef ASPOSE_GET_SHARED_MEMBERS
282 DEFINE_GET_SHARED_MEMBERS(m_data)
283#endif
284 public:
289
294 class Enumerator : virtual public Object, public Collections::Generic::IEnumerator<T>
295 {
296 RTTI_INFO_TEMPLATE_CLASS(Array<T>::Enumerator, System::BaseTypesInfo<System::Object>);
297
298 private:
300 SharedPtr<Array<T>> m_array;
302 int64_t m_idx;
303
304 public:
307 Enumerator(const SharedPtr<Array<T>>& arr) : m_array(arr), m_idx(-1) { }
308
310 virtual ~Enumerator() {}
311
313 virtual MakeConstRef_t<T> get_Current() const override
314 {
315 return (m_idx < 0 || m_idx >= (int64_t)m_array->m_data.size())
316 ? System::Default<T>()
317 : m_array->m_data[(size_t)m_idx];
318 }
319
323 virtual bool MoveNext() override
324 {
325 if (m_idx < (int64_t)m_array->m_data.size())
326 m_idx++;
327
328 return m_idx < (int64_t)m_array->m_data.size();
329 }
330
332 virtual void Reset() override
333 {
334 m_idx = -1;
335 }
336
337#ifdef __DBG_FOR_EACH_MEMBER
338 public:
341 void DBG_for_each_member(DBG::for_each_member_visitor &visitor) const override
342 {
343 visitor.add_self(this);
344 visitor.add_member(this, m_array.get_shared(), "m_array");
345 }
346
348 const char* DBG_class_name() const override { return "Array<T>::Enumerator"; }
349#endif
350
351 protected:
352#ifdef ASPOSE_GET_SHARED_MEMBERS
354 virtual void GetSharedMembers(System::Object::shared_members_type& result) const override
355 {
356 Object::GetSharedMembers(result);
357 result.Add("System::Array<T>::Enumerator::m_array", m_array);
358 }
359#endif
360 };
361
363 Array() : m_data(m_pointer_mode.GetAllocator()) {}
364
368 Array(int count, const T& init = T()) : m_data(count, static_cast<UnderlyingType>(init), m_pointer_mode.GetAllocator()) { }
369
374 template <typename ValueType>
375 Array(typename std::enable_if<std::is_arithmetic<T>::value && std::is_arithmetic<ValueType>::value && std::is_convertible<ValueType, T>::value, int>::type count, ValueType init)
376 : Array(count, ASPOSECPP_CHECKED_CAST(T, init)) {}
377
381 Array(int count, const T inits[]) : m_data(count, static_cast<UnderlyingType>(T()), m_pointer_mode.GetAllocator())
382 {
383 for (int i = 0; i < count; ++i)
384 m_data[i] = inits[i];
385 }
386
389 Array(vector_t&& value) : m_data(std::move(value), m_pointer_mode.GetAllocator()) {}
390
393 Array(const vector_t &assgn) : m_data(assgn, m_pointer_mode.GetAllocator()) {}
394
399 template <typename Q, typename = typename std::enable_if<std::is_same<Q, T>::value && !std::is_same<std::vector<Q>, vector_t>::value, std::vector<Q>>::type>
400 Array(const std::vector<Q> &value)
401 : m_data(value.begin(), value.end(), m_pointer_mode.GetAllocator())
402 {}
403
408 template <typename Q, typename = typename std::enable_if<std::is_same<Q, T>::value && !std::is_same<std::vector<Q>, vector_t>::value, std::vector<Q>>::type>
409 Array(std::vector<Q> &&value)
410 : m_data(m_pointer_mode.GetAllocator())
411 {
412 m_data.swap(value);
413 }
414
417 Array(std::initializer_list<UnderlyingType> init) : m_data(init, m_pointer_mode.GetAllocator()) {}
418
422 template <std::size_t InitArraySize>
423 Array(const std::array<UnderlyingType, InitArraySize> &init) :
424 Array(init, static_cast<std::make_index_sequence<InitArraySize>*>(nullptr))
425 {}
426
429 Array(std::initializer_list<bool> init, int = 0) : m_data(m_pointer_mode.GetAllocator())
430 {
431 for (auto it = init.begin(); it != init.end(); ++it)
432 m_data.push_back(UnderlyingType(*it));
433 }
434
435 // IEnumerable<T> interface
436
439 virtual EnumeratorPtr GetEnumerator() override
440 {
441 return MakeObject<Enumerator>(std::move(MakeSharedPtr(this)));
442 }
443
444 // end of IEnumerable<T> interface
445
446 // ICollection<T> interface
447 // Note: members which add, insert, or remove elements throw NotSupportedException.
448
450 virtual int get_Count() const override
451 {
452 return get_Length();
453 }
454
457 virtual void Add(const T&) override
458 {
459 throw NotSupportedException(u"Array as ICollection<T>::Add");
460 }
461
464 virtual void Clear() override
465 {
466 throw NotSupportedException(u"Array as ICollection<T>::Clear");
467 }
468
471 void SetTemplateWeakPtr(uint32_t argument) override
472 {
473 m_pointer_mode.SetWeak(argument, m_data);
474 }
475
476private:
481 template <typename Q = T>
482 auto ContainsImpl(const Q* item) const -> decltype(std::declval<UnderlyingType>() == *item, void(0), bool())
483 {
484 return std::find_if(m_data.begin(), m_data.end(),
485 [&item](const T& value) { return Details::AreEqual(value, *item); }) != m_data.end();
486 }
487
490 bool ContainsImpl(...) const
491 {
492 throw NotImplementedException(ASPOSE_CURRENT_FUNCTION);
493 }
494public:
498 virtual bool Contains(const T& item) const override
499 {
500 return ContainsImpl(&item);
501 }
502
505 virtual bool Remove(const T&) override
506 {
507 throw NotSupportedException(u"Array as ICollection<T>::Remove");
508 }
509
510 // Returns True when you cast or converted to an ICollection<T> object,
511 // even though individual array elements can be modified.
512
515 virtual bool get_IsReadOnly() const override
516 {
517 return true;
518 }
519
524 virtual void CopyTo(ArrayPtr<T> arr, int arrayIndex) override
525 {
526 this->CopyTo<T>(arr, static_cast<int64_t>(arrayIndex));
527 }
528
529 // end of ICollection<T> interface
530
531 // IList<T> interface
532private:
533 template <std::size_t ...InitArrayIndexes>
534 Array(const std::array<UnderlyingType, sizeof...(InitArrayIndexes)> &init, std::index_sequence<InitArrayIndexes...>*) :
535 m_data({ init[InitArrayIndexes]... }, m_pointer_mode.GetAllocator()) {}
536
537
542 template <typename Q = T>
543 auto IndexOfImpl(const Q* item) const -> decltype(std::declval<UnderlyingType>() == *item, void(0), int())
544 {
545 auto it = std::find_if(m_data.begin(), m_data.end(), [&item](const T& value) { return Details::AreEqual(value, *item); });
546
547 return (it != m_data.end()) ? static_cast<int>(it - m_data.begin()) : -1;
548 }
549
552 int IndexOfImpl(...) const
553 {
554 throw NotImplementedException(ASPOSE_CURRENT_FUNCTION);
555 }
556
557public:
561 virtual int IndexOf(const T& item) const override
562 {
563 return IndexOfImpl(&item);
564 }
565
568 virtual void Insert(int, const T&) override
569 {
570 throw NotSupportedException(u"Array as IList<T>::Insert");
571 }
572
575 virtual void RemoveAt(int) override
576 {
577 throw NotSupportedException(u"Array as IList<T>::RemoveAt");
578 }
579
583 virtual T idx_get(int index) const override
584 {
585 return operator[](index);
586 }
587
591 virtual void idx_set(int index, T value) override
592 {
593 operator[](index) = value;
594 }
595
596 // end of IList<T> interface
597
601 ArrayPtr<T> Init(const T inits[])
602 {
603 for (size_t i = 0; i < m_data.size(); ++i)
604 m_data[i] = inits[i];
605
606 return MakeSharedPtr(this);
607 }
608
611 {
612 for (size_t i = 0; i < m_data.size(); ++i)
613 m_data[i] = T();
614 }
615
620 {
621 using namespace Collections::Generic::Details;
622 if (IsOutOfBounds(index, m_data)) {
623 throw ArgumentOutOfRangeException(u"index");
624 }
625 return m_data[static_cast<typename vector_t::size_type>(index)];
626 }
627
631 UnderlyingType const& operator[](int index) const
632 {
633 using namespace Collections::Generic::Details;
634 if (IsOutOfBounds(index, m_data)) {
635 throw ArgumentOutOfRangeException(u"index");
636 }
637 return m_data[static_cast<typename vector_t::size_type>(index)];
638 }
639
644 {
645 System::ArrayPtr<T> clone = System::MakeObject< System::Array<T> >(static_cast<int>(m_data.size()));
646 std::copy(m_data.begin(), m_data.end(), clone->data().begin());
647 return clone;
648 }
649
654 static int BinarySearch(System::ArrayPtr<T> arr, const T &item)
655 {
656 return Collections::Generic::_net_binnary_search(arr->m_data, 0, static_cast<int32_t>(arr->m_data.size()), item);
657 }
658
661 template<typename Y, typename Z>
662 static int BinarySearch(System::ArrayPtr<T> arr, const Y& item, const SharedPtr<Collections::Generic::IComparer<Z>>& comparer)
663 {
664 throw NotImplementedException();
665 }
666
670 int GetLength(int dimension)
671 {
672 return static_cast<int>(GetLongLength(dimension));
673 }
674
678 int64_t GetLongLength(int dimension)
679 {
680 return upper_bound(m_data, dimension) + 1;
681 }
682
686 int GetLowerBound(int dimension) const
687 {
688 ASPOSE_UNUSED(dimension);
689 return 0;
690 }
691
695 int GetUpperBound(int dimension)
696 {
697 return upper_bound(m_data, dimension);
698 }
699
706 template <typename InputType, typename OutputType>
708 {
709 if (!input_array)
710 {
711 throw System::ArgumentNullException(u"arr");
712 }
713
714 if (converter.IsNull())
715 {
716 throw System::ArgumentNullException(u"converter");
717 }
718
719 System::ArrayPtr<OutputType> newArray = System::MakeObject< System::Array<OutputType> >(input_array->get_Length());
720 for (int i = 0; i < input_array->get_Length(); i++)
721 {
722 newArray[i] = converter(input_array[i]);
723 }
724 return newArray;
725 }
726
733 template <typename InputType, typename OutputType>
734 static ArrayPtr<OutputType> ConvertAll(ArrayPtr<InputType> input_array, std::function<OutputType(InputType)> converter)
735 {
736 return ConvertAll(input_array, Converter<InputType, OutputType>(converter));
737 }
738
744 {
745 if (!arr || match.IsNull())
746 {
747 throw System::ArgumentNullException(u"arr or match");
748 }
749
750 for (int i = 0; i < arr->get_Length(); i++)
751 {
752 if (match(arr[i]))
753 return i;
754 }
755 return -1;
756 }
757
763 {
764 if (!arr || match.IsNull())
765 {
766 throw System::ArgumentNullException(u"arr or match");
767 }
768
769 for (auto val: arr->m_data)
770 if (match(val))
771 return val;
772 return T();
773 }
774
780 {
781 if (!arr || match.IsNull())
782 {
783 throw System::ArgumentNullException(u"arr or match");
784 }
785
786 System::ArrayPtr<T> result = System::MakeObject<System::Array<T>>();
787
788 for (auto val : arr->m_data)
789 if (match(val))
790 result->data().push_back(val);
791
792 return result;
793 }
794
800 {
801 if (!arr || match.IsNull())
802 {
803 throw System::ArgumentNullException(u"arr or match");
804 }
805 for (auto val : arr->m_data)
806 if (!match(val))
807 return false;
808 return true;
809 }
810
812 int32_t get_Rank() const { throw System::NotImplementedException(ASPOSE_CURRENT_FUNCTION); };
813
816 int32_t get_Length() const
817 {
818 //TODO IF the array is multidimensional THEN OverflowException
819 const int64_t len64 = get_LongLength();
820
821 if (len64 > (std::numeric_limits<int32_t>::max)()) {
822 throw OverflowException();
823 }
824 return static_cast<int32_t>(len64);
825 }
826
829 int64_t get_LongLength() const
830 {
831 return GetSizeTLength();
832 }
833
836 size_t GetSizeTLength() const
837 {
838 return recursive_size(m_data);
839 }
840
843 int Count() const { return get_Length(); }
844
850 template<typename DstType>
851 void CopyTo(const ArrayPtr<DstType> &dstArray, int64_t dstIndex) const
852 {
853 this->CopyTo(dstArray, 0, dstIndex, GetSizeTLength());
854 }
855
861 template<typename DstType>
862 void CopyTo(const System::Details::ArrayView<DstType> &dstArray, int64_t dstIndex) const
863 {
864 this->CopyTo(dstArray, 0, dstIndex, GetSizeTLength());
865 }
866
875 template<typename DstType>
876 void CopyTo(const ArrayPtr<DstType> &dstArray, int64_t srcIndex, int64_t dstIndex, int64_t count) const
877 {
878 using namespace Collections::Generic::Details;
879
880 if (!dstArray) {
881 throw ArgumentNullException(u"dstArray");
882 }
883 if (srcIndex < 0 || dstIndex < 0 || count < 0) {
884 throw ArgumentOutOfRangeException(u"srcIndex, dstIndex or count");
885 }
886 if (IsOutOfSize(srcIndex + count, m_data)
887 || IsOutOfSize(dstIndex + count, dstArray->data())) {
888 throw ArgumentException(u"srcIndex, dstIndex or count");
889 }
890
891 // casts are safe because bounds have already checked.
892
893 if (dstArray.GetObjectOrNull() == (Object*)(this) && dstIndex > srcIndex && dstIndex < srcIndex + count)
894 {
895 std::copy_backward(
896 m_data.begin() + ASPOSECPP_CHECKED_CAST(std::ptrdiff_t, srcIndex)
897 , m_data.begin() + ASPOSECPP_CHECKED_CAST(std::ptrdiff_t, srcIndex) + ASPOSECPP_CHECKED_CAST(std::ptrdiff_t, count)
898 , dstArray->data().begin() + ASPOSECPP_CHECKED_CAST(std::ptrdiff_t, dstIndex) + ASPOSECPP_CHECKED_CAST(std::ptrdiff_t, count)
899 );
900 }
901 else
902 {
903 std::copy(
904 m_data.begin() + ASPOSECPP_CHECKED_CAST(std::ptrdiff_t, srcIndex)
905 , m_data.begin() + ASPOSECPP_CHECKED_CAST(std::ptrdiff_t, srcIndex) + ASPOSECPP_CHECKED_CAST(std::ptrdiff_t, count)
906 , dstArray->data().begin() + ASPOSECPP_CHECKED_CAST(std::ptrdiff_t, dstIndex)
907 );
908 }
909 }
910
919 template<typename DstType>
920 void CopyTo(const System::Details::ArrayView<DstType> &dstArray, int64_t srcIndex, int64_t dstIndex, int64_t count) const
921 {
922 using namespace Collections::Generic::Details;
923
924 if (!dstArray) {
925 throw ArgumentNullException(u"dstArray");
926 }
927 if (srcIndex < 0 || dstIndex < 0 || count < 0) {
928 throw ArgumentOutOfRangeException(u"srcIndex, dstIndex or count");
929 }
930 if (IsOutOfSize(srcIndex + count, m_data)
931 || dstIndex + count > dstArray.get_Length()) {
932 throw ArgumentException(u"srcIndex, dstIndex or count");
933 }
934
935 if (dstArray.data() == this->data().data()
936 && dstIndex > srcIndex && dstIndex < srcIndex + count)
937 {
938 std::copy_backward(
939 m_data.begin() + ASPOSECPP_CHECKED_CAST(std::ptrdiff_t, srcIndex)
940 , m_data.begin() + ASPOSECPP_CHECKED_CAST(std::ptrdiff_t, srcIndex) + ASPOSECPP_CHECKED_CAST(std::ptrdiff_t, count)
941 , dstArray.begin() + ASPOSECPP_CHECKED_CAST(std::ptrdiff_t, dstIndex) + ASPOSECPP_CHECKED_CAST(std::ptrdiff_t, count)
942 );
943 }
944 else
945 {
946 std::copy(
947 m_data.begin() + ASPOSECPP_CHECKED_CAST(std::ptrdiff_t, srcIndex)
948 , m_data.begin() + ASPOSECPP_CHECKED_CAST(std::ptrdiff_t, srcIndex) + ASPOSECPP_CHECKED_CAST(std::ptrdiff_t, count)
949 , dstArray.begin() + ASPOSECPP_CHECKED_CAST(std::ptrdiff_t, dstIndex)
950 );
951 }
952 }
953
957 static void ForEach(const ArrayPtr<T>& arr, System::Action<T> action)
958 {
959 if (action.IsNull())
960 throw ArgumentNullException(u"action");
961
962 for (auto val : arr->m_data)
963 action(val);
964 }
965
972 template<typename ArrayType, typename ValueType>
973 static int IndexOf(const ArrayPtr<ArrayType> &arr, const ValueType& value)
974 {
975 return IndexOf(arr, value, 0);
976 }
977
985 template<typename ArrayType, typename ValueType>
986 static int IndexOf(const ArrayPtr<ArrayType> &arr, const ValueType& value, int startIndex)
987 {
988 return IndexOf(arr, value, startIndex, arr->get_Length() - startIndex);
989 }
990
999 template<typename ArrayType, typename ValueType>
1000 static int IndexOf(const ArrayPtr<ArrayType> &arr, const ValueType& value, int startIndex, int count)
1001 {
1002 using namespace Collections::Generic::Details;
1003 if (!arr) {
1004 throw ArgumentNullException(u"arr");
1005 }
1006 if (startIndex < 0 || count < 0 || IsOutOfSize(startIndex + count, arr->data())) {
1007 throw ArgumentOutOfRangeException(u"startIndex or count");
1008 }
1009
1010 auto begin = arr->data().begin() + startIndex;
1011 auto end = begin + count;
1012 auto it =
1013 std::find_if(begin, end, [&value](const ArrayType& item) { return Details::AreEqual(item, value); });
1014
1015 return (it != end) ? static_cast<int>(it - arr->data().begin()) : -1;
1016 }
1017
1026 template<typename ArrayType, typename ValueType>
1027 static int LastIndexOf(const ArrayPtr<ArrayType>& arr, const ValueType& value, int startIndex, int count)
1028 {
1029 using namespace Collections::Generic::Details;
1030 if (!arr) {
1031 throw ArgumentNullException(u"arr");
1032 }
1033 if (startIndex < 0 || count < 0
1034 || IsOutOfSize(startIndex, arr->data()) || IsOutOfSize(count, arr->data())
1035 || (startIndex - count + 1) < 0) {
1036 throw ArgumentOutOfRangeException(u"startIndex or count");
1037 }
1038 auto rbegin = arr->data().rbegin() + arr->data().size() - startIndex - 1;
1039 auto rend = rbegin + count;
1040 auto rit = std::find_if(rbegin, rend, [&value](const ArrayType& item) { return Details::AreEqual(item, value); });
1041
1042 return (rit != rend) ? ASPOSECPP_CHECKED_CAST(int, rit.base() - arr->data().begin() - 1) : -1;
1043 }
1044
1052 template<typename ArrayType, typename ValueType>
1053 static int LastIndexOf(const ArrayPtr<ArrayType>& items, const ValueType& value, int startIndex)
1054 {
1055 return LastIndexOf(items, value, startIndex, (items->get_Length() == 0) ? 0 : startIndex + 1);
1056 }
1057
1064 template<typename ArrayType, typename ValueType>
1065 static int LastIndexOf(const ArrayPtr<ArrayType>& items, const ValueType& value)
1066 {
1067 return LastIndexOf(items, value, items->get_Length() - 1, items->get_Length());
1068 }
1069
1075 template<typename Type>
1076 static void Clear(const ArrayPtr<Type> &arr, int startIndex, int count)
1077 {
1078 using namespace Collections::Generic::Details;
1079 if (!arr) {
1080 throw ArgumentNullException(u"arr");
1081 }
1082 if (startIndex < 0 || count < 0 || IsOutOfSize(startIndex + count, arr->data())) {
1083 throw ArgumentOutOfRangeException(u"startIndex or count");
1084 }
1085
1086 for (auto i = 0; i < count; ++i)
1087 arr->data().at(startIndex + i) = Type();
1088 }
1089
1091 // index and pastes them to another System.Array starting at the specified destination
1092 // index. Guarantees that all changes are undone if the copy does not succeed completely.
1101 template <typename SrcType, typename DstType>
1102 static void ConstrainedCopy(const ArrayPtr<SrcType> &srcArray, int64_t srcIndex,
1103 const ArrayPtr<DstType> &dstArray, int64_t dstIndex, int64_t count)
1104 {
1105 if (!srcArray) {
1106 throw ArgumentNullException(u"srcArray");
1107 }
1108 srcArray->CopyTo(dstArray, srcIndex, dstIndex, count);
1109 }
1110
1115 template<typename SrcType, typename DstType>
1116 static void Copy(const ArrayPtr<SrcType> &srcArray,
1117 const ArrayPtr<DstType> &dstArray, int64_t count)
1118 {
1119 if (!srcArray) {
1120 throw ArgumentNullException(u"srcArray");
1121 }
1122 srcArray->CopyTo(dstArray, 0, 0, count);
1123 }
1124
1129 template<typename SrcType, typename DstType>
1130 static void Copy(System::Details::ArrayView<SrcType> srcArray,
1131 const ArrayPtr<DstType> &dstArray, int64_t count)
1132 {
1133 if (!srcArray) {
1134 throw ArgumentNullException(u"srcArray");
1135 }
1136 srcArray.CopyTo(dstArray, 0, 0, count);
1137 }
1138
1143 template<typename SrcType, typename DstType>
1144 static void Copy(const ArrayPtr<SrcType> &srcArray,
1145 System::Details::ArrayView<DstType> dstArray, int64_t count)
1146 {
1147 if (!srcArray) {
1148 throw ArgumentNullException(u"srcArray");
1149 }
1150 srcArray->CopyTo(dstArray, 0, 0, count);
1151 }
1152
1157 template<typename SrcType, typename DstType>
1158 static void Copy(System::Details::ArrayView<SrcType> srcArray,
1159 System::Details::ArrayView<DstType> dstArray, int64_t count)
1160 {
1161 if (!srcArray) {
1162 throw ArgumentNullException(u"srcArray");
1163 }
1164 srcArray.CopyTo(dstArray, 0, 0, count);
1165 }
1166
1171 template<typename SrcType, std::size_t N, typename DstType>
1172 static void Copy(System::Details::StackArray<SrcType, N> &srcArray,
1173 const ArrayPtr<DstType> &dstArray, int64_t count)
1174 {
1175 Copy(static_cast<System::Details::ArrayView<SrcType> >(srcArray), dstArray, count);
1176 }
1177
1182 template<typename SrcType, typename DstType, std::size_t N>
1183 static void Copy(const ArrayPtr<SrcType> &srcArray,
1184 System::Details::StackArray<DstType, N> &dstArray, int64_t count)
1185 {
1186 Copy(srcArray, static_cast<System::Details::ArrayView<DstType> >(dstArray), count);
1187 }
1188
1193 template<typename SrcType, std::size_t NS, typename DstType, std::size_t ND>
1194 static void Copy(System::Details::StackArray<SrcType, NS> &srcArray,
1195 System::Details::StackArray<DstType, ND> &dstArray, int64_t count)
1196 {
1197 Copy(static_cast<System::Details::ArrayView<SrcType> >(srcArray),
1198 static_cast<System::Details::ArrayView<DstType> >(dstArray), count);
1199 }
1200
1209 template<typename SrcType, typename DstType>
1210 static void Copy(const ArrayPtr<SrcType> &srcArray, int64_t srcIndex,
1211 const ArrayPtr<DstType> &dstArray, int64_t dstIndex, int64_t count)
1212 {
1213 if (!srcArray) {
1214 throw ArgumentNullException(u"srcArray");
1215 }
1216 srcArray->CopyTo(dstArray, srcIndex, dstIndex, count);
1217 }
1218
1227 template<typename SrcType, typename DstType>
1228 static void Copy(System::Details::ArrayView<SrcType> srcArray, int64_t srcIndex,
1229 const ArrayPtr<DstType> &dstArray, int64_t dstIndex, int64_t count)
1230 {
1231 if (!srcArray) {
1232 throw ArgumentNullException(u"srcArray");
1233 }
1234 srcArray.CopyTo(dstArray, srcIndex, dstIndex, count);
1235 }
1236
1245 template<typename SrcType, typename DstType>
1246 static void Copy(const ArrayPtr<SrcType> &srcArray, int64_t srcIndex,
1247 System::Details::ArrayView<DstType> dstArray, int64_t dstIndex, int64_t count)
1248 {
1249 if (!srcArray) {
1250 throw ArgumentNullException(u"srcArray");
1251 }
1252 srcArray->CopyTo(dstArray, srcIndex, dstIndex, count);
1253 }
1254
1263 template<typename SrcType, typename DstType>
1264 static void Copy(System::Details::ArrayView<SrcType> srcArray, int64_t srcIndex,
1265 System::Details::ArrayView<DstType> dstArray, int64_t dstIndex, int64_t count)
1266 {
1267 if (!srcArray) {
1268 throw ArgumentNullException(u"srcArray");
1269 }
1270 srcArray.CopyTo(dstArray, srcIndex, dstIndex, count);
1271 }
1272
1281 template<typename SrcType, std::size_t N, typename DstType>
1282 static void Copy(System::Details::StackArray<SrcType, N> &srcArray, int64_t srcIndex,
1283 const ArrayPtr<DstType> &dstArray, int64_t dstIndex, int64_t count)
1284 {
1285 Copy(static_cast<System::Details::ArrayView<SrcType> >(srcArray), srcIndex, dstArray, dstIndex, count);
1286 }
1287
1296 template<typename SrcType, typename DstType, std::size_t N>
1297 static void Copy(const ArrayPtr<SrcType> &srcArray, int64_t srcIndex,
1298 System::Details::StackArray<DstType, N> &dstArray, int64_t dstIndex, int64_t count)
1299 {
1300 Copy(srcArray, srcIndex, static_cast<System::Details::ArrayView<DstType> >(dstArray), dstIndex, count);
1301 }
1302
1311 template<typename SrcType, std::size_t NS, typename DstType, std::size_t ND>
1312 static void Copy(System::Details::StackArray<SrcType, NS> &srcArray, int64_t srcIndex,
1313 System::Details::StackArray<DstType, ND> &dstArray, int64_t dstIndex, int64_t count)
1314 {
1315 Copy(static_cast<System::Details::ArrayView<SrcType>>(srcArray), srcIndex,
1316 static_cast<System::Details::ArrayView<DstType>>(dstArray), dstIndex, count);
1317 }
1318
1327 template<typename SrcType, typename DstType, std::size_t ND>
1328 static void Copy(System::Details::ArrayView<SrcType> &srcArray, int64_t srcIndex,
1329 System::Details::StackArray<DstType, ND> &dstArray, int64_t dstIndex, int64_t count)
1330 {
1331 Copy(srcArray, srcIndex,
1332 static_cast<System::Details::ArrayView<DstType>>(dstArray), dstIndex, count);
1333 }
1334
1337 template<typename Type>
1338 static void Sort(const ArrayPtr<Type> &arr)
1339 {
1340 Sort(arr, 0, arr->get_Length());
1341 }
1342
1347 template<typename Type>
1348 static void Sort(const ArrayPtr<Type> &arr, int startIndex, int count)
1349 {
1350 using namespace Collections::Generic::Details;
1351 if (!arr) {
1352 throw ArgumentNullException(u"arr");
1353 }
1354 if (startIndex < 0 || count < 0 || IsOutOfSize(startIndex + count, arr->data())) {
1355 throw ArgumentOutOfRangeException(u"startIndex or count");
1356 }
1357
1358 auto begin = arr->data().begin() + startIndex;
1359 auto end = begin + count;
1360
1361 std::sort(begin, end, Collections::Generic::Details::ComparerType<Type>());
1362 }
1363
1367 template<typename Type>
1369 {
1370 Collections::Generic::ComparerAdapter<T> adapter(comparator);
1371 std::sort(arr->data().begin(), arr->data().end(), adapter);
1372 }
1373
1376 template<typename Type, typename Y>
1378 {
1379 throw NotImplementedException();
1380 }
1381
1388 template<typename TKey, typename TValue>
1389 static void Sort(const ArrayPtr<TKey>& keys, const ArrayPtr<TValue>& items)
1390 {
1391 if (keys == nullptr)
1392 throw ArgumentNullException(u"keys");
1393
1394 Sort(keys, items, 0, keys->get_Length());
1395 }
1396
1405 template<typename TKey, typename TValue>
1406 static void Sort(const ArrayPtr<TKey>& keys, const ArrayPtr<TValue>& items, int index, int length)
1407 {
1408 if (keys == nullptr)
1409 throw ArgumentNullException(u"keys");
1410 if (index < 0 || length < 0)
1411 throw ArgumentOutOfRangeException(length < 0 ? u"length" : u"index");
1412 if (index + length > keys->Count() || (items != nullptr && index + length > items->Count()))
1413 throw ArgumentException();
1414
1415 if (items == nullptr)
1416 {
1417 typename std::vector<TKey>::iterator keys_begin = keys->data().begin() + index;
1418 typename std::vector<TKey>::iterator keys_end = keys_begin + length;
1419
1420 std::sort(keys_begin, keys_end, Collections::Generic::Details::ComparerType<TKey>());
1421 }
1422 else
1423 {
1424 // Sorting keys and items via multimap
1425 std::multimap<TKey, TValue, Collections::Generic::Details::ComparerType<TKey>> map;
1426 for (int i = index; i < index + length; ++i)
1427 map.insert(std::make_pair(keys[i], items[i]));
1428
1429 auto map_iter = map.begin();
1430 for (int i = index; (i < index + length) && (map_iter != map.end()); ++i, ++map_iter)
1431 {
1432 keys[i] = map_iter->first;
1433 items[i] = map_iter->second;
1434 }
1435 }
1436 }
1437
1440 template<typename Type>
1441 static void Reverse(const ArrayPtr<Type> &arr)
1442 {
1443 std::reverse(arr->m_data.begin(), arr->m_data.end());
1444 }
1445
1450 template<typename Type>
1451 static void Reverse(const ArrayPtr<Type> &arr, int startIndex, int count)
1452 {
1453 using namespace Collections::Generic::Details;
1454 if (!arr) {
1455 throw ArgumentNullException(u"arr");
1456 }
1457 if (startIndex < 0 || count < 0 || IsOutOfSize(startIndex + count, arr->data())) {
1458 throw ArgumentOutOfRangeException(u"startIndex or count");
1459 }
1460
1461 std::reverse(arr->m_data.begin() + startIndex, arr->m_data.begin() + startIndex + count);
1462 }
1463
1467 template<typename Type>
1468 static void Resize(ArrayPtr<Type> &arr, int new_size)
1469 {
1470 if (new_size < 0)
1471 throw ArgumentOutOfRangeException(u"new_size");
1472
1473 if (arr)
1474 arr->m_data.resize((typename vector_t::size_type)new_size);
1475 else
1476 arr = MakeObject<Array<T>>(new_size);
1477 }
1478
1482 void SetValue(const T &value, int index)
1483 {
1484 using namespace Collections::Generic::Details;
1485 if (IsOutOfBounds(index, m_data)) {
1486 throw ArgumentOutOfRangeException(u"index");
1487 }
1488 m_data[index] = value;
1489 }
1490
1492 vector_t& data() { return m_data; }
1493
1495 const vector_t& data() const { return m_data; }
1496
1498 typename vector_t::pointer data_ptr() // VS2013 std::vector has no data() member
1499 {
1500 if(m_data.empty())
1501 return nullptr;
1502
1503 return &m_data[0];
1504 }
1505
1507 const UnderlyingType * data_ptr() const { return data_ptr(); }
1508
1510 typedef typename vector_t::iterator iterator;
1512 typedef typename vector_t::const_iterator const_iterator;
1514 typedef typename vector_t::reverse_iterator reverse_iterator;
1516 typedef typename vector_t::const_reverse_iterator const_reverse_iterator;
1517
1521 iterator begin() noexcept
1522 {
1523 return m_data.begin();
1524 }
1525
1529 const_iterator begin() const noexcept
1530 {
1531 return m_data.begin();
1532 }
1533
1537 const_iterator cbegin() const noexcept
1538 {
1539 return m_data.cbegin();
1540 }
1541
1545 iterator end() noexcept
1546 {
1547 return m_data.end();
1548 }
1549
1553 const_iterator end() const noexcept
1554 {
1555 return m_data.end();
1556 }
1557
1561 const_iterator cend() const noexcept
1562 {
1563 return m_data.cend();
1564 }
1565
1571 {
1572 return m_data.rbegin();
1573 }
1574
1580 {
1581 return m_data.rbegin();
1582 }
1583
1589 {
1590 return m_data.crbegin();
1591 }
1592
1598 {
1599 return m_data.rend();
1600 }
1601
1607 {
1608 return m_data.rend();
1609 }
1610
1616 {
1617 return m_data.crend();
1618 }
1619
1620 // int get_Count() const; - see ICollection<T> interface
1621 // void Add(const T& item); - see ICollection<T> interface
1622 // void Clear(); - see ICollection<T> interface
1623 // bool Contains(const T& item) const; - see ICollection<T> interface
1624 // bool Remove(const T& item); - see ICollection<T> interface
1625
1626 // IList interface
1627
1628 // int IndexOf(const T& item) const; - see IList<T> interface
1629 // void Insert(int index, const T& item); - see IList<T> interface
1630 // void RemoveAt(int index); - see IList<T> interface
1631
1632 // IEnumerable interface
1636 {
1637 return *std::min_element(m_data.cbegin(), m_data.cend());
1638 }
1639
1643 {
1644 return *std::max_element(m_data.cbegin(), m_data.cend());
1645 }
1646
1651 static bool Exists(ArrayPtr<T> arr, std::function<bool(T)> match)
1652 {
1653 for (int i = 0; i < arr->get_Length(); i++)
1654 {
1655 if (match(arr[i]))
1656 return true;
1657 }
1658 return false;
1659 }
1660
1662 System::Details::VirtualizedIteratorBase<T>* virtualizeBeginIterator() override
1663 {
1664 return new System::Details::NativeIteratorWrapper<T, iterator>(begin(), end());
1665 }
1667 System::Details::VirtualizedIteratorBase<T>* virtualizeEndIterator() override
1668 {
1669 return new System::Details::NativeIteratorWrapper<T, iterator>(end(), end());
1670 }
1672 System::Details::VirtualizedIteratorBase<T>* virtualizeBeginConstIterator() const override
1673 {
1674 return new System::Details::NativeConstIteratorWrapper<T, const_iterator>(begin(), end());
1675 }
1677 System::Details::VirtualizedIteratorBase<T>* virtualizeEndConstIterator() const override
1678 {
1679 return new System::Details::NativeConstIteratorWrapper<T, const_iterator>(end(), end());
1680 }
1681
1682private:
1688 template <typename ErrType>
1689 static int upper_bound(ErrType arr, int dim)
1690 {
1691 ASPOSE_UNUSED(arr);
1692 ASPOSE_UNUSED(dim);
1693 throw System::IndexOutOfRangeException();
1694 }
1701 template <typename VType, typename Alloc>
1702 static int upper_bound(const std::vector<VType, Alloc> &arr, int dim)
1703 {
1704 if (!dim)
1705 return (int)arr.size() - 1;
1706
1707 if (!arr.size())
1708 return -1;
1709
1710 return upper_bound(arr[0], dim - 1);
1711 }
1712
1718 template <typename U, typename Alloc>
1719 static size_t recursive_size(const std::vector<U, Alloc>& v)
1720 {
1721 return v.size();
1722 }
1723
1731 template <typename U, typename Alloc1, typename Alloc2>
1732 static size_t recursive_size(const std::vector<std::vector<U, Alloc1>, Alloc2>& v)
1733 {
1734 size_t rv = 0;
1735 for (const auto &i : v)
1736 rv += recursive_size(i);
1737
1738 return rv;
1739 }
1740
1741protected:
1743 ~Array() override {}
1744
1745#ifdef __DBG_FOR_EACH_MEMBER
1746 public:
1749 void DBG_for_each_member(DBG::for_each_member_visitor &visitor) const override
1750 {
1751 visitor.add_self(this);
1752 DBG::for_each_of_Object(this, m_data, visitor);
1753 }
1755 const char* DBG_class_name() const override { return "Array<T>"; }
1756#endif
1757 };
1760 template <typename TTo>
1761 struct CastResult<Array<TTo>>
1762 {
1764 typedef ArrayPtr<TTo> type;
1765 };
1767
1768
1769 namespace Details {
1773 template <typename T>
1774 inline Array<T>* CreateArray(Array<T>*)
1775 {
1776 return new Array<T>(0);
1777 }
1778
1779 } // namespace Details
1780
1781} // namespace System
1782
1783#endif // _aspose_system_array_h_
Implements IEnumerator interface that enables enumeration of elements of an Array object....
Definition: array.h:295
virtual ~Enumerator()
Destructor.
Definition: array.h:310
Enumerator(const SharedPtr< Array< T > > &arr)
Constructs a new Enumerator object that represents the specified array.
Definition: array.h:307
virtual MakeConstRef_t< T > get_Current() const override
Returns a copy of the current element.
Definition: array.h:313
virtual bool MoveNext() override
Checks if the current element's index does not point to the last element in the array and advances it...
Definition: array.h:323
virtual void Reset() override
Resets the current element's index.
Definition: array.h:332
Class that represents an array data structure. Objects of this class should only be allocated using S...
Definition: array.h:259
static System::ArrayPtr< T > FindAll(System::ArrayPtr< T > arr, System::Predicate< T > match)
Retrieves all the elements that match the conditions defined by the specified predicate.
Definition: array.h:779
static void Clear(const ArrayPtr< Type > &arr, int startIndex, int count)
Replaces count values starting at the startIndex index in the specified array with default values.
Definition: array.h:1076
static ArrayPtr< OutputType > ConvertAll(ArrayPtr< InputType > input_array, std::function< OutputType(InputType)> converter)
Constructs a new Array object and fills it with elements of the specified array converted to OutputTy...
Definition: array.h:734
const_reverse_iterator crbegin() const noexcept
Returns a reverse iterator to the first element of the reversed container. It corresponds to the last...
Definition: array.h:1588
static int IndexOf(const ArrayPtr< ArrayType > &arr, const ValueType &value)
Determines the index of the first occurrence of specified item in the array.
Definition: array.h:973
void SetValue(const T &value, int index)
Sets value of the element at specified index.
Definition: array.h:1482
SharedPtr< Collections::Generic::IEnumerator< T > > EnumeratorPtr
An alias for shared pointer type pointing to IEnumerator object containing elements of type T.
Definition: array.h:288
static void ConstrainedCopy(const ArrayPtr< SrcType > &srcArray, int64_t srcIndex, const ArrayPtr< DstType > &dstArray, int64_t dstIndex, int64_t count)
Copies a range of elements from an System.Array starting at the specified source.
Definition: array.h:1102
vector_t::iterator iterator
Iterator type.
Definition: array.h:1510
static void Sort(const ArrayPtr< Type > &arr, const SharedPtr< System::Collections::Generic::IComparer< T > > &comparator)
Sorts elements in the specified array using specified comparer.
Definition: array.h:1368
reverse_iterator rbegin() noexcept
Returns a reverse iterator to the first element of the reversed container. It corresponds to the last...
Definition: array.h:1570
UnderlyingType Min() const
Finds the smallest element in the array using operator<() to compare elements.
Definition: array.h:1635
Array(std::vector< Q > &&value)
Constructs an Array object and fills it with values moved from an std::vector object whose values' ty...
Definition: array.h:409
virtual bool Contains(const T &item) const override
Determines if the specified item is in the array.
Definition: array.h:498
vector_t::const_reverse_iterator const_reverse_iterator
Const reverse iterator type.
Definition: array.h:1516
const UnderlyingType * data_ptr() const
Returns a constant raw pointer to the beginning of the memory buffer where the array elements are sto...
Definition: array.h:1507
~Array() override
Destructor.
Definition: array.h:1743
virtual void Clear() override
Not supported because the array represented by the current object is read-only.
Definition: array.h:464
static void Copy(System::Details::ArrayView< SrcType > srcArray, int64_t srcIndex, System::Details::ArrayView< DstType > dstArray, int64_t dstIndex, int64_t count)
Copies a specified number of elements from the source array view starting at the specified index to t...
Definition: array.h:1264
iterator begin() noexcept
Returns an iterator to the first element of the container. If the container is empty,...
Definition: array.h:1521
virtual int IndexOf(const T &item) const override
Determines the index of the first occurrence of the specified item in the array.
Definition: array.h:561
static void Sort(const ArrayPtr< Type > &arr, const SharedPtr< System::Collections::Generic::IComparer< Y > > &comparator)
NOT IMPLEMENTED.
Definition: array.h:1377
vector_t m_data
The storage for array's elements.
Definition: array.h:280
static T Find(System::ArrayPtr< T > arr, System::Predicate< T > match)
Searches for the first element in the specified array that satisfies the conditions of the specified ...
Definition: array.h:762
ArrayPtr< T > Init(const T inits[])
Fills the array represented by the current object with the values from the specified array.
Definition: array.h:601
static void Sort(const ArrayPtr< TKey > &keys, const ArrayPtr< TValue > &items, int index, int length)
Sorts two arrays one containing keys and the other - corresponding items, based on the values of arra...
Definition: array.h:1406
int GetLength(int dimension)
Returns the number of elements in the specified dimension.
Definition: array.h:670
virtual EnumeratorPtr GetEnumerator() override
Returns a pointer to Enumerator object that provides IEnumerator interface to elements of the array r...
Definition: array.h:439
Array(vector_t &&value)
Move constructor.
Definition: array.h:389
vector_t::pointer data_ptr()
Returns a raw pointer to the beginning of the memory buffer where the array elements are stored.
Definition: array.h:1498
static void Reverse(const ArrayPtr< Type > &arr)
Reverses elements in the specified array.
Definition: array.h:1441
static void Copy(System::Details::StackArray< SrcType, NS > &srcArray, int64_t srcIndex, System::Details::StackArray< DstType, ND > &dstArray, int64_t dstIndex, int64_t count)
Copies a specified number of elements from the source array on stack starting at the specified index ...
Definition: array.h:1312
const vector_t & data() const
Returns a constant reference to the internal data structure used to store the array elements.
Definition: array.h:1495
static void Copy(System::Details::ArrayView< SrcType > &srcArray, int64_t srcIndex, System::Details::StackArray< DstType, ND > &dstArray, int64_t dstIndex, int64_t count)
Copies a specified number of elements from the source array view starting at the specified index to t...
Definition: array.h:1328
Array(std::initializer_list< bool > init, int=0)
Constructs an Array object and fills it with values from the specified initializer list containing el...
Definition: array.h:429
static int IndexOf(const ArrayPtr< ArrayType > &arr, const ValueType &value, int startIndex, int count)
Determines the index of the first occurrence of the specified item in a range of items of the array s...
Definition: array.h:1000
static void Copy(const ArrayPtr< SrcType > &srcArray, System::Details::ArrayView< DstType > dstArray, int64_t count)
Copies the specified number of elements from the source array to the destination array view.
Definition: array.h:1144
SharedPtr< Collections::Generic::IEnumerable< T > > EnumerablePtr
An alias for shared pointer type pointing to IEnumerable object containing elements of type T.
Definition: array.h:286
Array(const std::vector< Q > &value)
Constructs an Array object and fills it with values copied from an std::vector object whose values' t...
Definition: array.h:400
System::Details::CollectionHelpers::ContainerPointerMode< UnderlyingType > pointer_mode_t
Type to keep information on whether to treat array elements as shared or weak pointers,...
Definition: array.h:274
void CopyTo(const ArrayPtr< DstType > &dstArray, int64_t srcIndex, int64_t dstIndex, int64_t count) const
Copies a specified number of elements from the current array starting at specified position to specif...
Definition: array.h:876
System::Details::VirtualizedIteratorBase< T > * virtualizeEndConstIterator() const override
Gets the implementation of end const iterator for the current container.
Definition: array.h:1677
ArrayPtr< T > Clone()
Clones the array.
Definition: array.h:643
virtual void Add(const T &) override
Not supported because the array represented by the current object is read-only.
Definition: array.h:457
vector_t & data()
Returns a reference to the internal data structure used to store the array elements.
Definition: array.h:1492
void CopyTo(const ArrayPtr< DstType > &dstArray, int64_t dstIndex) const
Copies all elements of the current array to the specified destination array. Elements are inserted in...
Definition: array.h:851
void CopyTo(const System::Details::ArrayView< DstType > &dstArray, int64_t dstIndex) const
Copies all elements of the current array to the specified destination array view. Elements are insert...
Definition: array.h:862
void CopyTo(const System::Details::ArrayView< DstType > &dstArray, int64_t srcIndex, int64_t dstIndex, int64_t count) const
Copies a specified number of elements from the current array starting at specified position to specif...
Definition: array.h:920
virtual bool Remove(const T &) override
Not supported because the array represented by the current object is read-only.
Definition: array.h:505
const_reverse_iterator rend() const noexcept
Returns a reverse iterator to the element following the last element of the reversed container....
Definition: array.h:1606
Array(const vector_t &assgn)
Copy constructor.
Definition: array.h:393
iterator end() noexcept
Returns an iterator to the element following the last element of the container. This element acts as ...
Definition: array.h:1545
static int BinarySearch(System::ArrayPtr< T > arr, const T &item)
Performs binary search in the sorted array.
Definition: array.h:654
UnderlyingType Max() const
Finds the largest element in the array using operator<() to compare elements.
Definition: array.h:1642
int32_t get_Rank() const
NOT IMPLEMENTED.
Definition: array.h:812
const_iterator end() const noexcept
Returns an iterator to the element following the last element of the const-qualified container....
Definition: array.h:1553
static ArrayPtr< OutputType > ConvertAll(ArrayPtr< InputType > input_array, Converter< InputType, OutputType > converter)
Constructs a new Array object and fills it with elements of the specified array converted to OutputTy...
Definition: array.h:707
static int IndexOf(const ArrayPtr< ArrayType > &arr, const ValueType &value, int startIndex)
Determines the index of the first occurrence of the specified item in the array starting from the spe...
Definition: array.h:986
static bool Exists(ArrayPtr< T > arr, std::function< bool(T)> match)
Determines if the specified Array object contains an element that satisfies requirements of the speci...
Definition: array.h:1651
T ValueType
Alias for the type of the elements of the array.
Definition: array.h:268
static void Copy(System::Details::ArrayView< SrcType > srcArray, System::Details::ArrayView< DstType > dstArray, int64_t count)
Copies the specified number of elements from the source array view to the destination array view.
Definition: array.h:1158
static bool TrueForAll(System::ArrayPtr< T > arr, System::Predicate< T > match)
Determines whether all elements in the specified array satisfy the conditions defined by specified pr...
Definition: array.h:799
static int FindIndex(System::ArrayPtr< T > arr, System::Predicate< T > match)
Searches for the first element in the specified array that satisfies the conditions of the specified ...
Definition: array.h:743
static int LastIndexOf(const ArrayPtr< ArrayType > &arr, const ValueType &value, int startIndex, int count)
Determines the index of the last occurrence of the specified item in a range of items of the array sp...
Definition: array.h:1027
static void Copy(const ArrayPtr< SrcType > &srcArray, const ArrayPtr< DstType > &dstArray, int64_t count)
Copies the specified number of elements from the source array to the destination array.
Definition: array.h:1116
vector_t::reverse_iterator reverse_iterator
Reverse iterator type.
Definition: array.h:1514
Array(int count, const T &init=T())
Filling constructor.
Definition: array.h:368
int64_t get_LongLength() const
Returns 64-bit integer that represents the total number of all elements in all dimensions of the arra...
Definition: array.h:829
static void Copy(System::Details::StackArray< SrcType, NS > &srcArray, System::Details::StackArray< DstType, ND > &dstArray, int64_t count)
Copies the specified number of elements from the source array on stack to the destination array on st...
Definition: array.h:1194
System::Details::VirtualizedIteratorBase< T > * virtualizeBeginConstIterator() const override
Gets the implementation of begin const iterator for the current container.
Definition: array.h:1672
UnderlyingType const & operator[](int index) const
Returns an item at the specified index.
Definition: array.h:631
virtual void CopyTo(ArrayPtr< T > arr, int arrayIndex) override
Copies all elements of the current array to the specified destination array. Elements are inserted in...
Definition: array.h:524
virtual bool get_IsReadOnly() const override
Indicates whether the array is read-only.
Definition: array.h:515
static void Sort(const ArrayPtr< TKey > &keys, const ArrayPtr< TValue > &items)
Sorts two arrays one containing keys and the other - corresponding items, based on the values of arra...
Definition: array.h:1389
void Initialize()
Fills the array with the default constructed objects of type T.
Definition: array.h:610
Array(int count, const T inits[])
Filling constructor.
Definition: array.h:381
virtual T idx_get(int index) const override
Returns the item at the specified index.
Definition: array.h:583
int GetLowerBound(int dimension) const
Returns the lower bound of the specified dimension.
Definition: array.h:686
System::Details::VirtualizedIteratorBase< T > * virtualizeEndIterator() override
Gets the implementation of end iterator for the current container.
Definition: array.h:1667
static void ForEach(const ArrayPtr< T > &arr, System::Action< T > action)
Performs specified action on each element of the specified array.
Definition: array.h:957
int64_t GetLongLength(int dimension)
Returns the number of elements in the specified dimension as 64-bit integer.
Definition: array.h:678
static void Copy(System::Details::StackArray< SrcType, N > &srcArray, int64_t srcIndex, const ArrayPtr< DstType > &dstArray, int64_t dstIndex, int64_t count)
Copies a specified number of elements from the source array on stack starting at the specified index ...
Definition: array.h:1282
static int BinarySearch(System::ArrayPtr< T > arr, const Y &item, const SharedPtr< Collections::Generic::IComparer< Z > > &comparer)
NOT IMPLEMENTED.
Definition: array.h:662
static int LastIndexOf(const ArrayPtr< ArrayType > &items, const ValueType &value, int startIndex)
Determines the index of the last occurrence of the specified item in the array starting from the spec...
Definition: array.h:1053
static void Copy(const ArrayPtr< SrcType > &srcArray, System::Details::StackArray< DstType, N > &dstArray, int64_t count)
Copies the specified number of elements from the source array to the destination array on stack.
Definition: array.h:1183
virtual int get_Count() const override
Returns the size of the array.
Definition: array.h:450
typename System::Details::SelectType< T >::type UnderlyingType
Alias for the type used to represent each element of the array.
Definition: array.h:270
static void Sort(const ArrayPtr< Type > &arr)
Sorts elements in the specified array using default comparer.
Definition: array.h:1338
virtual void RemoveAt(int) override
Not supported because array represented by the current object is read-only.
Definition: array.h:575
virtual void idx_set(int index, T value) override
Sets the specified value as the item of the array at the specified index.
Definition: array.h:591
const_iterator cbegin() const noexcept
Returns an iterator to the first const-qualified element of the container. If the container is empty,...
Definition: array.h:1537
static void Copy(System::Details::ArrayView< SrcType > srcArray, const ArrayPtr< DstType > &dstArray, int64_t count)
Copies the specified number of elements from the source array view to the destination array.
Definition: array.h:1130
Array(const std::array< UnderlyingType, InitArraySize > &init)
Constructs an Array object and fills it with values from the specified array containing elements of U...
Definition: array.h:423
size_t GetSizeTLength() const
Returns an std::size_t variable that represents the total number of all elements in all dimensions of...
Definition: array.h:836
static void Resize(ArrayPtr< Type > &arr, int new_size)
Changes the size of the specified array to the specified value or crates new array with specified siz...
Definition: array.h:1468
static void Copy(System::Details::StackArray< SrcType, N > &srcArray, const ArrayPtr< DstType > &dstArray, int64_t count)
Copies the specified number of elements from the source array on stack to the destination array.
Definition: array.h:1172
static void Copy(const ArrayPtr< SrcType > &srcArray, int64_t srcIndex, System::Details::ArrayView< DstType > dstArray, int64_t dstIndex, int64_t count)
Copies a specified number of elements from the source array starting at the specified index to the sp...
Definition: array.h:1246
const_iterator cend() const noexcept
Returns an iterator to the element following the last element of the container. This element acts as ...
Definition: array.h:1561
static int LastIndexOf(const ArrayPtr< ArrayType > &items, const ValueType &value)
Determines the index of the last occurrence of the specified item in the array.
Definition: array.h:1065
std::vector< UnderlyingType, typename pointer_mode_t::allocator_type > vector_t
An alias for the type used to store the array's elements.
Definition: array.h:276
int GetUpperBound(int dimension)
Returns the upper bound of the specified dimension.
Definition: array.h:695
void SetTemplateWeakPtr(uint32_t argument) override
Makes array treat stored pointers as weak (if applicable).
Definition: array.h:471
const_iterator begin() const noexcept
Returns an iterator to the first element of the const-qualified container. If the container is empty,...
Definition: array.h:1529
virtual void Insert(int, const T &) override
Not supported because array represented by the current object is read-only.
Definition: array.h:568
static void Copy(const ArrayPtr< SrcType > &srcArray, int64_t srcIndex, const ArrayPtr< DstType > &dstArray, int64_t dstIndex, int64_t count)
Copies a specified number of elements from the source array starting at the specified index to the sp...
Definition: array.h:1210
static void Copy(System::Details::ArrayView< SrcType > srcArray, int64_t srcIndex, const ArrayPtr< DstType > &dstArray, int64_t dstIndex, int64_t count)
Copies a specified number of elements from the source array view starting at the specified index to t...
Definition: array.h:1228
const_reverse_iterator crend() const noexcept
Returns a reverse iterator to the element following the last element of the reversed container....
Definition: array.h:1615
static void Sort(const ArrayPtr< Type > &arr, int startIndex, int count)
Sorts a range of elements in the specified array using default comparer.
Definition: array.h:1348
vector_t::const_iterator const_iterator
Const iterator type.
Definition: array.h:1512
pointer_mode_t m_pointer_mode
Information on whether to treat array elements as shared or weak pointers, if applicable.
Definition: array.h:278
Array(typename std::enable_if< std::is_arithmetic< T >::value &&std::is_arithmetic< ValueType >::value &&std::is_convertible< ValueType, T >::value, int >::type count, ValueType init)
Filling constructor.
Definition: array.h:375
int32_t get_Length() const
Returns 32-bit integer that represents the total number of all elements in all dimensions of the arra...
Definition: array.h:816
reverse_iterator rend() noexcept
Returns a reverse iterator to the element following the last element of the reversed container....
Definition: array.h:1597
const_reverse_iterator rbegin() const noexcept
Returns a reverse iterator to the first element of the reversed container. It corresponds to the last...
Definition: array.h:1579
static void Reverse(const ArrayPtr< Type > &arr, int startIndex, int count)
Reverses a range of elements in the specified array.
Definition: array.h:1451
static void Copy(const ArrayPtr< SrcType > &srcArray, int64_t srcIndex, System::Details::StackArray< DstType, N > &dstArray, int64_t dstIndex, int64_t count)
Copies a specified number of elements from the source array starting at the specified index to the sp...
Definition: array.h:1297
Array()
Constructs an empty array.
Definition: array.h:363
Array(std::initializer_list< UnderlyingType > init)
Constructs an Array object and fills it with values from the specified initializer list containing el...
Definition: array.h:417
System::Details::VirtualizedIteratorBase< T > * virtualizeBeginIterator() override
Gets the implementation of begin iterator for the current container.
Definition: array.h:1662
int Count() const
Returns a number that represents the total number of all elements in all dimensions of the array.
Definition: array.h:843
UnderlyingType & operator[](int index)
Returns an item at the specified index.
Definition: array.h:619
Interface that compares two objects in greater-equal-less sense. Objects of this class should only be...
Definition: icomparer.h:20
Interface of enumerator which can be used to iterate through some elements. Objects of this class sho...
Definition: ienumerator.h:63
Interface of indexed container of elements. Objects of this class should only be allocated using Syst...
Definition: ilist.h:19
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
auto end() -> decltype(std::declval< Q >().end())
Accessor for end() method of an underling collection. Only compiles if SmartPtr_ is specialization ty...
Definition: smart_ptr.h:838
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
Pointee_ * get_shared() const
Gets pointed object, but asserts that pointer is in shared mode.
Definition: smart_ptr.h:524
class System::SmartPtr::Data m_data
An instance of Data class.
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
ArrayPtr< T > MakeArray(std::initializer_list< T > init)
A factory function that constructs a new Array object, fills it with the elements from the specified ...
Definition: array.h:138
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
typename MakeConstRef< T >::type MakeConstRef_t
Helper type for MakeConstRef modifier.
Definition: make_const_ref.h:20
System::ArrayPtr< uint8_t > ByteArrayPtr
An alias for a smart pointer object that points to an array of unsigned 8-bit integers.
Definition: array.h:107
class ASPOSECPP_SHARED_CLASS Array
Definition: smart_ptr.h:22
SmartPtr< TTo > type
An alias for a pointer to an instance of TTo.
Definition: object.h:387
Adapter to use IComparer within STL environment. Uses IComparer if set; otherwise,...
Definition: icomparer.h:44