HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
Public Types | Public Member Functions
v1::tree< Key, T, Compare > Class Template Reference

#include <hikogui/container/tree.hpp>

Public Types

using key_type = Key
 
using value_type = T
 

Public Member Functions

constexpr tree (tree const &) noexcept=default
 
constexpr tree (tree &&) noexcept=default
 
constexpr treeoperator= (tree const &) noexcept=default
 
constexpr treeoperator= (tree &&) noexcept=default
 
value_type & operator() (auto path_first, auto path_last) noexcept
 Find or create the node and return the value of the node.
 
value_type const & operator() (auto path_first, auto path_last) const noexcept
 Find the node and return the value of the node.
 
value_type & operator[] (auto const &key) noexcept
 Find or create the node and return the value of the node.
 
value_type const & operator[] (auto const &path) const noexcept
 Find the node and return the value of the node.
 
void walk (auto path_first, auto path_last, auto &&func) noexcept
 
void walk (auto path_first, auto path_last, auto &&func) const noexcept
 
void walk (auto const &key, auto &&func) noexcept
 
void walk (auto const &key, auto &&func) const noexcept
 
void walk_including_path (auto path_first, auto path_last, auto const &func) noexcept
 Walk the tree starting at path, and also for each node along the path.
 
void walk_including_path (auto path_first, auto path_last, auto const &func) const noexcept
 Walk the tree starting at path, and also for each node along the path.
 
void walk_including_path (auto const &path, auto &&func) noexcept
 Walk the tree starting at path, and also for each node along the path.
 
void walk_including_path (auto const &path, auto &&func) const noexcept
 Walk the tree starting at path, and also for each node along the path.
 
void walk (auto &&func) noexcept
 Walk the full tree.
 
void walk (auto &&func) const noexcept
 Walk the full tree.
 

Detailed Description

template<typename Key, typename T, typename Compare = std::less<Key>>
class v1::tree< Key, T, Compare >

A tree container.

Template Parameters
KeyThey key type to index into each level of the tree.
TThe value that is stored into each node.
CompareThe comparison to use with the key used in std::map.

Member Function Documentation

◆ operator()() [1/2]

template<typename Key , typename T , typename Compare = std::less<Key>>
value_type const & v1::tree< Key, T, Compare >::operator() ( auto path_first,
auto path_last ) const
inlinenoexcept

Find the node and return the value of the node.

XXX c++23 multiple argument index operator

Note
It is undefined behavior to call this function if the path does not exist in the tree.
Parameters
path_firstThe iterator to the first element of the path of the node to get the value of.
path_lastThe iterator beyond the last element of the path of the node to get the value of.
Returns
A reference to the value.

◆ operator()() [2/2]

template<typename Key , typename T , typename Compare = std::less<Key>>
value_type & v1::tree< Key, T, Compare >::operator() ( auto path_first,
auto path_last )
inlinenoexcept

Find or create the node and return the value of the node.

XXX c++23 multiple argument index operator

Parameters
path_firstThe iterator to the first element of the path of the node to get the value of.
path_lastThe iterator beyond the last element of the path of the node to get the value of.
Returns
A reference to the value.

◆ operator[]() [1/2]

template<typename Key , typename T , typename Compare = std::less<Key>>
value_type & v1::tree< Key, T, Compare >::operator[] ( auto const & key)
inlinenoexcept

Find or create the node and return the value of the node.

Parameters
keyThe path of the node to get the value of.
Returns
A reference to the value.

◆ operator[]() [2/2]

template<typename Key , typename T , typename Compare = std::less<Key>>
value_type const & v1::tree< Key, T, Compare >::operator[] ( auto const & path) const
inlinenoexcept

Find the node and return the value of the node.

Note
It is undefined behavior to call this function if the path does not exist in the tree.
Parameters
pathThe path of the node to get the value of.
Returns
A reference to the value.

◆ walk() [1/2]

template<typename Key , typename T , typename Compare = std::less<Key>>
void v1::tree< Key, T, Compare >::walk ( auto && func) const
inlinenoexcept

Walk the full tree.

Parameters
funcThe function (value_type const &) -> void to call for each node in the tree.

◆ walk() [2/2]

template<typename Key , typename T , typename Compare = std::less<Key>>
void v1::tree< Key, T, Compare >::walk ( auto && func)
inlinenoexcept

Walk the full tree.

Parameters
funcThe function (value_type &) -> void to call for each node in the tree.

◆ walk_including_path() [1/4]

template<typename Key , typename T , typename Compare = std::less<Key>>
void v1::tree< Key, T, Compare >::walk_including_path ( auto const & path,
auto && func ) const
inlinenoexcept

Walk the tree starting at path, and also for each node along the path.

Parameters
pathThe path (range) of the node to start walking.
funcThe function (value_type const &) -> void to call on each child node recursively at the start of the path, and along the nodes of the path.

◆ walk_including_path() [2/4]

template<typename Key , typename T , typename Compare = std::less<Key>>
void v1::tree< Key, T, Compare >::walk_including_path ( auto const & path,
auto && func )
inlinenoexcept

Walk the tree starting at path, and also for each node along the path.

Parameters
pathThe path (range) of the node to start walking.
funcThe function (value_type &) -> void to call on each child node recursively at the start of the path, and along the nodes of the path.

◆ walk_including_path() [3/4]

template<typename Key , typename T , typename Compare = std::less<Key>>
void v1::tree< Key, T, Compare >::walk_including_path ( auto path_first,
auto path_last,
auto const & func ) const
inlinenoexcept

Walk the tree starting at path, and also for each node along the path.

Parameters
path_firstThe iterator pointing to the first element of the path; of the node to start walking.
path_lastThe iterator pointing beyond the last element of the path.
funcThe function (value_type const &) -> void to call on each child node recursively at the start of the path, and along the nodes of the path.

◆ walk_including_path() [4/4]

template<typename Key , typename T , typename Compare = std::less<Key>>
void v1::tree< Key, T, Compare >::walk_including_path ( auto path_first,
auto path_last,
auto const & func )
inlinenoexcept

Walk the tree starting at path, and also for each node along the path.

Parameters
path_firstThe iterator pointing to the first element of the path; of the node to start walking.
path_lastThe iterator pointing beyond the last element of the path.
funcThe function (value_type &) -> void to call on each child node recursively at the start of the path, and along the nodes of the path.

The documentation for this class was generated from the following file: