Giter Site home page Giter Site logo

p-groarke / fea_unsigned_map Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 0.0 100 KB

A collection of slot maps and hash maps optimized for unsigned keys.

License: BSD 3-Clause "New" or "Revised" License

CMake 4.68% C++ 95.32%
unsigned-keys stl slotmap unordered-map unordered-maps hash-map flatmap

fea_unsigned_map's Introduction


This repository is inactive and kept for posterity's sake.

Any further development will happen in fea_libs. Cheers.



fea_unsigned_map

Build Status Build status

unordered_map like containers, optimized for unsigned keys.

Internal container and allocator are not customizable at this time.

unsigned_map

unsigned_map is a slot map that follows the unordered_map c++ standard apis as close as possible. Unlike most slot map implementations, you provide the unique key. This is useful when retro-fitting slot maps into legacy code. If key generations are desirable for your use-case, use a slot_map instead.

Warning : Key container will grow as large as the biggest key!

When To Use

  • Keys grow from 0 to N.
  • Each key is unique, aka a perfect hash.
  • Memory is not a concearn or you can guarantee linearity in the keys (aka memory consumption isn't wasted).

Features

  • Has better copy/clear performance since it doesn't need rehashing.
  • Has better value iteration performance since it doesn't use buckets and values are tightly packed.
  • Insert is darn fast.
  • Optimized for speed, not memory usage.

flat_unsigned_hashmap

The flat_unsigned_hashmap is a more traditional hashing map, that has similar constraints as a slot map. Here, the lookup container will not grow as big as the biggest key. It is still much more performant than unordered_map, all the while offering a data() api which returns a pointer to the underlying values (hence flat).

When To Use

  • Keys aren't guaranteed to be unique, though as with all hashmaps, performance will degrade if there are too many collisions.
  • You cannot guarantee key linearity (ex. pointers).
  • You need to iterate contained values often.
  • You must cross an ABI boundary, and wish to return a pointer to the data (or a span).

Features

  • Has overall better performance than an equivalent unordered_map.
  • Doesn't use as much memory as unsigned_map, though it uses more memory than unordered_map.
  • Data is stored contiguously.
  • Access to underlying value buffer.

Benchmarks

Benchmarks are available here

Build

fea_unsigned_map is a header library with no dependencies other than the stl.

Use conan to install the dependencies when running the test suite.

Windows

mkdir build && cd build
cmake .. -A x64 -DFEA_UNSIGNED_MAP_TESTS=On -DFEA_UNSIGNED_MAP_BENCHMARKS=On && cmake --build .
bin\fea_unsigned_map_tests.exe

// Optionally
cmake --build . --target install

Unixes

mkdir build && cd build
cmake .. -DFEA_UNSIGNED_MAP_TESTS=On -DFEA_UNSIGNED_MAP_BENCHMARKS=On && cmake --build .
bin/fea_unsigned_map_tests

// Optionally
cmake --build . --target install

fea_unsigned_map's People

Contributors

p-groarke avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

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.