]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | [/ |
2 | / Copyright (c) 2008 Marcin Kalicinski (kalita <at> poczta dot onet dot pl) | |
3 | / Copyright (c) 2009 Sebastian Redl (sebastian dot redl <at> getdesigned dot at) | |
4 | / | |
5 | / Distributed under the Boost Software License, Version 1.0. (See accompanying | |
6 | / file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | |
7 | /] | |
8 | [section:container Property Tree as a Container] | |
9 | [/ __ptree_*__ macros expected from property_tree.qbk] | |
10 | Every property tree node models the ReversibleSequence concept, providing | |
11 | access to its immediate children. This means that iterating over a __ptree__ | |
12 | (which is the same as its root node - every __ptree__ node is also the | |
13 | subtree it starts) iterates only a single level of the hierarchy. There is no | |
14 | way to iterate over the entire tree. | |
15 | ||
16 | It is very important to remember that the property sequence is *not* ordered by | |
17 | the key. It preserves the order of insertion. It closely resembles a std::list. | |
18 | Fast access to children by name is provided via a separate lookup structure. Do | |
19 | not attempt to use algorithms that expect an ordered sequence (like | |
20 | binary_search) on a node's children. | |
21 | ||
22 | The property tree exposes a second container-like interface, called the | |
23 | associative view. Its iterator type is the nested type assoc_iterator (and its | |
24 | const counterpart const_assoc_iterator). You can get an ordered view of all | |
25 | children by using ordered_begin() and ordered_end(). | |
26 | ||
27 | The associative view also provides find() and equal_range() members, which | |
28 | return assoc_iterators, but otherwise have the same semantics as the members | |
29 | of std::map of the same name. | |
30 | ||
31 | You can get a normal iterator from an assoc_iterator by using the to_iterator() | |
32 | member function. Converting the other way is not possible. | |
33 | [endsect] [/container] |