BloombergLP::ball::CategoryManager_RadixTree

This class template implements a space-efficient associative container that maps string keys to values of the specified t_VALUE type. The container uses a radix tree (compressed trie) data structure, which shares common prefixes among keys. The container provides O(k) insertion, lookup, and removal operations, where k is the key length.

Synopsis

Declared in <ball_categorymanager_radixtree.h>

template<class t_VALUE>
class CategoryManager_RadixTree;

Type Aliases

NameDescription
EmplaceResult The return type of adding a value to the tree with emplace(). It is not the usual insert return type, because this data structure does not provide an iterator. The .first boolean is true if an element was inserted, and the .second data member is a reference to the (possibly newly created) value. Notice that if the value existed (.first == false) the reference wrapper will still give access to the value of that node; the .second is always a valid mutable reference to the value belonging to the key used in the emplace call.
OptValueCRef Type for immutable access to the optional value. Used also as return type for immutable finders where empty optional signifies "not found".
OptValueRef Type for mutable access to the optional value. Used also as return type for mutable finders where empty optional signifies "not found".
allocator_type allocator_type is an alias for the type of allocator used by this class.
size_type size_type is an alias for the type used to represent sizes in this tree.
value_type value_type is an alias for the value type stored in this tree.

Member Functions

NameDescription
CategoryManager_RadixTree [constructor]Constructors
operator= Assignment operators
clear Remove all entries from this tree. After this call empty() will return true. After this call the tree will have 0 nodes.
contains Return true if this tree contains an entry for the specified key, and false otherwise.
countNodes Return the total number of nodes in this tree, including internal nodes without values. Note that this method has O(n) complexity where n is the number of nodes, and is intended for use in testing to verify tree structure invariants. In user code use size() that tells the actual number of entries with values.
emplace Insert into this tree an entry with the specified key and a newly created t_VALUE object, constructed by forwarding get_allocator() (if required) and the specified (variable number of) args to the corresponding constructor of t_VALUE. Return a pair consisting of a reference to the value associated with key (whether newly inserted or already existing) and a boolean indicating whether insertion took place (true if the key was not already present, false otherwise). This method requires that t_VALUE be emplace-constructible from args.
empty Return true if this tree contains no entries, and false otherwise.
erase Remove from this tree the entry with the specified key. Return true if the entry was removed (key existed), and false otherwise.
eraseChildrenOfPrefix Remove all children of the entry matching the specified prefix, but not the entry with the prefix itself. If unused (no value, no children) nodes remain remove those, too. If no entry exists for prefix remove nothing. Return the number of entries removed.
erasePrefix Remove from this tree all entries with keys that have the specified prefix, including the entry for the prefix itself if it exists. Return the number of entries removed. Note that this method removes all nodes whose keys start with prefix, not just those that have a value.
find find overloads
findLongestCommonPrefix findLongestCommonPrefix overloads
forEach forEach overloads
forEachPrefix forEachPrefix overloads
get_allocator Return the allocator used by this object to supply memory. Note that if no allocator was supplied at construction the default allocator in effect at construction is used.
printNodes Write the value of this object to the specified output stream in a human-readable format, and return a non-const reference to stream. Optionally specify an initial indentation level, whose absolute value is incremented recursively for nested objects. If level is specified, optionally specify spacesPerLevel, whose absolute value indicates the number of spaces per indentation level for this and all of its nested objects. If level is negative, suppress indentation of the first line. If spacesPerLevel is negative, format the entire output on one line, suppressing all but the initial indentation (as governed by level). If stream is not valid on entry, this operation has no effect. Note that the format is not fully specified, and may change without notice.
size Return the number of entries in this tree.
swap Efficiently exchange the value of this object with the value of the specified other object. This method provides the no-throw exception-safety guarantee. The behavior is undefined unless this object was created with the same allocator as other.

Friends

NameDescription
BloombergLP::ball::swapExchange the values of the specified trees.
BloombergLP::ball::operator==Return true if the specified trees have the same value.

Non-Member Functions

NameDescription
operator!=Return true if the specified lhs and rhs objects do not have the same value, and false otherwise. Two CategoryManager_RadixTree objects do not have the same value if they differ in their number of entries or if any key maps to different values in the two objects.
operator==Return true if the specified lhs and rhs objects have the same value, and false otherwise. Two CategoryManager_RadixTree objects have the same value if they have the same number of entries and each key in lhs maps to the same value as in rhs.
swapExchange the values of the specified a and b objects. This function provides the no-throw exception-safety guarantee if the two objects were created with the same allocator and the basic guarantee otherwise.