Samchon Framework for CPP
1.0.0
|
Customized std::map. More...
#include <TreeMap.hpp>
Public Member Functions | |
auto | has (const _Kty &key) const -> bool |
Whether have the item or not. More... | |
auto | get (const _Kty &key) -> _Ty & |
Get element. More... | |
void | set (const _Kty &key, const _Ty &val) |
Set element. More... | |
auto | pop (const _Kty &key) -> _Ty |
Pop item. More... | |
Customized std::map.
TreeMap is a std::map some methods are modified.
Maps are associative containers that store elements formed by a combination of a key value and a mapped value, following a specific order.
In a map, the key values are generally used to sort and uniquely identify the elements, while the mapped values store the content associated to this key. The types of key and mapped value may differ, and are grouped together in member type value_type, which is a pair type combining both:
Internally, the elements in a map are always sorted by its key following a specific strict weak ordering criterion indicated by its internal comparison object (of type Compare).
map containers are generally slower than unordered_map containers to access individual elements by their key, but they allow the direct iteration on subsets based on their order.
Maps are typically implemented as binary search trees.
The mapped values in a map can be accessed directly by their corresponding key using the bracket operator ((operator[]).
Maps are typically implemented as binary search trees.
Referenced comments of std::map
_Kty |
Type of the keys. Each element in a map is uniquely identified by its key value.
Aliased as member type map::key_type.
_Ty |
Type of the mapped value. Each element in a map stores some data as its mapped value.
Aliased as member type map::mapped_type.
_Pr |
A binary predicate that takes two element keys as arguments and returns a bool. The expression comp(a,b), where comp is an object of this type and a and b are key values, shall return true if a is considered to go before b in the strict weak ordering the function defines.
The map object uses this expression to determine both the order the elements follow in the container and whether two element keys are equivalent (by comparing them reflexively: they are equivalent if !comp(a,b) && !comp(b,a)). No two elements in a map container can have equivalent keys.
This can be a function pointer or a function object. This defaults to std::less<T>, which returns the same as applying the less-than operator (a<b).
Aliased as member type map::key_compare.
_Alloc |
Type of the allocator object used to define the storage allocation model. By default, the allocator class template is used, which defines the simplest memory allocation model and is value-independent.
Aliased as member type map::allocator_type.
Definition at line 87 of file TreeMap.hpp.
|
inline |
Whether have the item or not.
Indicates whether a map has an item having the specified identifier.
key | Key value of the element whose mapped value is accessed. |
Definition at line 109 of file TreeMap.hpp.
|
inline |
Get element.
Returns a reference to the mapped value of the element identified with key
key | Key value of the element whose mapped value is accessed. |
exception | out of range |
Definition at line 128 of file TreeMap.hpp.
|
inline |
Set element.
Set an item as the specified identifier.
If the identifier is already in map, change value of the identifier.
If not, then insert the object with the identifier.
key | Key value of the element whose mapped value is accessed. |
val | Value, the item. |
Definition at line 149 of file TreeMap.hpp.
|
inline |
Pop item.
Removes an item having specified key and returns the removed element.
Definition at line 172 of file TreeMap.hpp.