GithubHelp home page GithubHelp logo

morzhovets / momo Goto Github PK

View Code? Open in Web Editor NEW
12.0 4.0 2.0 20.84 MB

C++ template containers with optimized memory consumption

Home Page: https://morzhovets.github.io/momo

License: MIT License

C++ 97.39% C 2.58% CMake 0.03%
optimization data-structures hash-table b-tree memory-pool hash-container unordered-map hash-map

momo's Introduction

MSVC GCC Clang AppleClang IntelLLVM

momo (Memory Optimization is the Main Objective)

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. Compiler must support C++11.

Deviations from the standard

  • 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 map and unordered_map type reference is not the same as value_type&, so for (auto& p : map) is illegal, but for (auto p : map) or for (const auto& p : map) or for (auto&& p : map) is allowed.

The main ideas

  • The implementation of set/map is based on a B-tree.

  • unordered_set/map are hash tables with buckets in the form of small arrays.

  • Memory pools are used to speed up the memory operations.

Usage

Just copy the folder include/momo in your source code. This folder contains only header files.

Classes set/map and unordered_set/map are located in subfolder stdish, namespace momo::stdish.

Some documentation is here.

Other classes

  • stdish::unordered_set_open and stdish::unordered_map_open are based on open addressing hash tables.

  • stdish::vector_intcap is vector with internal capacity. This vector doesn't need dynamic memory while its size is not greater than user-defined constant.

  • stdish::unordered_multimap is similar to std::unordered_multimap, but each of duplicate keys is stored only once.

  • stdish::multiset and stdish::multimap are similar to std::multiset and std::multimap.

  • stdish::unsynchronized_pool_allocator is allocator with a pool of memory for containers like std::list or std::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 momo also contains many of the analogous classes with non-standard interface, but more flexible, namely HashSet, HashMap, HashMultiMap, TreeSet, TreeMap, Array, SegmentedArray, MemPool.

DataTable

momo::DataTable is similar to Boost.MultiIndex, but its API looks like ADO.NET DataTable. Some examples are here.

Supported compilers

  • MS Visual C++ (19.0+, Visual Studio 2015+)

  • GCC (4.9+) with -std=c++11

  • Clang (3.6+) with -std=c++11

  • Apple Clang (8.1+, Xcode 8.3+) with -std=c++11

  • Intel C++ with -std=c++11

momo's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

asidorov95

momo's Issues

gcc 9.2.1

momo/DataSelection.h:303:3: warning: converting ‘momo::internal::DataConstItemIterator<TItem, TRowIterator, TSettings>’ to the same type will never use a type conversion operator [-Wclass-conversion]
  303 |   operator ConstIterator() const noexcept
      |   ^~~~~~~~
momo/DataSelection.h:380:3: warning: converting ‘momo::internal::DataConstItemBounds<TItem, TRowBounds, TSettings>’ to the same type will never use a type conversion operator [-Wclass-conversion]
  380 |   operator ConstBounds() const noexcept
      |   ^~~~~~~~

std::exception: Cannot create DataColumnList

#include <iostream>
#include "momo/DataTable.h"

namespace a {
	MOMO_DATA_COLUMN_STRING(int, v);
	// MOMO_DATA_COLUMN_STRING(int, v);  //error: redefinition of 'v'
}

namespace b {
	MOMO_DATA_COLUMN_STRING(int, v);
}

int main() try
{
	momo::experimental::DataColumnList<> {a::v, b::v};
	return 0;
}
catch (std::exception &ex)
{
	std::cerr << "std::exception: " << ex.what() << std::endl;
}

MemPool is not thread safe

When we try to create objects using MemPool from different threads at the same time, it crashes. Please add thread safety

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.