cpp-art is a C++11 STL-commpliant map and set container based on an Adaptive Radix Tree (ART) implementation. ART supports O(k) operations (where k is the size of the key in bytes) while limiting the characteristic space overhead of radix trees by changing node sizes. (See the wiki for more information.) The containers provide virtually the same interface as their stl counterparts (see the wiki for the interface documentation: radix_map, radix_set) and they meet (mostly/completely?) the requirements of Container, AssociativeContainer (there is a key_transform instead of key_comp) and ReversibleContainer. (Please report other deviations as issues.)
- Only integers are supported as keys out of the box at the moment. Support for string/char is on the roadmap.
- There is a
key_transform
function instead ofkey_comp
/hash
that you can implement for custom types. The return type ofkey_transform
must be an integer type for now. - Container is not thread-safe (yet)!!!
- AllocatorAwareContainer is on the roadmap.
- Erase by iterator only works with non-const iterator.
cpp-art is a header-only library and requires C++11 features. Simply add <path-of-your-choice>/cpp-art/include
to your include paths and then the relevant headers can then be included with #include <art/radix_set.h>
and #include <art/radix_map.h>
. For further information, please take a look at the wiki.
- Sparse: Sampled uniform at random of the entire key type's domain.
- Dense: Sequential keys 0..16M.
- Comparison of std::map, std::unordered_map, google's cpp-btree and cpp-art.
- Preliminary because of lacking due diligence when measuring and, seeing as some main features are still missing in cpp-art, there also hasn't been performance optimization. Also, variance is very high, in particular for the radix tree.
Looking up non-existing keys is up to 3-5 times faster in a radix tree, other containers are unaffected or gain much less.