|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
DynMapTree (ordered map) with multiple tree backends + demo suite and benchmark. More...
#include <iostream>#include <iomanip>#include <string>#include <vector>#include <chrono>#include <random>#include <tpl_dynMapTree.H>#include <tclap/CmdLine.h>Go to the source code of this file.
Functions | |
| void | demo_basic_operations () |
| Demonstrate basic map operations. | |
| void | demo_tree_backends () |
| Demonstrate different tree backends. | |
| void | demo_word_frequency () |
| Practical example: Word frequency counter. | |
| void | demo_config_store () |
| Practical example: Configuration store. | |
| void | demo_functional () |
| Functional programming with maps. | |
| void | demo_performance (int n) |
| Performance comparison of backends. | |
| int | main (int argc, char *argv[]) |
DynMapTree (ordered map) with multiple tree backends + demo suite and benchmark.
This example demonstrates Aleph-w's DynMapTree, an ordered key→value map implemented on top of a configurable tree backend.
The program is organized as a set of small demos:
insert, operator[], search, remove, iteration)--count)DynMapTree<string, int> and DynMapTree<int, int, Backend>Aleph::less<Key> by default.This example uses TCLAP. Options:
--count / -n <int>: number of elements used by the performance demo (default: 10000).--basic / -b: run only the basic-operations demo.--trees / -t: run only the tree-backends demo.--words / -w: run only the word-frequency demo.--config / -c: run only the configuration-store demo.--functional / -f: run only the functional-programming demo.--performance / -p: run only the performance demo.--all / -a: run all demos.--help: show help.Behavior:
Let n be the number of stored keys.
O(log n) expected/typical for balanced backends.O(n).operator[] inserts a default value if the key does not exist.tpl_dynMapTree.H (DynMapTree)dynset_trees.C (set counterpart)hash_tables_example.C (unordered alternatives)Definition in file dynmap_example.C.
| void demo_basic_operations | ( | ) |
Demonstrate basic map operations.
Definition at line 126 of file dynmap_example.C.
References LocateFunctions< Container, Type >::get_it(), Aleph::DynList< T >::insert(), Aleph::maps(), Aleph::DynList< T >::remove(), and Aleph::HTList::size().
Referenced by main().
| void demo_config_store | ( | ) |
Practical example: Configuration store.
Definition at line 282 of file dynmap_example.C.
References LocateFunctions< Container, Type >::get_it(), Aleph::maps(), and Aleph::DynMapTree< Key, Data, Tree, Compare >::search().
Referenced by main().
| void demo_functional | ( | ) |
Functional programming with maps.
Definition at line 328 of file dynmap_example.C.
References FunctionalMethods< Container, T >::all(), FunctionalMethods< Container, T >::exists(), FunctionalMethods< Container, T >::filter(), FunctionalMethods< Container, T >::foldl(), FunctionalMethods< Container, T >::for_each(), Aleph::maps(), and Aleph::HTList::size().
Referenced by main().
| void demo_performance | ( | int | n | ) |
Performance comparison of backends.
Definition at line 383 of file dynmap_example.C.
References Aleph::maps().
| void demo_tree_backends | ( | ) |
Demonstrate different tree backends.
Definition at line 187 of file dynmap_example.C.
References Aleph::maps(), and Aleph::HTList::size().
Referenced by main().
| void demo_word_frequency | ( | ) |
Practical example: Word frequency counter.
Definition at line 244 of file dynmap_example.C.
References LocateFunctions< Container, Type >::get_it(), Aleph::maps(), and Aleph::HTList::size().
Referenced by main().
| int main | ( | int | argc, |
| char * | argv[] | ||
| ) |
Definition at line 459 of file dynmap_example.C.
References demo_basic_operations(), demo_config_store(), demo_functional(), demo_performance(), demo_tree_backends(), demo_word_frequency(), and Aleph::maps().