This project contains an implementation of the C++ containers, similar to the
standard set/map and unordered_set/map,
but much more efficient in memory usage.
As for the operation speed, these containers are also better than the standard ones in most cases
(benchmark of unordered containers,
benchmark of ordered containers,
benchmark sources).
Classes are designed in close conformity with the standard C++20 including exception safety guarantees. The compiler only needs to support C++11.
-
Container items must be movable (preferably without exceptions) or copyable, similar to items of
std::vector. -
All iterators and references to items will become invalid after each addition or removal of the item and should not be used.
-
In
mapandunordered_maptypereferenceis a pair of references (same as instd::flat_map), sofor (auto& p : map)is illegal, butfor (auto p : map)orfor (const auto& p : map)orfor (auto&& p : map)is allowed.
-
The implementation of
set/mapis based on a B-tree. -
unordered_set/mapare hash tables with buckets in the form of small arrays. -
Memory pools are used to speed up the memory operations.
This library is header-only and has zero dependencies. So you can just copy the folder include/momo into your source code.
Classes set/map and unordered_set/map are located in subfolder
stdish, namespace momo::stdish.
Some documentation is here.
-
stdish::unordered_set_openandstdish::unordered_map_openare based on open addressing hash tables. -
stdish::vector_intcapis vector with internal capacity. This vector doesn't need dynamic memory while its size is not greater than user-defined constant. -
stdish::unordered_multimapis similar tostd::unordered_multimap, but each of duplicate keys is stored only once. -
stdish::multisetandstdish::multimapare similar tostd::multisetandstd::multimap. -
stdish::unsynchronized_pool_allocatoris allocator with a pool of memory for containers likestd::listorstd::map. Each copy of the container keeps its own memory pool. Memory is released not only after destruction of the object, but also in case of removal sufficient number of items. -
Folder
momoalso contains many of the analogous classes with non-standard interface, but more flexible, namelyHashSet,HashMap,HashMultiMap,TreeSet,TreeMap,Array,SegmentedArray,MemPool.
momo::DataTable is similar to Boost.MultiIndex,
but its API looks like ADO.NET DataTable.
Some examples are here.
-
MS Visual C++ (19.0+, Visual Studio 2015+)
-
GCC (5+)
-
Clang (3.9+)
-
Apple Clang
-
Intel C++