2#ifndef _aspose_system_collections_sorted_dictionary_h_
3#define _aspose_system_collections_sorted_dictionary_h_
5#include "system/object.h"
6#include "system/collections/base_dictionary.h"
7#include "system/collections/keyvalue_collection.h"
8#include "system/cycles_detection.h"
13namespace Collections {
17template<
typename T,
typename V>
class SortedDictionary;
22template<
typename T,
typename V>
37 V& operator[] (
const T& key)
const
39 return (*(this->GetPointer()))[key];
49template<
typename TKey,
typename TValue>
51 :
public BaseDictionary<std::map<TKey, TValue, ComparerAdapter<typename BasePointerType<TKey>::type>, ASPOSE_MAP_ALLOCATOR_TYPE(TKey, TValue)> >
58 RTTI_INFO_TEMPLATE_CLASS(
_ThisType, System::BaseTypesInfo<_BaseType>);
62 using _BaseType::m_map;
70 typedef std::map<TKey, TValue, ComparerAdapter<typename BasePointerType<TKey>::type>, ASPOSE_MAP_ALLOCATOR_TYPE(TKey, TValue)>
map_t;
96 static std::once_flag once;
97 std::call_once(once, [] { value = MakeObject<DefaultComparer<typename BasePointerType<TKey>::type>>(); });
111 m_comparer = comparer;
128 m_comparer = comparer;
163 return m_map.rbegin();
177 return m_map.rbegin();
209 return MakeObject<_KeyCollection<SortedDictionary<TKey, TValue>>>(
MakeSharedPtr(
this));
215 return MakeObject<_ValueCollection<SortedDictionary<TKey, TValue>>>(
MakeSharedPtr(
this));
217#ifdef ASPOSE_GET_SHARED_MEMBERS
219 DEFINE_GET_SHARED_MEMBERS(_BaseType::m_map)
Implements common code for various dictionary-alike data structures (e. g. Dictionary,...
Definition: base_dictionary.h:100
Interface of collection of elements. Objects of this class should only be allocated using System::Mak...
Definition: icollection.h:20
Interface that compares two objects in greater-equal-less sense. Objects of this class should only be...
Definition: icomparer.h:20
Interface for dictionary-alike containers. Objects of this class should only be allocated using Syste...
Definition: idictionary.h:21
Adapting iterator, wraps std::pair into KVPair expected from Dictionary.
Definition: base_enumerator.h:109
Pair of key and value. This type should be allocated on stack and passed to functions by value or by ...
Definition: keyvalue_pair.h:20
Iterator class for simple containers holding elements directly using rbegin() and rend() functions....
Definition: base_enumerator.h:81
Enumerator type to iterate through dictionary. Objects of this class should only be allocated using S...
Definition: sorted_dictionary.h:142
Enumerator(const Ptr &dict)
Constructs enumerator over specific dictionary.
Definition: sorted_dictionary.h:146
RTTI_INFO_TEMPLATE_CLASS(Enumerator, System::BaseTypesInfo< System::Object >)
RTTI information.
SortedDictionary< TKey, TValue >::Enumerator EnumeratorType
Enumerator type alias.
Definition: sorted_dictionary.h:148
Sorted dictionary type forward declaration.
Definition: sorted_dictionary.h:52
map_t::reverse_iterator reverse_iterator
Reverse iterator type.
Definition: sorted_dictionary.h:87
SharedPtr< ValueCollection > get_ValuesInternal() const override
Implementation of get_ValuesInternal() method.
Definition: sorted_dictionary.h:213
ICollection< TValue > ValueCollection
Value collection type.
Definition: sorted_dictionary.h:68
_BaseType::iterator iterator
Iterator type.
Definition: sorted_dictionary.h:83
_BaseType::const_iterator const_iterator
Const iterator type.
Definition: sorted_dictionary.h:85
const_reverse_iterator crbegin() const noexcept
Gets a reverse iterator to the last const-qualified element of collection (first in reverse).
Definition: sorted_dictionary.h:189
SharedPtr< KeyCollection > get_KeysInternal() const override
Implementation of get_KeysInternal() method.
Definition: sorted_dictionary.h:207
KeyValuePair< TKey, TValue > KVPair
Key-value pair type.
Definition: sorted_dictionary.h:76
SharedPtr< this_t > Ptr
Pointer type.
Definition: sorted_dictionary.h:74
const_reverse_iterator crend() const noexcept
Gets a reverse iterator for a non-existent const-qualified element before the start of the collection...
Definition: sorted_dictionary.h:196
SharedPtr< IEnumerator< KVPair > > IEnumeratorPtr
Enumerator type.
Definition: sorted_dictionary.h:80
SortedDictionary< TKey, TValue > this_t
Self type.
Definition: sorted_dictionary.h:72
SharedPtr< System::Collections::Generic::IComparer< TKey > > get_Comparer() const
Gets the IComparer<TKey> used to order the elements of the SortedDictionary<TKey,TValue>.
Definition: sorted_dictionary.h:132
const_reverse_iterator rbegin() const noexcept
Gets a reverse iterator to the last element of the const-qualified collection (first in reverse).
Definition: sorted_dictionary.h:175
std::map< TKey, TValue, ComparerAdapter< typename BasePointerType< TKey >::type >, ASPOSE_MAP_ALLOCATOR_TYPE(TKey, TValue)> map_t
Underlying data type.
Definition: sorted_dictionary.h:70
map_t::const_reverse_iterator const_reverse_iterator
Const reverse iterator type.
Definition: sorted_dictionary.h:89
static SharedPtr< IComparer< typename BasePointerType< TKey >::type > > GetDefaultKeyComparer()
Singleton accessor function.
Definition: sorted_dictionary.h:93
SortedDictionary(const SharedPtr< IDictionary< TKey, TValue > > &src)
Copy constructor.
Definition: sorted_dictionary.h:115
SortedDictionary()
Constructs empty dictionary.
Definition: sorted_dictionary.h:102
ICollection< TKey > KeyCollection
Key collection type.
Definition: sorted_dictionary.h:66
IEnumeratorPtr GetEnumerator() override
Gets enumerator to iterate through current dictionary.
Definition: sorted_dictionary.h:154
const_reverse_iterator rend() const noexcept
Gets a reverse iterator for a non-existent element before the start of the const-qualified collection...
Definition: sorted_dictionary.h:182
SortedDictionary(const SharedPtr< IDictionary< TKey, TValue > > &src, const SharedPtr< IComparer< typename BasePointerType< TKey >::type > > &comparer)
Copy constructor.
Definition: sorted_dictionary.h:124
SortedDictionary(const SharedPtr< IComparer< typename BasePointerType< TKey >::type > > &comparer)
Constructs empty dictionary.
Definition: sorted_dictionary.h:108
reverse_iterator rend() noexcept
Gets a reverse iterator for a non-existent element before the start of the collection.
Definition: sorted_dictionary.h:168
~SortedDictionary() override
Destructor.
Definition: sorted_dictionary.h:203
SharedPtr< IEnumerable< KVPair > > IEnumerablePtr
Collection of same elements.
Definition: sorted_dictionary.h:78
reverse_iterator rbegin() noexcept
Gets a reverse iterator to the last element of collection (first in reverse).
Definition: sorted_dictionary.h:161
Sorted dictionary pointer with access operators. This type is a pointer to manage other object's dele...
Definition: sorted_dictionary.h:24
SortedDictionaryPtr(const SharedPtr< SortedDictionary< T, V > > &obj)
Constructs pointer to specified sorted dictionary.
Definition: sorted_dictionary.h:31
SortedDictionaryPtr()
Constructs null pointer.
Definition: sorted_dictionary.h:27
Pointer class to wrap types being allocated on heap. Use it to manage memory for classes inheriting O...
Definition: smart_ptr.h:180
Definition: db_command.h:9
SmartPtr< X > MakeSharedPtr(X *p)
Converts raw pointer to smart pointer.
Definition: smart_ptr.h:1650
Adapter to use IComparer within STL environment. Uses IComparer if set; otherwise,...
Definition: icomparer.h:44