Class Dictionary
Template for unordered dictionary with mapped key with value pairs.
Inheritance
Inherited Members
Assembly: FlaxEngine.dll
File: Engine/Core/Collections/Dictionary.h
Syntax
public class Dictionary<KeyType, ValueType, AllocationType> : public HashSetBase
Type Parameters
KeyType
The type of the keys in the dictionary. |
ValueType
The type of the values in the dictionary. |
AllocationType
The type of memory allocator. |
Constructors
~Dictionary()
DEPRECATED("Use Add with separate Key and Value from iterator.") void Add(const Iterator& i)
Add pair element to the collection.
Declaration
public DEPRECATED("Use Add with separate Key and Value from iterator.") void Add(const Iterator& i)
Parameters
"Use Add with separate Key and Value from iterator."
Dictionary_DEPRECATED__Use_Add_with_separate_Key_and_Value_from_iterator___
|
Dictionary()
Dictionary(const Dictionary& other)
Initializes Dictionary by copying the elements from the other collection.
Declaration
public Dictionary(const Dictionary& other)
Parameters
Dictionary
other
Other collection to copy |
Dictionary(Dictionary&& other)
Initializes a new instance of the Dictionary class.
Declaration
public Dictionary(Dictionary&& other) noexcept
Parameters
Dictionary
other
The other collection to move. |
Methods
Add(const KeyComparableType& key, const ValueType& value)
Add pair element to the collection.
Declaration
public Bucket* Add(const KeyComparableType& key, const ValueType& value)
Parameters
KeyComparableType
key
The key. |
ValueType
value
The value. |
Returns
Bucket
Weak reference to the stored bucket. |
Type Parameters
typename KeyComparableType
|
Add(const KeyComparableType& key, ValueType&& value)
Add pair element to the collection.
Declaration
public Bucket* Add(const KeyComparableType& key, ValueType&& value)
Parameters
KeyComparableType
key
The key. |
ValueType
value
The value. |
Returns
Bucket
Weak reference to the stored bucket. |
Type Parameters
typename KeyComparableType
|
At(const KeyComparableType& key)
Gets element by the key (will add default ValueType element if key not found).
Declaration
public ValueType At(const KeyComparableType& key)
Parameters
KeyComparableType
key
The key of the element. |
Returns
ValueType
The value that is at given index. |
Type Parameters
typename KeyComparableType
|
Begin()
Declaration
public Iterator Begin()
Returns
Iterator
|
begin()
Declaration
public Iterator begin()
Returns
Iterator
|
ClearDelete()
Clears the collection and delete value objects. Note: collection must contain pointers to the objects that have public destructor and be allocated using New method.
Declaration
public void ClearDelete()
Clone(const Dictionary& other)
Clones other collection into this.
Declaration
public void Clone(const Dictionary& other)
Parameters
Dictionary
other
The other collection to clone. |
ContainsKey(const KeyComparableType& key)
Checks if given key is in a collection.
Declaration
public bool ContainsKey(const KeyComparableType& key) const
Parameters
KeyComparableType
key
The key to find. |
Returns
bool
True if key has been found in a collection, otherwise false. |
Type Parameters
typename KeyComparableType
|
ContainsValue(const ValueType& value)
Checks if given value is in a collection.
Declaration
public bool ContainsValue(const ValueType& value) const
Parameters
ValueType
value
The value to find. |
Returns
bool
True if value has been found in a collection, otherwise false. |
Dictionary(const int32 capacity)
Initializes Dictionary by reserving space.
Declaration
public Dictionary(const int32 capacity)
Parameters
int32
capacity
The number of elements that can be added without a need to allocate more memory. |
Returns
FORCE_INLINE
|
End()
Declaration
public Iterator End()
Returns
Iterator
|
end()
Declaration
public Iterator end()
Returns
Iterator
|
Find(const KeyComparableType& key)
Finds the element with given key in the collection.
Declaration
public Iterator Find(const KeyComparableType& key)
Parameters
KeyComparableType
key
The key to find. |
Returns
Iterator
The iterator for the found element or End if cannot find it. |
Type Parameters
typename KeyComparableType
|
GetKeys(Array<KeyType, ArrayAllocation>& result)
Gets the keys collection to the output array (will contain unique items).
Declaration
public void GetKeys(Array<KeyType, ArrayAllocation>& result) const
Parameters
Array<KeyType, ArrayAllocation>
result
The result. |
Type Parameters
typename ArrayAllocation
|
GetValues(Array<ValueType, ArrayAllocation>& result)
Gets the values collection to the output array (may contain duplicates).
Declaration
public void GetValues(Array<ValueType, ArrayAllocation>& result) const
Parameters
Array<ValueType, ArrayAllocation>
result
The result. |
Type Parameters
typename ArrayAllocation
|
KeyOf(const ValueType& value, KeyType* key)
Searches for the specified object and returns the zero-based index of the first occurrence within the entire dictionary.
Declaration
public bool KeyOf(const ValueType& value, KeyType* key) const
Parameters
ValueType
value
The value of the key to find. |
KeyType
key
The output key. |
Returns
bool
True if value has been found, otherwise false. |
operator[](const KeyComparableType& key)
Gets or sets the element by the key.
Declaration
public ValueType operator[](const KeyComparableType& key)
Parameters
KeyComparableType
key
The key of the element. |
Returns
ValueType
The value that is at given index. |
Type Parameters
typename KeyComparableType
|
operator=(const Dictionary& other)
Clones the data from the other collection.
Declaration
public Dictionary operator=(const Dictionary& other)
Parameters
Dictionary
other
The other collection to copy. |
Returns
Dictionary
The reference to this. |
operator=(Dictionary&& other)
Moves the data from the other collection.
Declaration
public Dictionary operator=(Dictionary&& other) noexcept
Parameters
Dictionary
other
The other collection to move. |
Returns
Dictionary
The reference to this. |
Remove(const Iterator& i)
Removes element at specified iterator.
Declaration
public bool Remove(const Iterator& i)
Parameters
Iterator
i
The element iterator to remove. |
Returns
bool
True if cannot remove item from the collection because cannot find it, otherwise false. |
Remove(const KeyComparableType& key)
Removes element with a specified key.
Declaration
public bool Remove(const KeyComparableType& key)
Parameters
KeyComparableType
key
The element key to remove. |
Returns
bool
True if cannot remove item from the collection because cannot find it, otherwise false. |
Type Parameters
typename KeyComparableType
|
RemoveValue(const ValueType& value)
Removes elements with a specified value
Declaration
public int32 RemoveValue(const ValueType& value)
Parameters
ValueType
value
Element value to remove |
Returns
int32
The amount of removed items. Zero if nothing changed. |
TryGet(const KeyComparableType& key)
Tries to get pointer to the element with given key.
Declaration
public ValueType* TryGet(const KeyComparableType& key) const
Parameters
KeyComparableType
key
The ky of the element. |
Returns
ValueType
Pointer to the element value or null if cannot find it. |
Type Parameters
typename KeyComparableType
|
TryGet(const KeyComparableType& key, ValueType& result)
Tries to get element with given key.
Declaration
public bool TryGet(const KeyComparableType& key, ValueType& result) const
Parameters
KeyComparableType
key
The key of the element. |
ValueType
result
The result value. |
Returns
bool
True if element of given key has been found, otherwise false. |
Type Parameters
typename KeyComparableType
|