BaseDictionary

BaseDictionary class

Implements common code for various dictionary-alike data structures (e. g. Dictionary, SortedDictionary). Shouldn’t be used directly, except for inheritance when defining containers. Objects of this class should only be allocated using System::MakeObject() function. Never create instance of this type on stack or using operator new, as it will result in runtime errors and/or assertion faults. Always wrap this class into System::SmartPtr pointer and use this pointer to pass it to functions as argument.

template<typename Map>class BaseDictionary : public System::Collections::Generic::IDictionary<Map::key_type, Map::mapped_type>

Template parameters

ParameterDescription
MapUnderlying map type.

Methods

MethodDescription
void _add_range(std::initializer_list<typename Map::value_type>)C++ specific.
void Add(const key_t&, const mapped_t&) overrideAdds key-value pair into dictionary.
BaseDictionary()Creates empty data structure.
BaseDictionary(int, const Args&…)Forwarding constructor to push arguments into underlying map constructor.
BaseDictionary(BaseType *, const Args&…)Copying constructor.
BaseDictionary(BaseType *)Copying constructor.
const_iterator begin() constReturns an iterator to the KVPair-wrapper for key-value-element of the container. Implemented in C# style - iterator should be return the KVPair-object with get_Key() and get_Value() interface. If the container is empty, the returned iterator will be equal to end().
iterator begin()Gets iterator pointing to the first element (if any) of the collection. This iterator can’t be used to change a referenced object because GetEnumerator() returns a copy-object of T.
stl_const_iterator cbegin() constReturns an iterator to the first element of the container. Implemented in STL-style. If the container is empty, the returned iterator will be equal to end().
stl_const_iterator cend() constReturns an iterator to the element following the last element of the container. Implemented in STL-style. This element acts as a placeholder; attempting to access it results in undefined behavior.
void Clear() overrideDeletes all elements.
bool ContainsKey(const key_t&) const overrideChecks if key is present in dictionary.
bool ContainsValue(const mapped_t&)Checks if value is present in dictionary. Uses operator == to compare values.
void CopyTo(ArrayPtr<KeyValuePair<TKey, TValue>>, int) overrideCopies dictionary contents into existing array elements.
Map& data()Underlying data storage accessor.
const Map& data() constUnderlying data storage accessor.
const_iterator end() constReturns an iterator to the KVPair-wrapper for key-value-element following the last element of the container. Implemented in C# style - iterator should be return the KVPair-object with get_Key() and get_Value() interface. This element acts as a placeholder; attempting to access it results in undefined behavior.
iterator end()Gets iterator pointing right after the last element (if any) of the collection. This iterator can’t be used to change a referenced object because GetEnumerator() returns a copy-object of T.
virtual bool Equals(ptr)Compares objects using C# Object.Equals semantics.
static std::enable_if<IsSmartPtr<T1>::value&&IsSmartPtr<T2>::value, bool>::type Equals(T1 const&, T2 const&)Compares reference type objects in C# style.
static std::enable_if<!IsSmartPtr<T1>::value&&!IsSmartPtr<T2>::value, bool>::type Equals(T1 const&, T2 const&)Compares value type objects in C# style.
static bool Equals(float const&, float const&)Emulates C#-style floating point comparison where two NaNs are considered equal even though according to IEC 60559:1989 NaN is not equal to any value, including NaN.
static bool Equals(double const&, double const&)Emulates C#-style floating point comparison where two NaNs are considered equal even though according to IEC 60559:1989 NaN is not equal to any value, including NaN.
virtual bool FastCast(const Details::FastRttiBase&, void **) constFor internal purposes only.
int32_t get_Count() const overrideGets elements count.
bool get_IsFixedSize() constChecks if collection size is fixed.
virtual bool get_IsReadOnly() constChecks if collection is read only.
bool get_IsSynchronized() constChecks if container is thread-safe.
virtual SharedPtr<ICollection<TKey>> get_Keys() constAccesses key collection.
SharedPtr<Object> get_SyncRoot() constGets the object the collection is being synchronized through.
virtual SharedPtr<ICollection<TValue>> get_Values() constAccesses value collection.
Detail::SmartPtrCounter * GetCounter()Gets reference counter data structure associated with the object.
virtual SharedPtr<IEnumerator<KeyValuePair<key_t, mapped_t>>> GetEnumerator()Creates enumerator instance, should be implemented by subclass.
virtual int32_t GetHashCode() constAnalog of C# Object.GetHashCode() method. Enables hashing of custom objects.
virtual const TypeInfo& GetType() constGets actual type of object. Analog of C# System.Object.GetType() call.
mapped_t GetValueOrDefault(const key_t&) const overrideReturns value if found; or Value() otherwise.
mapped_t GetValueOrDefault(const key_t&, const mapped_t&) const overrideReturns value if found; or defaultValue otherwise.
mapped_t GetValueOrNull(const key_t&) const overrideReturns value if found; or null otherwise. Make sense only for reference types.
ICollection()Default constructor.
ICollection(const ICollection&)Copy constructor.
ICollection(ICollection&&)Move constructor.
mapped_t idx_get(const key_t&) const overrideKeyed getter function.
void idx_set(const key_t&, mapped_t) overrideKeyed setter function. Alters or creates element.
virtual bool Is(const TypeInfo&) constCheck if object represents an instance of type described by targetType. Analog of C# ‘is’ operator.
bool LINQ_All(std::function<bool(T)>)Determines whether all elements of a sequence satisfy a condition.
bool LINQ_Any()Determines whether a sequence contains any elements.
bool LINQ_Any(std::function<bool(T)>)Determines whether any element of a sequence exists or satisfies a condition.
SharedPtr<IEnumerable<ResultType>> LINQ_Cast()Casts the elements to the specified type.
SharedPtr<IEnumerable<Result>> LINQ_Cast()
SharedPtr<IEnumerable<T>> LINQ_Concat(SharedPtr<IEnumerable<T>>)Concatenates two sequences.
bool LINQ_Contains(T)Determines if a sequence contains a specified value.
int LINQ_Count()Returns the number of elements in the sequence (calculated via direct counting).
int LINQ_Count(const Func<T, bool>&)Returns the number of elements in the sequence that satisfy the specified condition.
T LINQ_ElementAt(int)Returns the element at a specified index in a sequence.
T LINQ_First()Returns the first element of a sequence.
T LINQ_First(const Func<T, bool>&)Returns the first element of a sequence that satisfy the specified condition.
T LINQ_FirstOrDefault()Returns the first element of a sequence, or a default value if the sequence is empty.
T LINQ_FirstOrDefault(std::function<bool(T)>)Returns the first element of the sequence that satisfies a condition or a default value if no such element is found.
System::SharedPtr<IEnumerable<System::SharedPtr<System::Linq::IGrouping<Key, T>>>> LINQ_GroupBy(System::Func<T, Key>)Groups the elements of a sequence.
SharedPtr<IEnumerable<SharedPtr<System::Linq::IGrouping<Key, Source>>>> LINQ_GroupBy(System::Func<Source, Key>)
T LINQ_Last()Returns the last element of a sequence.
T LINQ_LastOrDefault()Returns the last element of a sequence, or a default value if the sequence is empty.
SharedPtr<IEnumerable<ResultType>> LINQ_OfType()Filters the elements of the sequence based on the specified type.
SharedPtr<IEnumerable<Result>> LINQ_OfType()
SharedPtr<IEnumerable<T>> LINQ_OrderBy(const Func<T, Key>&)Sorts the elements of a sequence in ascending order according to the key values selected by keySelector.
SharedPtr<IEnumerable<Source>> LINQ_OrderBy(const Func<Source, Key>&)
SharedPtr<IEnumerable<T>> LINQ_OrderByDescending(const Func<T, Key>&)Sorts the elements of a sequence in descending order according to the key values selected by keySelector.
SharedPtr<IEnumerable<Source>> LINQ_OrderByDescending(const Func<Source, Key>&)
SharedPtr<IEnumerable<ResultType>> LINQ_Select(const Func<T, ResultType>&)Transforms elements of a sequence.
SharedPtr<IEnumerable<ResultType>> LINQ_Select(const Func<T, int32_t, ResultType>&)Transforms each element of a sequence into a new form by incorporating the element’s index.
SharedPtr<IEnumerable<Result>> LINQ_Select(const Func<Source, Result>&)
SharedPtr<IEnumerable<Result>> LINQ_Select(const Func<Source, int32_t, Result>&)
SharedPtr<IEnumerable<ResultType>> LINQ_SelectMany(const Func<T, SharedPtr<IEnumerable<ResultType>>>&)Projects each element of a sequence and combines the resulting sequences into one sequence.
SharedPtr<IEnumerable<Result>> LINQ_SelectMany(const Func<Source, SharedPtr<IEnumerable<Result>>>&)
System::ArrayPtr<T> LINQ_ToArray()Creates an array from a sequence.
SharedPtr<List<T>> LINQ_ToList()Creates a List from a sequence.
SharedPtr<IEnumerable<T>> LINQ_Where(std::function<bool(T)>)Filters a sequence based on the specified predicate.
void Lock()Implements C# lock() statement locking. Call directly or use LockContext sentry object.
virtual ptr MemberwiseClone() constAnalog of C# Object.MemberwiseClone() method. Enables cloning custom types.
Object()Creates object. Initializes all internal data structures.
Object(Object const&)Copy constructor. Doesn’t copy anything, really, just initializes new object and enables copy constructing subclasses.
ICollection& operator=(ICollection&&)Move assignment operator.
ICollection& operator=(const ICollection&)Move assignment operator.
Object& operator=(Object const&)Assignment operator. Doesn’t copy anything, really, just initializes new object and enables copy constructing subclasses.
virtual mapped_t& operator[](const key_t&)Accessor function.
static bool ReferenceEquals(ptr const&, ptr const&)Compares objects by reference.
static std::enable_if<!IsSmartPtr<T>::value, bool>::type ReferenceEquals(T const&, T const&)Compares objects by reference.
static std::enable_if<!IsSmartPtr<T>::value, bool>::type ReferenceEquals(T const&, std::nullptr_t)Reference-compares value type object with nullptr.
bool ReferenceEquals(String const&, std::nullptr_t)Specialization of Object::ReferenceEquals for case of string and nullptr.
bool ReferenceEquals(String const&, String const&)Specialization of Object::ReferenceEquals for case of strings.
bool Remove(const key_t&) overrideRemoves specific key from dictionary.
int RemovedSharedRefs(int)Decreases shared reference count by specified value.
void SetTemplateWeakPtr(unsigned int) override
virtual void SetTemplateWeakPtr(uint32_t)Set n’th template argument a weak pointer (rather than shared). Allows switching pointers in containers to weak mode.
int SharedCount() constGets current value of shared reference counter.
Object * SharedRefAdded()Increments shared reference count. Shouldn’t be called directly; instead, use smart pointers or ThisProtector.
int SharedRefRemovedSafe()Decrements and returns shared reference count. Shouldn’t be called directly; instead, use smart pointers or ThisProtector.
virtual String ToString() constAnalog of C# Object.ToString() method. Enables converting custom objects to string.
bool TryGetValue(const key_t&, mapped_t&) const overrideLooks for keyed value and retreives it if found.
static const TypeInfo& Type()Implements C# typeof(System.Object) construct.
void Unlock()Implements C# lock() statement unlocking. Call directly or use LockContext sentry object.
System::Details::VirtualizedIteratorBase<KVPair> * virtualizeBeginConstIterator() const overrideGets the implementation of begin const iterator for the current container.
System::Details::VirtualizedIteratorBase<KVPair> * virtualizeBeginIterator() overrideGets the implementation of begin iterator for the current container.
System::Details::VirtualizedIteratorBase<KVPair> * virtualizeEndConstIterator() const overrideGets the implementation of end const iterator for the current container.
System::Details::VirtualizedIteratorBase<KVPair> * virtualizeEndIterator() overrideGets the implementation of end iterator for the current container.
Detail::SmartPtrCounter * WeakRefAdded()Increments weak reference count. Shouldn’t be called directly; instead, use smart pointers or ThisProtector.
void WeakRefRemoved()Decrements weak reference count. Shouldn’t be called directly; instead, use smart pointers or ThisProtector.
virtual ~ICollection()Destructor.
virtual ~Object()Destroys object. Frees all internal data structures.

Typedefs

TypedefDescription
map_tInternal map type.
KeyCollectionMake sure we use correct allocator with underlying storage type.
ValueCollectionCollection of values.
KVPairKey-value pair type.
BaseTypeImplemented interface.
iteratorIterator type.
const_iteratorConst iterator type.

See Also