10 #define _COLLECTION_H_
14 #ifndef __cplusplus_winrt
15 #error collection.h requires the /ZW compiler option.
33 #define _COLLECTION_ATTRIBUTES [::Platform::Metadata::RuntimeClassName] [::Windows::Foundation::Metadata::Default]
35 #define _COLLECTION_TRANSLATE \
36 } catch (const ::std::bad_alloc&) { \
37 throw ref new OutOfMemoryException; \
38 } catch (const ::std::exception&) { \
39 throw ref new FailureException; \
42 #ifndef _COLLECTION_WUXI
43 #define _COLLECTION_WUXI 1
47 #pragma pack(push, 16)
52 #pragma warning(push, 4)
54 #pragma warning(disable: 4451) // Usage of ref class 'Meow' inside this context can lead to invalid marshaling of object across contexts
57 namespace Collections {
59 namespace WFC = ::Windows::Foundation::Collections;
62 namespace WUXI = ::Windows::UI::Xaml::Interop;
63 #endif // _COLLECTION_WUXI
65 typedef ::Windows::Foundation::EventRegistrationToken Token;
67 inline void ValidateBounds(
bool b) {
69 throw ref new OutOfBoundsException;
73 inline void ValidateCounter(const ::std::shared_ptr<unsigned int>& ctr,
unsigned int good_ctr) {
74 if (*ctr != good_ctr) {
75 throw ref new ChangedStateException;
79 inline void ValidateSize(
size_t n) {
80 if (n > 0x7FFFFFFFUL) {
81 throw ref new OutOfMemoryException;
85 template <
typename T>
struct AlwaysFalse
88 template <
typename T>
struct Wrap {
92 template <
typename T>
struct Wrap<T^>
93 : public ::std::conditional<__is_winrt_agile(T), T^, Agile<T^>> { };
95 template <
typename T>
inline const T& MakeWrap(
const T& t) {
99 template <
typename T>
inline typename ::std::enable_if<!__is_winrt_agile(T), Agile<T^>>::type MakeWrap(T^
const & t) {
103 template <
typename T>
inline const T& Unwrap(
const T& t) {
107 template <
typename T>
inline T^ Unwrap(
const Agile<T^>& a) {
111 template <
typename T,
typename U>
struct VectorEnableIf
112 :
public ::std::enable_if< ::std::is_same<T, U>::value || ::std::is_same<typename Wrap<T>::type, U>::value, void **> { };
114 template <
typename X>
inline void Init(::std::shared_ptr<unsigned int>& ctr, ::std::shared_ptr<X>& sp) {
116 ctr = ::std::make_shared<unsigned int>(0);
117 sp = ::std::make_shared<X>();
121 template <
typename X,
typename A>
inline void Init(::std::shared_ptr<unsigned int>& ctr, ::std::shared_ptr<X>& sp, A&& a) {
123 ctr = ::std::make_shared<unsigned int>(0);
124 sp = ::std::make_shared<X>(::std::forward<A>(a));
126 ValidateSize(sp->size());
130 template <
typename X,
typename A,
typename B>
inline void Init(::std::shared_ptr<unsigned int>& ctr, ::std::shared_ptr<X>& sp, A&& a, B&& b) {
132 ctr = ::std::make_shared<unsigned int>(0);
133 sp = ::std::make_shared<X>(::std::forward<A>(a), ::std::forward<B>(b));
135 ValidateSize(sp->size());
139 template <
typename X,
typename A,
typename B,
typename C>
inline void Init(::std::shared_ptr<unsigned int>& ctr, ::std::shared_ptr<X>& sp, A&& a, B&& b, C&& c) {
141 ctr = ::std::make_shared<unsigned int>(0);
142 sp = ::std::make_shared<X>(::std::forward<A>(a), ::std::forward<B>(b), ::std::forward<C>(c));
144 ValidateSize(sp->size());
148 template <
typename X,
typename A>
inline void InitMoveVector(::std::shared_ptr<unsigned int>& ctr, ::std::shared_ptr<X>& sp, A&& a) {
149 Init(ctr, sp, a.begin(), a.end());
152 template <
typename X>
inline void InitMoveVector(::std::shared_ptr<unsigned int>& ctr, ::std::shared_ptr<X>& sp, X&& x) {
156 template <
typename K,
typename V,
typename M,
typename InIt>
inline void EmplaceWrappedRange(M&
m, InIt first, InIt last) {
157 for ( ; first != last; ++first) {
158 ::std::pair<const K, V> p(*first);
160 m.emplace(MakeWrap(p.first), MakeWrap(p.second));
164 template <
typename K,
typename V,
typename X,
typename A>
inline void InitMoveMap(::std::shared_ptr<unsigned int>& ctr, ::std::shared_ptr<X>& sp, A&& a) {
165 Init(ctr, sp, a.key_comp());
167 EmplaceWrappedRange<K, V>(*sp, a.begin(), a.end());
170 template <
typename K,
typename V,
typename X>
inline void InitMoveMap(::std::shared_ptr<unsigned int>& ctr, ::std::shared_ptr<X>& sp, X&& x) {
174 inline void IncrementCounter(::std::shared_ptr<unsigned int>& ctr) {
175 if (++*ctr == static_cast<unsigned int>(-1)) {
177 ctr = ::std::make_shared<unsigned int>(0);
183 VectorChangedEventArgs(WFC::CollectionChange change,
unsigned int index)
184 : m_change(change), m_index(index) { }
187 virtual property WFC::CollectionChange CollectionChange {
188 virtual WFC::CollectionChange
get() {
193 virtual property unsigned int Index {
194 virtual unsigned int get() {
195 if (m_change == WFC::CollectionChange::Reset) {
196 throw ref new FailureException;
204 WFC::CollectionChange m_change;
205 unsigned int m_index;
208 template <
typename K>
ref class MapChangedEventArgsReset
sealed :
public _COLLECTION_ATTRIBUTES WFC::IMapChangedEventArgs<K> {
210 virtual property WFC::CollectionChange CollectionChange {
211 virtual WFC::CollectionChange
get() {
212 return WFC::CollectionChange::Reset;
216 virtual property K Key {
218 throw ref new FailureException;
223 template <
typename K>
ref class MapChangedEventArgs
sealed :
public _COLLECTION_ATTRIBUTES WFC::IMapChangedEventArgs<K> {
225 MapChangedEventArgs(WFC::CollectionChange change, K key)
226 : m_change(change), m_key(key) { }
229 virtual property WFC::CollectionChange CollectionChange {
230 virtual WFC::CollectionChange
get() {
235 virtual property K Key {
237 return Unwrap(m_key);
242 WFC::CollectionChange m_change;
243 typename Wrap<K>::type m_key;
246 template <
typename T,
typename E>
inline bool VectorIndexOf(const ::std::vector<
typename Wrap<T>::type>& v, T value,
unsigned int * index) {
247 auto pred = [&](
const typename Wrap<T>::type& elem) {
return E()(Unwrap(elem), value); };
249 *index =
static_cast<unsigned int>(
::std::find_if(v.begin(), v.end(), pred) - v.begin());
251 return *index < v.size();
259 template <
typename T,
typename E>
inline bool VectorBindableIndexOf(::
std::false_type, const ::std::vector<
typename Wrap<T>::type>& v, Object^ o,
unsigned int * index) {
260 IBox<T>^ ib =
dynamic_cast<IBox<T>^
>(o);
263 return VectorIndexOf<T, E>(v, ib->Value, index);
265 *index =
static_cast<unsigned int>(v.size());
270 template <
typename T,
typename E>
inline bool VectorBindableIndexOf(::
std::true_type, const ::std::vector<
typename Wrap<T>::type>& v, Object^ o,
unsigned int * index) {
271 T t =
dynamic_cast<T
>(o);
274 return VectorIndexOf<T, E>(v, t, index);
276 *index =
static_cast<unsigned int>(v.size());
281 template <
typename T,
typename E>
inline bool VectorBindableIndexOf(const ::std::vector<
typename Wrap<T>::type>& v, Object^ o,
unsigned int * index) {
282 return VectorBindableIndexOf<T, E>(is_hat<T>(), v, o, index);
284 #endif // _COLLECTION_WUXI
286 template <
typename T>
inline unsigned int VectorGetMany(const ::std::vector<
typename Wrap<T>::type>& v,
unsigned int startIndex, WriteOnlyArray<T>^ dest) {
287 unsigned int capacity = dest->Length;
289 unsigned int actual =
static_cast<unsigned int>(v.size()) - startIndex;
291 if (actual > capacity) {
295 for (
unsigned int i = 0;
i < actual; ++
i) {
296 dest->set(
i, Unwrap(v[startIndex +
i]));
302 template <
typename T>
ref class IteratorForVectorView
sealed
305 ,
public WUXI::IBindableIterator
306 #endif // _COLLECTION_WUXI
309 typedef ::std::vector<typename Wrap<T>::type> WrappedVector;
310 typedef WFC::IIterator<T> WFC_Base;
313 typedef WUXI::IBindableIterator WUXI_Base;
314 #endif // _COLLECTION_WUXI
317 IteratorForVectorView(const ::std::shared_ptr<unsigned int>& ctr, const ::std::shared_ptr<WrappedVector>& vec)
318 : m_ctr(ctr), m_vec(vec), m_good_ctr(*ctr), m_index(0) { }
321 virtual property T Current {
323 ValidateCounter(m_ctr, m_good_ctr);
325 ValidateBounds(m_index < m_vec->size());
327 return Unwrap((*m_vec)[m_index]);
331 virtual property bool HasCurrent {
333 ValidateCounter(m_ctr, m_good_ctr);
335 return m_index < m_vec->size();
339 virtual bool MoveNext() {
340 ValidateCounter(m_ctr, m_good_ctr);
342 ValidateBounds(m_index < m_vec->size());
345 return m_index < m_vec->size();
348 virtual unsigned int GetMany(WriteOnlyArray<T>^ dest) {
349 ValidateCounter(m_ctr, m_good_ctr);
351 unsigned int actual = VectorGetMany(*m_vec, m_index, dest);
364 #endif // _COLLECTION_WUXI
366 ::std::shared_ptr<unsigned int> m_ctr;
367 ::std::shared_ptr<WrappedVector> m_vec;
368 unsigned int m_good_ctr;
369 unsigned int m_index;
373 template <
typename T,
typename E = ::std::equal_to<T>,
bool = __is_val
id_winrt_type(T)>
ref class Vector;
374 template <
typename T,
typename E = ::std::equal_to<T>,
bool = __is_val
id_winrt_type(T)>
ref class VectorView;
376 template <
typename T,
typename E>
ref class VectorView<T, E, false> {
377 static_assert(Details::AlwaysFalse<T>::value,
"Platform::Collections::VectorView<T, E> requires T to be a valid Windows Runtime type.");
380 template <
typename T,
typename E,
bool>
ref class VectorView
sealed
383 ,
public Details::WUXI::IBindableVectorView
384 #endif // _COLLECTION_WUXI
387 typedef ::std::vector<typename Details::Wrap<T>::type> WrappedVector;
388 typedef Details::WFC::IVectorView<T> WFC_Base;
391 typedef Details::WUXI::IBindableVectorView WUXI_Base;
392 #endif // _COLLECTION_WUXI
396 Details::Init(m_ctr, m_vec);
401 explicit VectorView(
unsigned int size) {
402 Details::Init(m_ctr, m_vec, size);
407 VectorView(
unsigned int size, T value) {
408 Details::Init(m_ctr, m_vec, size, Details::MakeWrap(value));
413 template <
typename U>
explicit VectorView(const ::std::vector<U>& v,
typename Details::VectorEnableIf<T, U>::type =
nullptr) {
414 Details::Init(m_ctr, m_vec, v.begin(), v.end());
419 template <
typename U>
explicit VectorView(::std::vector<U>&& v,
typename Details::VectorEnableIf<T, U>::type =
nullptr) {
420 Details::InitMoveVector(m_ctr, m_vec, ::
std::move(v));
425 VectorView(
const T * ptr,
unsigned int size) {
426 Details::Init(m_ctr, m_vec, ptr, ptr + size);
431 template <
size_t N>
explicit VectorView(
const T (&arr)[N]) {
432 Details::Init(m_ctr, m_vec, arr, arr + N);
437 template <
size_t N>
explicit VectorView(const ::std::array<T, N>& a) {
438 Details::Init(m_ctr, m_vec, a.begin(), a.end());
443 explicit VectorView(
const Array<T>^ arr) {
444 Details::Init(m_ctr, m_vec, arr->begin(), arr->end());
449 template <
typename InIt> VectorView(InIt first, InIt last) {
452 Details::Init(m_ctr, m_vec, first, last);
457 VectorView(::std::initializer_list<T> il) {
458 Details::Init(m_ctr, m_vec, il.begin(), il.end());
464 virtual Details::WFC::IIterator<T>^ First() = WFC_Base::First {
465 Details::ValidateCounter(m_ctr, m_good_ctr);
467 return ref new Details::IteratorForVectorView<T>(m_ctr, m_vec);
470 virtual T GetAt(
unsigned int index) = WFC_Base::GetAt {
471 Details::ValidateCounter(m_ctr, m_good_ctr);
473 Details::ValidateBounds(index < m_vec->size());
475 return Details::Unwrap((*m_vec)[index]);
478 virtual property unsigned int Size {
479 virtual unsigned int get() {
480 Details::ValidateCounter(m_ctr, m_good_ctr);
482 return static_cast<unsigned int>(m_vec->size());
486 virtual bool IndexOf(T value,
unsigned int * index) = WFC_Base::IndexOf {
489 Details::ValidateCounter(m_ctr, m_good_ctr);
491 return Details::VectorIndexOf<T, E>(*m_vec, value, index);
494 virtual unsigned int GetMany(
unsigned int startIndex, WriteOnlyArray<T>^ dest) {
495 Details::ValidateCounter(m_ctr, m_good_ctr);
497 Details::ValidateBounds(startIndex <= m_vec->size());
499 return Details::VectorGetMany(*m_vec, startIndex, dest);
503 friend ref class Vector<T, E>;
505 VectorView(const ::std::shared_ptr<unsigned int>& ctr, const ::std::shared_ptr<WrappedVector>& vec)
506 : m_ctr(ctr), m_vec(vec), m_good_ctr(*ctr) { }
509 virtual Details::WUXI::IBindableIterator^ BindableFirst() = WUXI_Base::First {
510 return safe_cast<Details::WUXI::IBindableIterator^>(First());
513 virtual Object^ BindableGetAt(
unsigned int index) = WUXI_Base::GetAt {
517 virtual bool BindableIndexOf(Object^ value,
unsigned int * index) = WUXI_Base::IndexOf {
520 Details::ValidateCounter(m_ctr, m_good_ctr);
522 return Details::VectorBindableIndexOf<T, E>(*m_vec, value, index);
524 #endif // _COLLECTION_WUXI
526 ::std::shared_ptr<unsigned int> m_ctr;
527 ::std::shared_ptr<WrappedVector> m_vec;
528 unsigned int m_good_ctr;
531 template <
typename T,
typename E>
ref class Vector<T, E, false> {
532 static_assert(Details::AlwaysFalse<T>::value,
"Platform::Collections::Vector<T, E> requires T to be a valid Windows Runtime type.");
535 template <
typename T,
typename E,
bool>
ref class Vector
sealed
538 ,
public Details::WUXI::IBindableObservableVector
539 #endif // _COLLECTION_WUXI
542 typedef ::std::vector<typename Details::Wrap<T>::type> WrappedVector;
543 typedef Details::WFC::IObservableVector<T> WFC_Base;
544 typedef Details::WFC::VectorChangedEventHandler<T> WFC_Handler;
547 typedef Details::WUXI::IBindableObservableVector WUXI_Base;
548 typedef Details::WUXI::BindableVectorChangedEventHandler WUXI_Handler;
549 #endif // _COLLECTION_WUXI
553 Details::Init(m_ctr, m_vec);
558 explicit Vector(
unsigned int size) {
559 Details::Init(m_ctr, m_vec, size);
564 Vector(
unsigned int size, T value) {
565 Details::Init(m_ctr, m_vec, size, Details::MakeWrap(value));
570 template <
typename U>
explicit Vector(const ::std::vector<U>& v,
typename Details::VectorEnableIf<T, U>::type =
nullptr) {
571 Details::Init(m_ctr, m_vec, v.begin(), v.end());
576 template <
typename U>
explicit Vector(::std::vector<U>&& v,
typename Details::VectorEnableIf<T, U>::type =
nullptr) {
577 Details::InitMoveVector(m_ctr, m_vec, ::
std::move(v));
582 Vector(
const T * ptr,
unsigned int size) {
583 Details::Init(m_ctr, m_vec, ptr, ptr + size);
588 template <
size_t N>
explicit Vector(
const T (&arr)[N]) {
589 Details::Init(m_ctr, m_vec, arr, arr + N);
594 template <
size_t N>
explicit Vector(const ::std::array<T, N>& a) {
595 Details::Init(m_ctr, m_vec, a.begin(), a.end());
600 explicit Vector(
const Array<T>^ arr) {
601 Details::Init(m_ctr, m_vec, arr->begin(), arr->end());
606 template <
typename InIt> Vector(InIt first, InIt last) {
609 Details::Init(m_ctr, m_vec, first, last);
614 Vector(::std::initializer_list<T> il) {
615 Details::Init(m_ctr, m_vec, il.begin(), il.end());
621 virtual Details::WFC::IIterator<T>^ First() = WFC_Base::First {
622 return ref new Details::IteratorForVectorView<T>(m_ctr, m_vec);
625 virtual T GetAt(
unsigned int index) = WFC_Base::GetAt {
626 Details::ValidateBounds(index < m_vec->size());
628 return Details::Unwrap((*m_vec)[index]);
631 virtual property unsigned int Size {
632 virtual unsigned int get() {
633 return static_cast<unsigned int>(m_vec->size());
637 virtual bool IndexOf(T value,
unsigned int * index) = WFC_Base::IndexOf {
640 return Details::VectorIndexOf<T, E>(*m_vec, value, index);
643 virtual unsigned int GetMany(
unsigned int startIndex, WriteOnlyArray<T>^ dest) {
644 Details::ValidateBounds(startIndex <= m_vec->size());
646 return Details::VectorGetMany(*m_vec, startIndex, dest);
649 virtual Details::WFC::IVectorView<T>^ GetView() = WFC_Base::GetView {
650 return ref new VectorView<T, E>(m_ctr, m_vec);
653 virtual void SetAt(
unsigned int index, T item) = WFC_Base::SetAt {
655 Details::IncrementCounter(m_ctr);
657 Details::ValidateBounds(index < m_vec->size());
659 (*m_vec)[index] = item;
661 NotifyChanged(index);
665 virtual void InsertAt(
unsigned int index, T item) = WFC_Base::InsertAt {
667 Details::IncrementCounter(m_ctr);
669 Details::ValidateBounds(index <= m_vec->size());
671 Details::ValidateSize(m_vec->size() + 1);
673 Emplace(m_vec->begin() + index, item, ::std::is_same<T, bool>());
675 NotifyInserted(index);
679 virtual void Append(T item) = WFC_Base::Append {
681 Details::IncrementCounter(m_ctr);
683 size_t n = m_vec->size();
685 Details::ValidateSize(n + 1);
687 EmplaceBack(item, ::std::is_same<T, bool>());
689 NotifyInserted(static_cast<unsigned int>(n));
693 virtual void RemoveAt(
unsigned int index) {
695 Details::IncrementCounter(m_ctr);
697 Details::ValidateBounds(index < m_vec->size());
699 m_vec->erase(m_vec->begin() + index);
701 NotifyRemoved(index);
705 virtual void RemoveAtEnd() {
707 Details::IncrementCounter(m_ctr);
709 Details::ValidateBounds(!m_vec->empty());
713 NotifyRemoved(static_cast<unsigned int>(m_vec->size()));
717 virtual void Clear() {
719 Details::IncrementCounter(m_ctr);
727 virtual void ReplaceAll(
const Array<T>^ arr) {
729 Details::IncrementCounter(m_ctr);
731 Details::ValidateSize(arr->Length);
733 m_vec->assign(arr->begin(), arr->end());
739 virtual event WFC_Handler^ VectorChanged {
740 virtual Details::Token add(WFC_Handler^ e) = WFC_Base::VectorChanged::add {
742 return m_wfc_event += e;
751 template <
typename A,
typename B>
void Emplace(A&& a, B&& b, ::
std::false_type) {
752 m_vec->emplace(::std::forward<A>(a), ::std::forward<B>(b));
755 template <
typename A,
typename B>
void Emplace(A&& a, B&& b, ::
std::true_type) {
756 m_vec->insert(::std::forward<A>(a), ::std::forward<B>(b));
760 m_vec->emplace_back(::std::forward<A>(a));
764 m_vec->push_back(::std::forward<A>(a));
767 void Notify(Details::WFC::CollectionChange change,
unsigned int index) {
769 auto args =
ref new Details::VectorChangedEventArgs(change, index);
770 m_wfc_event(
this, args);
773 m_wuxi_event(
this, args);
774 #endif // _COLLECTION_WUXI
780 Notify(Details::WFC::CollectionChange::Reset, 0);
783 void NotifyInserted(
unsigned int index) {
784 Notify(Details::WFC::CollectionChange::ItemInserted, index);
787 void NotifyRemoved(
unsigned int index) {
788 Notify(Details::WFC::CollectionChange::ItemRemoved, index);
791 void NotifyChanged(
unsigned int index) {
792 Notify(Details::WFC::CollectionChange::ItemChanged, index);
796 virtual Details::WUXI::IBindableIterator^ BindableFirst() = WUXI_Base::First {
797 return safe_cast<Details::WUXI::IBindableIterator^>(First());
800 virtual Object^ BindableGetAt(
unsigned int index) = WUXI_Base::GetAt {
804 virtual bool BindableIndexOf(Object^ value,
unsigned int * index) = WUXI_Base::IndexOf {
807 return Details::VectorBindableIndexOf<T, E>(*m_vec, value, index);
810 virtual Details::WUXI::IBindableVectorView^ BindableGetView() = WUXI_Base::GetView {
811 return safe_cast<Details::WUXI::IBindableVectorView^>(GetView());
814 virtual void BindableSetAt(
unsigned int index, Object^ item) = WUXI_Base::SetAt {
815 SetAt(index, safe_cast<T>(item));
818 virtual void BindableInsertAt(
unsigned int index, Object^ item) = WUXI_Base::InsertAt {
819 InsertAt(index, safe_cast<T>(item));
822 virtual void BindableAppend(Object^ item) = WUXI_Base::Append {
823 Append(safe_cast<T>(item));
826 virtual Details::Token BindableEventAdd(WUXI_Handler^ e) = WUXI_Base::VectorChanged::add {
828 return m_wuxi_event += e;
834 #endif // _COLLECTION_WUXI
836 ::std::shared_ptr<unsigned int> m_ctr;
837 ::std::shared_ptr<WrappedVector> m_vec;
840 event WFC_Handler^ m_wfc_event;
843 event WUXI_Handler^ m_wuxi_event;
844 #endif // _COLLECTION_WUXI
850 template <
typename K,
typename V>
ref class KeyValuePair
sealed :
public _COLLECTION_ATTRIBUTES WFC::IKeyValuePair<K, V> {
852 KeyValuePair(
const typename Wrap<K>::type& key,
const typename Wrap<V>::type& value)
853 : m_key(key), m_value(value) { }
856 virtual property K Key {
858 return Unwrap(m_key);
862 virtual property V
Value {
864 return Unwrap(m_value);
869 typename Wrap<K>::type m_key;
870 typename Wrap<V>::type m_value;
873 template <typename K, typename F, bool = ::std::is_same<typename Wrap<K>::type, K>::value>
class WrapFunc {
878 template <
typename K,
typename F>
class WrapFunc<K, F, false> {
880 typedef WrapFunc type;
882 WrapFunc(
const F& func)
885 size_t operator()(
const Agile<K>& k)
const {
886 return m_func(k.Get());
889 bool operator()(
const Agile<K>& l,
const Agile<K>& r)
const {
890 return m_func(l.Get(), r.Get());
897 template <
typename K,
typename V,
typename C>
struct WrapMap {
898 typedef ::std::map<typename Wrap<K>::type,
typename Wrap<V>::type,
typename WrapFunc<K, C>::type> type;
901 template <
typename K,
typename V,
typename H,
typename P>
struct WrapUnorderedMap {
902 typedef ::std::unordered_map<typename Wrap<K>::type,
typename Wrap<V>::type,
typename WrapFunc<K, H>::type,
typename WrapFunc<K, P>::type> type;
905 template <
typename K,
typename V,
typename WrappedMap>
ref class IteratorForAnyMapView
sealed :
public _COLLECTION_ATTRIBUTES WFC::IIterator<WFC::IKeyValuePair<K, V>^> {
908 IteratorForAnyMapView(const ::std::shared_ptr<unsigned int>& ctr, const ::std::shared_ptr<WrappedMap>&
m)
909 : m_ctr(ctr), m_map(m), m_good_ctr(*ctr), m_iter(m->begin()) { }
912 virtual property WFC::IKeyValuePair<K, V>^ Current {
913 virtual WFC::IKeyValuePair<K, V>^
get() {
914 ValidateCounter(m_ctr, m_good_ctr);
916 ValidateBounds(m_iter != m_map->end());
918 return ref new KeyValuePair<K, V>(m_iter->first, m_iter->second);
922 virtual property bool HasCurrent {
924 ValidateCounter(m_ctr, m_good_ctr);
926 return m_iter != m_map->end();
930 virtual bool MoveNext() {
931 ValidateCounter(m_ctr, m_good_ctr);
933 ValidateBounds(m_iter != m_map->end());
936 return m_iter != m_map->end();
939 virtual unsigned int GetMany(WriteOnlyArray<WFC::IKeyValuePair<K, V>^>^ dest) {
940 ValidateCounter(m_ctr, m_good_ctr);
942 unsigned int capacity = dest->Length;
944 unsigned int actual = 0;
946 while (capacity > 0 && m_iter != m_map->end()) {
947 dest->set(actual,
ref new KeyValuePair<K, V>(m_iter->first, m_iter->second));
957 ::std::shared_ptr<unsigned int> m_ctr;
958 ::std::shared_ptr<WrappedMap> m_map;
959 unsigned int m_good_ctr;
960 typename WrappedMap::const_iterator m_iter;
964 template <
typename K,
typename V,
typename C = ::std::less<K>,
bool = __is_val
id_winrt_type(K),
bool = __is_val
id_winrt_type(V)>
ref class Map;
965 template <
typename K,
typename V,
typename C = ::std::less<K>,
bool = __is_val
id_winrt_type(K),
bool = __is_val
id_winrt_type(V)>
ref class MapView;
966 template <
typename K,
typename V,
typename H = ::std::hash<K>,
typename P = ::std::equal_to<K>,
bool = __is_val
id_winrt_type(K),
bool = __is_val
id_winrt_type(V)>
ref class UnorderedMap;
967 template <
typename K,
typename V,
typename H = ::std::hash<K>,
typename P = ::std::equal_to<K>,
bool = __is_val
id_winrt_type(K),
bool = __is_val
id_winrt_type(V)>
ref class UnorderedMapView;
969 template <
typename K,
typename V,
typename C>
ref class MapView<K, V, C, false, false> {
970 static_assert(Details::AlwaysFalse<K>::value,
"Platform::Collections::MapView<K, V, C> requires K and V to be valid Windows Runtime types.");
973 template <
typename K,
typename V,
typename C>
ref class MapView<K, V, C, false, true> {
974 static_assert(Details::AlwaysFalse<K>::value,
"Platform::Collections::MapView<K, V, C> requires K to be a valid Windows Runtime type.");
977 template <
typename K,
typename V,
typename C>
ref class MapView<K, V, C, true, false> {
978 static_assert(Details::AlwaysFalse<K>::value,
"Platform::Collections::MapView<K, V, C> requires V to be a valid Windows Runtime type.");
981 template <
typename K,
typename V,
typename C,
bool,
bool>
ref class MapView
sealed :
public _COLLECTION_ATTRIBUTES Details::WFC::IMapView<K, V> {
983 typedef typename Details::WrapMap<K, V, C>::type WrappedMap;
984 typedef Details::IteratorForAnyMapView<K, V, WrappedMap> MyIterator;
985 friend ref class Map<K, V, C>;
988 explicit MapView(
const C& comp = C()) {
989 Details::Init(m_ctr, m_map, comp);
994 explicit MapView(const ::std::map<K, V, C>&
m) {
995 Details::Init(m_ctr, m_map, m.key_comp());
997 Details::EmplaceWrappedRange<K, V>(*m_map, m.begin(), m.end());
1002 explicit MapView(::std::map<K, V, C>&& m) {
1003 Details::InitMoveMap<K, V>(m_ctr, m_map,
::std::move(m));
1008 template <
typename InIt> MapView(InIt first, InIt last,
const C& comp = C()) {
1009 Details::Init(m_ctr, m_map, comp);
1011 Details::EmplaceWrappedRange<K, V>(*m_map, first, last);
1016 MapView(::std::initializer_list< ::std::pair<const K, V>> il,
const C& comp = C()) {
1017 Details::Init(m_ctr, m_map, comp);
1019 Details::EmplaceWrappedRange<K, V>(*m_map, il.begin(), il.end());
1025 virtual Details::WFC::IIterator<Details::WFC::IKeyValuePair<K, V>^>^ First() {
1026 Details::ValidateCounter(m_ctr, m_good_ctr);
1028 return ref new MyIterator(m_ctr, m_map);
1031 virtual V Lookup(K key) {
1032 Details::ValidateCounter(m_ctr, m_good_ctr);
1034 auto i = m_map->find(Details::MakeWrap(key));
1036 Details::ValidateBounds(
i != m_map->end());
1038 return Details::Unwrap(
i->second);
1041 virtual property unsigned int Size {
1042 virtual unsigned int get() {
1043 Details::ValidateCounter(m_ctr, m_good_ctr);
1045 return static_cast<unsigned int>(m_map->size());
1049 virtual bool HasKey(K key) {
1050 Details::ValidateCounter(m_ctr, m_good_ctr);
1052 return m_map->find(Details::MakeWrap(key)) != m_map->end();
1055 virtual void Split(Details::WFC::IMapView<K, V>^ * firstPartition, Details::WFC::IMapView<K, V>^ * secondPartition) {
1056 *firstPartition =
nullptr;
1057 *secondPartition =
nullptr;
1059 Details::ValidateCounter(m_ctr, m_good_ctr);
1063 MapView(const ::std::shared_ptr<unsigned int>& ctr, const ::std::shared_ptr<WrappedMap>& m)
1064 : m_ctr(ctr), m_map(m), m_good_ctr(*ctr) { }
1066 ::std::shared_ptr<unsigned int> m_ctr;
1067 ::std::shared_ptr<WrappedMap> m_map;
1068 unsigned int m_good_ctr;
1071 template <
typename K,
typename V,
typename H,
typename P>
ref class UnorderedMapView<K, V, H, P, false, false> {
1072 static_assert(Details::AlwaysFalse<K>::value,
"Platform::Collections::UnorderedMapView<K, V, H, P> requires K and V to be valid Windows Runtime types.");
1075 template <
typename K,
typename V,
typename H,
typename P>
ref class UnorderedMapView<K, V, H, P, false, true> {
1076 static_assert(Details::AlwaysFalse<K>::value,
"Platform::Collections::UnorderedMapView<K, V, H, P> requires K to be a valid Windows Runtime type.");
1079 template <
typename K,
typename V,
typename H,
typename P>
ref class UnorderedMapView<K, V, H, P, true, false> {
1080 static_assert(Details::AlwaysFalse<K>::value,
"Platform::Collections::UnorderedMapView<K, V, H, P> requires V to be a valid Windows Runtime type.");
1083 template <
typename K,
typename V,
typename H,
typename P,
bool,
bool>
ref class UnorderedMapView
sealed
1086 typedef typename Details::WrapUnorderedMap<K, V, H, P>::type WrappedMap;
1087 typedef Details::IteratorForAnyMapView<K, V, WrappedMap> MyIterator;
1088 friend ref class UnorderedMap<K, V, H, P>;
1091 UnorderedMapView() {
1092 Details::Init(m_ctr, m_map);
1097 explicit UnorderedMapView(
size_t n) {
1098 Details::Init(m_ctr, m_map, n, H(), P());
1103 UnorderedMapView(
size_t n,
const H& h) {
1104 Details::Init(m_ctr, m_map, n, h, P());
1109 UnorderedMapView(
size_t n,
const H& h,
const P& p) {
1110 Details::Init(m_ctr, m_map, n, h, p);
1115 explicit UnorderedMapView(const ::std::unordered_map<K, V, H, P>&
m) {
1116 Details::Init(m_ctr, m_map, m.bucket_count(), m.hash_function(), m.key_eq());
1118 Details::EmplaceWrappedRange<K, V>(*m_map, m.begin(), m.end());
1123 explicit UnorderedMapView(::std::unordered_map<K, V, H, P>&& m) {
1124 Details::InitMoveMap<K, V>(m_ctr, m_map,
::std::move(m));
1129 template <
typename InIt> UnorderedMapView(InIt first, InIt last) {
1130 Details::Init(m_ctr, m_map);
1132 Details::EmplaceWrappedRange<K, V>(*m_map, first, last);
1137 template <
typename InIt> UnorderedMapView(InIt first, InIt last,
size_t n) {
1138 Details::Init(m_ctr, m_map, n, H(), P());
1140 Details::EmplaceWrappedRange<K, V>(*m_map, first, last);
1145 template <
typename InIt> UnorderedMapView(InIt first, InIt last,
size_t n,
const H& h) {
1146 Details::Init(m_ctr, m_map, n, h, P());
1148 Details::EmplaceWrappedRange<K, V>(*m_map, first, last);
1153 template <
typename InIt> UnorderedMapView(InIt first, InIt last,
size_t n,
const H& h,
const P& p) {
1154 Details::Init(m_ctr, m_map, n, h, p);
1156 Details::EmplaceWrappedRange<K, V>(*m_map, first, last);
1161 UnorderedMapView(::std::initializer_list< ::std::pair<const K, V>> il) {
1162 Details::Init(m_ctr, m_map);
1164 Details::EmplaceWrappedRange<K, V>(*m_map, il.begin(), il.end());
1169 UnorderedMapView(::std::initializer_list< ::std::pair<const K, V>> il,
size_t n) {
1170 Details::Init(m_ctr, m_map, n, H(), P());
1172 Details::EmplaceWrappedRange<K, V>(*m_map, il.begin(), il.end());
1177 UnorderedMapView(::std::initializer_list< ::std::pair<const K, V>> il,
size_t n,
const H& h) {
1178 Details::Init(m_ctr, m_map, n, h, P());
1180 Details::EmplaceWrappedRange<K, V>(*m_map, il.begin(), il.end());
1185 UnorderedMapView(::std::initializer_list< ::std::pair<const K, V>> il,
size_t n,
const H& h,
const P& p) {
1186 Details::Init(m_ctr, m_map, n, h, p);
1188 Details::EmplaceWrappedRange<K, V>(*m_map, il.begin(), il.end());
1194 virtual Details::WFC::IIterator<Details::WFC::IKeyValuePair<K, V>^>^ First() {
1195 Details::ValidateCounter(m_ctr, m_good_ctr);
1197 return ref new MyIterator(m_ctr, m_map);
1200 virtual V Lookup(K key) {
1201 Details::ValidateCounter(m_ctr, m_good_ctr);
1203 auto i = m_map->find(Details::MakeWrap(key));
1205 Details::ValidateBounds(
i != m_map->end());
1207 return Details::Unwrap(
i->second);
1210 virtual property unsigned int Size {
1211 virtual unsigned int get() {
1212 Details::ValidateCounter(m_ctr, m_good_ctr);
1214 return static_cast<unsigned int>(m_map->size());
1218 virtual bool HasKey(K key) {
1219 Details::ValidateCounter(m_ctr, m_good_ctr);
1221 return m_map->find(Details::MakeWrap(key)) != m_map->end();
1224 virtual void Split(Details::WFC::IMapView<K, V>^ * firstPartition, Details::WFC::IMapView<K, V>^ * secondPartition) {
1225 *firstPartition =
nullptr;
1226 *secondPartition =
nullptr;
1228 Details::ValidateCounter(m_ctr, m_good_ctr);
1232 UnorderedMapView(const ::std::shared_ptr<unsigned int>& ctr, const ::std::shared_ptr<WrappedMap>& m)
1233 : m_ctr(ctr), m_map(m), m_good_ctr(*ctr) { }
1235 ::std::shared_ptr<unsigned int> m_ctr;
1236 ::std::shared_ptr<WrappedMap> m_map;
1237 unsigned int m_good_ctr;
1240 template <
typename K,
typename V,
typename C>
ref class Map<K, V, C, false, false> {
1241 static_assert(Details::AlwaysFalse<K>::value,
"Platform::Collections::Map<K, V, C> requires K and V to be valid Windows Runtime types.");
1244 template <
typename K,
typename V,
typename C>
ref class Map<K, V, C, false, true> {
1245 static_assert(Details::AlwaysFalse<K>::value,
"Platform::Collections::Map<K, V, C> requires K to be a valid Windows Runtime type.");
1248 template <
typename K,
typename V,
typename C>
ref class Map<K, V, C, true, false> {
1249 static_assert(Details::AlwaysFalse<K>::value,
"Platform::Collections::Map<K, V, C> requires V to be a valid Windows Runtime type.");
1252 template <
typename K,
typename V,
typename C,
bool,
bool>
ref class Map
sealed :
public _COLLECTION_ATTRIBUTES Details::WFC::IObservableMap<K, V> {
1254 typedef typename Details::WrapMap<K, V, C>::type WrappedMap;
1255 typedef Details::IteratorForAnyMapView<K, V, WrappedMap> MyIterator;
1256 typedef MapView<K, V, C> MyView;
1257 typedef Details::WFC::MapChangedEventHandler<K, V> WFC_Handler;
1260 explicit Map(
const C& comp = C()) {
1261 Details::Init(m_ctr, m_map, comp);
1266 explicit Map(const ::std::map<K, V, C>&
m) {
1267 Details::Init(m_ctr, m_map, m.key_comp());
1269 Details::EmplaceWrappedRange<K, V>(*m_map, m.begin(), m.end());
1274 explicit Map(::std::map<K, V, C>&& m) {
1275 Details::InitMoveMap<K, V>(m_ctr, m_map,
::std::move(m));
1280 template <
typename InIt> Map(InIt first, InIt last,
const C& comp = C()) {
1281 Details::Init(m_ctr, m_map, comp);
1283 Details::EmplaceWrappedRange<K, V>(*m_map, first, last);
1288 Map(::std::initializer_list< ::std::pair<const K, V>> il,
const C& comp = C()) {
1289 Details::Init(m_ctr, m_map, comp);
1291 Details::EmplaceWrappedRange<K, V>(*m_map, il.begin(), il.end());
1297 virtual Details::WFC::IIterator<Details::WFC::IKeyValuePair<K, V>^>^ First() {
1298 return ref new MyIterator(m_ctr, m_map);
1301 virtual V Lookup(K key) {
1302 auto i = m_map->find(Details::MakeWrap(key));
1304 Details::ValidateBounds(
i != m_map->end());
1306 return Details::Unwrap(
i->second);
1309 virtual property unsigned int Size {
1310 virtual unsigned int get() {
1311 return static_cast<unsigned int>(m_map->size());
1315 virtual bool HasKey(K key) {
1316 return m_map->find(Details::MakeWrap(key)) != m_map->end();
1319 virtual Details::WFC::IMapView<K, V>^ GetView() {
1320 return ref new MyView(m_ctr, m_map);
1323 virtual bool Insert(K key, V value) {
1325 Details::IncrementCounter(m_ctr);
1327 Details::ValidateSize(m_map->size() + 1);
1329 auto p = m_map->emplace(Details::MakeWrap(key), Details::MakeWrap(value));
1332 NotifyInserted(key);
1334 p.first->second = value;
1342 virtual void Remove(K key) {
1344 Details::IncrementCounter(m_ctr);
1346 Details::ValidateBounds(m_map->erase(Details::MakeWrap(key)) == 1);
1352 virtual void Clear() {
1354 Details::IncrementCounter(m_ctr);
1362 virtual event WFC_Handler^ MapChanged {
1363 virtual Details::Token add(WFC_Handler^ e) {
1365 return m_wfc_event += e;
1368 virtual void remove(Details::Token t) {
1374 void NotifyReset() {
1376 m_wfc_event(
this,
ref new Details::MapChangedEventArgsReset<K>);
1380 void NotifyInserted(K key) {
1382 m_wfc_event(
this,
ref new Details::MapChangedEventArgs<K>(Details::WFC::CollectionChange::ItemInserted, key));
1386 void NotifyRemoved(K key) {
1388 m_wfc_event(
this,
ref new Details::MapChangedEventArgs<K>(Details::WFC::CollectionChange::ItemRemoved, key));
1392 void NotifyChanged(K key) {
1394 m_wfc_event(
this,
ref new Details::MapChangedEventArgs<K>(Details::WFC::CollectionChange::ItemChanged, key));
1398 ::std::shared_ptr<unsigned int> m_ctr;
1399 ::std::shared_ptr<WrappedMap> m_map;
1402 event WFC_Handler^ m_wfc_event;
1405 template <
typename K,
typename V,
typename H,
typename P>
ref class UnorderedMap<K, V, H, P, false, false> {
1406 static_assert(Details::AlwaysFalse<K>::value,
"Platform::Collections::UnorderedMap<K, V, H, P> requires K and V to be valid Windows Runtime types.");
1409 template <
typename K,
typename V,
typename H,
typename P>
ref class UnorderedMap<K, V, H, P, false, true> {
1410 static_assert(Details::AlwaysFalse<K>::value,
"Platform::Collections::UnorderedMap<K, V, H, P> requires K to be a valid Windows Runtime type.");
1413 template <
typename K,
typename V,
typename H,
typename P>
ref class UnorderedMap<K, V, H, P, true, false> {
1414 static_assert(Details::AlwaysFalse<K>::value,
"Platform::Collections::UnorderedMap<K, V, H, P> requires V to be a valid Windows Runtime type.");
1417 template <
typename K,
typename V,
typename H,
typename P,
bool,
bool>
ref class UnorderedMap
sealed :
public _COLLECTION_ATTRIBUTES Details::WFC::IObservableMap<K, V> {
1419 typedef typename Details::WrapUnorderedMap<K, V, H, P>::type WrappedMap;
1420 typedef Details::IteratorForAnyMapView<K, V, WrappedMap> MyIterator;
1421 typedef UnorderedMapView<K, V, H, P> MyView;
1422 typedef Details::WFC::MapChangedEventHandler<K, V> WFC_Handler;
1426 Details::Init(m_ctr, m_map);
1431 explicit UnorderedMap(
size_t n) {
1432 Details::Init(m_ctr, m_map, n, H(), P());
1437 UnorderedMap(
size_t n,
const H& h) {
1438 Details::Init(m_ctr, m_map, n, h, P());
1443 UnorderedMap(
size_t n,
const H& h,
const P& p) {
1444 Details::Init(m_ctr, m_map, n, h, p);
1449 explicit UnorderedMap(const ::std::unordered_map<K, V, H, P>& m) {
1450 Details::Init(m_ctr, m_map, m.bucket_count(), m.hash_function(), m.key_eq());
1452 Details::EmplaceWrappedRange<K, V>(*m_map, m.begin(), m.end());
1457 explicit UnorderedMap(::std::unordered_map<K, V, H, P>&& m) {
1458 Details::InitMoveMap<K, V>(m_ctr, m_map,
::std::move(m));
1463 template <
typename InIt> UnorderedMap(InIt first, InIt last) {
1464 Details::Init(m_ctr, m_map);
1466 Details::EmplaceWrappedRange<K, V>(*m_map, first, last);
1471 template <
typename InIt> UnorderedMap(InIt first, InIt last,
size_t n) {
1472 Details::Init(m_ctr, m_map, n, H(), P());
1474 Details::EmplaceWrappedRange<K, V>(*m_map, first, last);
1479 template <
typename InIt> UnorderedMap(InIt first, InIt last,
size_t n,
const H& h) {
1480 Details::Init(m_ctr, m_map, n, h, P());
1482 Details::EmplaceWrappedRange<K, V>(*m_map, first, last);
1487 template <
typename InIt> UnorderedMap(InIt first, InIt last,
size_t n,
const H& h,
const P& p) {
1488 Details::Init(m_ctr, m_map, n, h, p);
1490 Details::EmplaceWrappedRange<K, V>(*m_map, first, last);
1495 UnorderedMap(::std::initializer_list< ::std::pair<const K, V>> il) {
1496 Details::Init(m_ctr, m_map);
1498 Details::EmplaceWrappedRange<K, V>(*m_map, il.begin(), il.end());
1503 UnorderedMap(::std::initializer_list< ::std::pair<const K, V>> il,
size_t n) {
1504 Details::Init(m_ctr, m_map, n, H(), P());
1506 Details::EmplaceWrappedRange<K, V>(*m_map, il.begin(), il.end());
1511 UnorderedMap(::std::initializer_list< ::std::pair<const K, V>> il,
size_t n,
const H& h) {
1512 Details::Init(m_ctr, m_map, n, h, P());
1514 Details::EmplaceWrappedRange<K, V>(*m_map, il.begin(), il.end());
1519 UnorderedMap(::std::initializer_list< ::std::pair<const K, V>> il,
size_t n,
const H& h,
const P& p) {
1520 Details::Init(m_ctr, m_map, n, h, p);
1522 Details::EmplaceWrappedRange<K, V>(*m_map, il.begin(), il.end());
1528 virtual Details::WFC::IIterator<Details::WFC::IKeyValuePair<K, V>^>^ First() {
1529 return ref new MyIterator(m_ctr, m_map);
1532 virtual V Lookup(K key) {
1533 auto i = m_map->find(Details::MakeWrap(key));
1535 Details::ValidateBounds(
i != m_map->end());
1537 return Details::Unwrap(
i->second);
1540 virtual property unsigned int Size {
1541 virtual unsigned int get() {
1542 return static_cast<unsigned int>(m_map->size());
1546 virtual bool HasKey(K key) {
1547 return m_map->find(Details::MakeWrap(key)) != m_map->end();
1550 virtual Details::WFC::IMapView<K, V>^ GetView() {
1551 return ref new MyView(m_ctr, m_map);
1554 virtual bool Insert(K key, V value) {
1556 Details::IncrementCounter(m_ctr);
1558 Details::ValidateSize(m_map->size() + 1);
1560 auto p = m_map->emplace(Details::MakeWrap(key), Details::MakeWrap(value));
1563 NotifyInserted(key);
1565 p.first->second = value;
1573 virtual void Remove(K key) {
1575 Details::IncrementCounter(m_ctr);
1577 Details::ValidateBounds(m_map->erase(Details::MakeWrap(key)) == 1);
1583 virtual void Clear() {
1585 Details::IncrementCounter(m_ctr);
1593 virtual event WFC_Handler^ MapChanged {
1594 virtual Details::Token add(WFC_Handler^ e) {
1596 return m_wfc_event += e;
1599 virtual void remove(Details::Token t) {
1605 void NotifyReset() {
1607 m_wfc_event(
this,
ref new Details::MapChangedEventArgsReset<K>);
1611 void NotifyInserted(K key) {
1613 m_wfc_event(
this,
ref new Details::MapChangedEventArgs<K>(Details::WFC::CollectionChange::ItemInserted, key));
1617 void NotifyRemoved(K key) {
1619 m_wfc_event(
this,
ref new Details::MapChangedEventArgs<K>(Details::WFC::CollectionChange::ItemRemoved, key));
1623 void NotifyChanged(K key) {
1625 m_wfc_event(
this,
ref new Details::MapChangedEventArgs<K>(Details::WFC::CollectionChange::ItemChanged, key));
1629 ::std::shared_ptr<unsigned int> m_ctr;
1630 ::std::shared_ptr<WrappedMap> m_map;
1633 event WFC_Handler^ m_wfc_event;
1637 template <
typename X>
class InputIterator;
1638 template <
typename T>
class VectorIterator;
1639 template <
typename T>
class VectorViewIterator;
1640 template <
typename T>
class BackInsertIterator;
1644 template <
typename X> struct ::std::_Is_checked_helper< ::Platform::Collections::InputIterator<X>>
1647 template <
typename T> struct ::std::_Is_checked_helper< ::Platform::Collections::VectorIterator<T>>
1650 template <
typename T> struct ::std::_Is_checked_helper< ::Platform::Collections::VectorViewIterator<T>>
1653 template <
typename T> struct ::std::_Is_checked_helper< ::Platform::Collections::BackInsertIterator<T>>
1657 namespace Collections {
1658 template <
typename X>
class InputIterator {
1660 typedef ::std::input_iterator_tag iterator_category;
1661 typedef X value_type;
1663 typedef const X * pointer;
1664 typedef const X & reference;
1668 explicit InputIterator(Details::WFC::IIterator<X>^ iter) {
1669 if (iter->HasCurrent) {
1671 m_val = iter->Current;
1675 bool operator==(
const InputIterator& other)
const {
1676 return !!m_iter == !!other.m_iter;
1679 bool operator!=(
const InputIterator& other)
const {
1680 return !(*
this == other);
1687 pointer operator->()
const {
1691 InputIterator& operator++() {
1692 if (m_iter->MoveNext()) {
1693 m_val = m_iter->Current;
1701 InputIterator operator++(
int) {
1702 InputIterator old(*
this);
1708 Details::WFC::IIterator<X>^ m_iter;
1713 template <
typename T>
class VectorProxy {
1715 VectorProxy(WFC::IVector<T>^ v,
ptrdiff_t n)
1716 : m_v(v), m_i(static_cast<unsigned int>(n)) { }
1718 VectorProxy& operator=(
const VectorProxy& other) {
1719 m_v->SetAt(m_i, other.m_v->GetAt(other.m_i));
1723 VectorProxy& operator=(T t) {
1728 operator T()
const {
1729 return m_v->GetAt(m_i);
1732 T operator->()
const {
1733 return m_v->GetAt(m_i);
1736 void swap(
const VectorProxy& other)
const {
1737 T t1(m_v->GetAt(m_i));
1738 T t2(other.m_v->GetAt(other.m_i));
1740 m_v->SetAt(m_i, t2);
1741 other.m_v->SetAt(other.m_i, t1);
1744 void swap(T& t)
const {
1746 t = m_v->GetAt(m_i);
1747 m_v->SetAt(m_i, temp);
1751 WFC::IVector<T>^ m_v;
1755 template <
typename T>
inline void swap(
const VectorProxy<T>& l,
const VectorProxy<T>& r) {
1759 template <
typename T>
inline void swap(
const VectorProxy<T>& p, T& t) {
1763 template <
typename T>
inline void swap(T& t,
const VectorProxy<T>& p) {
1767 template <
typename T>
inline bool operator==(
const VectorProxy<T>& l,
const VectorProxy<T>& r) {
1768 return static_cast<T
>(l) == static_cast<T>(r);
1771 template <
typename T>
inline bool operator==(
const VectorProxy<T>& l,
const T& t) {
1772 return static_cast<T
>(l) == t;
1775 template <
typename T>
inline bool operator==(
const T& t,
const VectorProxy<T>& r) {
1776 return t ==
static_cast<T
>(r);
1779 template <
typename T>
inline bool operator!=(
const VectorProxy<T>& l,
const VectorProxy<T>& r) {
1780 return static_cast<T
>(l) != static_cast<T>(r);
1783 template <
typename T>
inline bool operator!=(
const VectorProxy<T>& l,
const T& t) {
1784 return static_cast<T
>(l) != t;
1787 template <
typename T>
inline bool operator!=(
const T& t,
const VectorProxy<T>& r) {
1788 return t !=
static_cast<T
>(r);
1791 template <
typename T>
inline bool operator<(const VectorProxy<T>& l,
const VectorProxy<T>& r) {
1792 return static_cast<T
>(l) < static_cast<T>(r);
1795 template <
typename T>
inline bool operator<(const VectorProxy<T>& l,
const T& t) {
1796 return static_cast<T
>(l) < t;
1799 template <
typename T>
inline bool operator<(const T& t, const VectorProxy<T>& r) {
1800 return t < static_cast<T>(r);
1803 template <
typename T>
inline bool operator<=(const VectorProxy<T>& l,
const VectorProxy<T>& r) {
1804 return static_cast<T
>(l) <= static_cast<T>(r);
1807 template <
typename T>
inline bool operator<=(const VectorProxy<T>& l,
const T& t) {
1808 return static_cast<T
>(l) <= t;
1811 template <
typename T>
inline bool operator<=(const T& t, const VectorProxy<T>& r) {
1812 return t <= static_cast<T>(r);
1815 template <
typename T>
inline bool operator>(
const VectorProxy<T>& l,
const VectorProxy<T>& r) {
1816 return static_cast<T
>(l) > static_cast<T>(r);
1819 template <
typename T>
inline bool operator>(
const VectorProxy<T>& l,
const T& t) {
1820 return static_cast<T
>(l) > t;
1823 template <
typename T>
inline bool operator>(
const T& t,
const VectorProxy<T>& r) {
1824 return t >
static_cast<T
>(r);
1827 template <
typename T>
inline bool operator>=(
const VectorProxy<T>& l,
const VectorProxy<T>& r) {
1828 return static_cast<T
>(l) >= static_cast<T>(r);
1831 template <
typename T>
inline bool operator>=(
const VectorProxy<T>& l,
const T& t) {
1832 return static_cast<T
>(l) >= t;
1835 template <
typename T>
inline bool operator>=(
const T& t,
const VectorProxy<T>& r) {
1836 return t >=
static_cast<T
>(r);
1839 template <
typename T>
class ArrowProxy {
1841 explicit ArrowProxy(T t)
1844 const T * operator->()
const {
1853 template <
typename T>
class VectorIterator {
1855 typedef ::std::random_access_iterator_tag iterator_category;
1856 typedef T value_type;
1858 typedef Details::VectorProxy<T> * pointer;
1859 typedef Details::VectorProxy<T> reference;
1862 : m_v(
nullptr), m_i(0) { }
1864 explicit VectorIterator(Details::WFC::IVector<T>^ v)
1865 : m_v(v), m_i(0) { }
1868 return reference(m_v, m_i);
1871 Details::ArrowProxy<T> operator->()
const {
1872 return Details::ArrowProxy<T>(m_v->GetAt(static_cast<unsigned int>(m_i)));
1875 reference operator[](difference_type n)
const {
1876 return reference(m_v, m_i + n);
1879 VectorIterator& operator++() {
1884 VectorIterator& operator--() {
1889 VectorIterator operator++(
int) {
1890 VectorIterator old(*
this);
1895 VectorIterator operator--(
int) {
1896 VectorIterator old(*
this);
1901 VectorIterator&
operator+=(difference_type n) {
1906 VectorIterator&
operator-=(difference_type n) {
1911 VectorIterator
operator+(difference_type n)
const {
1912 VectorIterator ret(*
this);
1917 VectorIterator
operator-(difference_type n)
const {
1918 VectorIterator ret(*
this);
1923 difference_type
operator-(
const VectorIterator& other)
const {
1924 return m_i - other.m_i;
1927 bool operator==(
const VectorIterator& other)
const {
1928 return m_i == other.m_i;
1931 bool operator!=(
const VectorIterator& other)
const {
1932 return m_i != other.m_i;
1935 bool operator<(
const VectorIterator& other)
const {
1936 return m_i < other.m_i;
1939 bool operator>(
const VectorIterator& other)
const {
1940 return m_i > other.m_i;
1943 bool operator<=(
const VectorIterator& other)
const {
1944 return m_i <= other.m_i;
1947 bool operator>=(
const VectorIterator& other)
const {
1948 return m_i >= other.m_i;
1952 Details::WFC::IVector<T>^ m_v;
1953 difference_type m_i;
1956 template <
typename T>
inline VectorIterator<T>
operator+(
ptrdiff_t n,
const VectorIterator<T>&
i) {
1960 template <
typename T>
class VectorViewIterator {
1962 typedef ::std::random_access_iterator_tag iterator_category;
1963 typedef T value_type;
1965 typedef T * pointer;
1966 typedef T reference;
1968 VectorViewIterator()
1969 : m_v(
nullptr), m_i(0) { }
1971 explicit VectorViewIterator(Details::WFC::IVectorView<T>^ v)
1972 : m_v(v), m_i(0) { }
1975 return m_v->GetAt(static_cast<unsigned int>(m_i));
1978 Details::ArrowProxy<T> operator->()
const {
1979 return Details::ArrowProxy<T>(m_v->GetAt(static_cast<unsigned int>(m_i)));
1982 reference operator[](difference_type n)
const {
1983 return m_v->GetAt(static_cast<unsigned int>(m_i + n));
1986 VectorViewIterator& operator++() {
1991 VectorViewIterator& operator--() {
1996 VectorViewIterator operator++(
int) {
1997 VectorViewIterator old(*
this);
2002 VectorViewIterator operator--(
int) {
2003 VectorViewIterator old(*
this);
2008 VectorViewIterator&
operator+=(difference_type n) {
2013 VectorViewIterator&
operator-=(difference_type n) {
2018 VectorViewIterator
operator+(difference_type n)
const {
2019 VectorViewIterator ret(*
this);
2024 VectorViewIterator
operator-(difference_type n)
const {
2025 VectorViewIterator ret(*
this);
2030 difference_type
operator-(
const VectorViewIterator& other)
const {
2031 return m_i - other.m_i;
2034 bool operator==(
const VectorViewIterator& other)
const {
2035 return m_i == other.m_i;
2038 bool operator!=(
const VectorViewIterator& other)
const {
2039 return m_i != other.m_i;
2042 bool operator<(
const VectorViewIterator& other)
const {
2043 return m_i < other.m_i;
2046 bool operator>(
const VectorViewIterator& other)
const {
2047 return m_i > other.m_i;
2050 bool operator<=(
const VectorViewIterator& other)
const {
2051 return m_i <= other.m_i;
2054 bool operator>=(
const VectorViewIterator& other)
const {
2055 return m_i >= other.m_i;
2059 Details::WFC::IVectorView<T>^ m_v;
2060 difference_type m_i;
2063 template <
typename T>
inline VectorViewIterator<T>
operator+(
ptrdiff_t n,
const VectorViewIterator<T>& i) {
2067 template <
typename T>
class BackInsertIterator
2068 :
public ::std::iterator< ::std::output_iterator_tag, void, void, void, void> {
2070 explicit BackInsertIterator(Details::WFC::IVector<T>^ v) : m_v(v) { }
2072 BackInsertIterator& operator=(
const T& t) {
2081 BackInsertIterator& operator++() {
2085 BackInsertIterator operator++(
int) {
2090 Details::WFC::IVector<T>^ m_v;
2094 template <
typename T,
typename I> inline ::std::vector<T> ToVector(
I^ v) {
2095 unsigned int size = v->Size;
2097 ::std::vector<T> ret(size);
2099 for (
unsigned int actual = 0; actual < size; ) {
2100 Array<T>^ arr =
ref new Array<T>(size - actual);
2102 unsigned int n = v->GetMany(actual, arr);
2105 throw ref new FailureException;
2120 namespace Foundation {
2121 namespace Collections {
2122 template <
typename X> inline ::Platform::Collections::InputIterator<X>
begin(IIterable<X>^
i) {
2123 return ::Platform::Collections::InputIterator<X>(i->First());
2126 template <
typename X> inline ::Platform::Collections::InputIterator<X>
end(IIterable<X>^) {
2127 return ::Platform::Collections::InputIterator<X>();
2130 template <
typename T> inline ::Platform::Collections::VectorIterator<T>
begin(IVector<T>^ v) {
2131 return ::Platform::Collections::VectorIterator<T>(v);
2134 template <
typename T> inline ::Platform::Collections::VectorIterator<T>
end(IVector<T>^ v) {
2135 return ::Platform::Collections::VectorIterator<T>(v) + v->Size;
2138 template <
typename T> inline ::Platform::Collections::VectorViewIterator<T>
begin(IVectorView<T>^ v) {
2139 return ::Platform::Collections::VectorViewIterator<T>(v);
2142 template <
typename T> inline ::Platform::Collections::VectorViewIterator<T>
end(IVectorView<T>^ v) {
2143 return ::Platform::Collections::VectorViewIterator<T>(v) + v->Size;
2146 template <
typename T> inline ::std::vector<T> to_vector(IVector<T>^ v) {
2147 return ::Platform::Collections::Details::ToVector<T>(v);
2150 template <
typename T> inline ::std::vector<T> to_vector(IVectorView<T>^ v) {
2151 return ::Platform::Collections::Details::ToVector<T>(v);
2154 template <
typename T> inline ::Platform::Collections::BackInsertIterator<T>
back_inserter(IVector<T>^ v) {
2155 return ::Platform::Collections::BackInsertIterator<T>(v);
2158 template <
typename T> inline ::Platform::Collections::BackInsertIterator<T>
back_inserter(IObservableVector<T>^ v) {
2159 return ::Platform::Collections::BackInsertIterator<T>(v);
2166 namespace Collections {
2167 template <
typename T,
typename E>
inline BackInsertIterator<T>
back_inserter(Vector<T, E>^ v) {
2168 return BackInsertIterator<T>(v);
2173 template <> struct ::std::hash< ::Platform::String^>
2174 : public ::std::unary_function< ::Platform::String^, size_t> {
2176 size_t operator()(::Platform::String^ s)
const {
2181 #undef _COLLECTION_ATTRIBUTES
2182 #undef _COLLECTION_TRANSLATE
2183 #undef _COLLECTION_WUXI
2185 #pragma warning(pop)
2188 #endif // RC_INVOKED
2190 #endif // _COLLECTION_H_
_OutIt copy_n(_InIt _First, _Diff _Count, _OutIt _Dest)
Definition: xutility:2208
_Tuple_type< _Rank > operator*(const _Tuple_type< _Rank > &_Lhs, typename _Tuple_type< _Rank >::value_type _Rhs) __GPU
Definition: amp.h:870
_Ty & get(array< _Ty, _Size > &_Arr) _NOEXCEPT
Definition: array:506
_FwdIt remove(_FwdIt _First, _FwdIt _Last, const _Ty &_Val)
Definition: algorithm:1741
back_insert_iterator< _Container > back_inserter(_Container &_Cont)
Definition: iterator:69
__m128d m
Definition: dvec.h:71
_OutIt move(_InIt _First, _InIt _Last, _OutIt _Dest)
Definition: xutility:2447
T & operator+=(T &lhs, SafeInt< U, E > rhs)
Definition: safeint.h:1439
reference_wrapper< _Ty > ref(_Ty &_Val) _NOEXCEPT
Definition: xrefwrap:691
integral_constant< bool, false > false_type
Definition: xtr1common:48
_STD_BEGIN size_t _Hash_seq(const unsigned char *_First, size_t _Count)
Definition: xstddef:279
int i[4]
Definition: dvec.h:70
Definition: vccorlib.h:112
unsigned short wchar_t
Definition: crtdefs.h:536
_W64 int ptrdiff_t
Definition: crtdefs.h:530
_InIt find_if(_InIt _First, _InIt _Last, _Pr _Pred)
Definition: algorithm:51
_Tuple_type< _Rank > operator+(const _Tuple_type< _Rank > &_Lhs, const _Tuple_type< _Rank > &_Rhs) __GPU
Definition: amp.h:822
void swap(array< _Ty, _Size > &_Left, array< _Ty, _Size > &_Right) _NOEXCEPT_OP(_NOEXCEPT_OP(_Left.swap(_Right)))
Definition: array:429
bool operator<=(const unorm &_Lhs, const unorm &_Rhs) __GPU
Definition: amp_short_vectors.h:480
_Tuple_type< _Rank > operator-(const _Tuple_type< _Rank > &_Lhs, const _Tuple_type< _Rank > &_Rhs) __GPU
Definition: amp.h:830
integral_constant< bool, true > true_type
Definition: xtr1common:47
#define _COLLECTION_TRANSLATE
Definition: collection.h:35
bool operator>=(const unorm &_Lhs, const unorm &_Rhs) __GPU
Definition: amp_short_vectors.h:470
#define _COLLECTION_ATTRIBUTES
Definition: collection.h:33
#define I
Definition: complex.h:70
bool operator>(const unorm &_Lhs, const unorm &_Rhs) __GPU
Definition: amp_short_vectors.h:450
T & operator-=(T &lhs, SafeInt< U, E > rhs)
Definition: safeint.h:1448