diff options
author | Adrian Kummerländer | 2014-02-06 18:37:43 +0100 |
---|---|---|
committer | Adrian Kummerländer | 2014-02-06 18:37:43 +0100 |
commit | 35f814706c4ff244bc15c4285804fc0656824c41 (patch) | |
tree | bd15383618cf9e0e0b319df4e46fb51adec6494b /src | |
parent | c86f957426a2399217bcca466dec7a83d0981ba3 (diff) | |
download | Trie-35f814706c4ff244bc15c4285804fc0656824c41.tar Trie-35f814706c4ff244bc15c4285804fc0656824c41.tar.gz Trie-35f814706c4ff244bc15c4285804fc0656824c41.tar.bz2 Trie-35f814706c4ff244bc15c4285804fc0656824c41.tar.lz Trie-35f814706c4ff244bc15c4285804fc0656824c41.tar.xz Trie-35f814706c4ff244bc15c4285804fc0656824c41.tar.zst Trie-35f814706c4ff244bc15c4285804fc0656824c41.zip |
Added support for changing values
* member method set changes the value of a given path to the provided value
** returns false if the specified path doesn't exist
Diffstat (limited to 'src')
-rw-r--r-- | src/trie.h | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -51,6 +51,19 @@ class Trie { } } + inline bool set(key_list path, Value value) { + std::pair<bool, Trie*> tmp(this->resolve(path)); + + if ( tmp.first ) { + tmp.second->value_.first = true; + tmp.second->value_.second = value; + + return true; + } else { + return false; + } + } + private: std::pair<bool, Value> value_; std::map<Key, Trie> children_; |