Giter Club home page Giter Club logo

containers's Introduction

Branch OSX / Linux Windows
master Build Status Build status
dev Build Status Build status

Containers

A collection of containers that I use

Disclaimer

This software is supplied "AS IS" without any warranties and support

License

The MIT license

jc::HashTable

A fast and small C++ implementation of a hash table

  • ~260 lines of code
  • Open addressing
  • Robin Hood collision resolving
  • Backward shift deletion
  • On par with Google's dense_hash_map

Benchmarks

Benchmarks Hashtable

Performance examples for jc::HashTable. See benchmark page for more stats. Timings insert_random size=8 Timings insert_random size=152

Timings get_random size=8

Timings get_random size=152

Memory get_random size=8

Memory get_random size=152

Usage

jc::HashTable

struct SPod
{
    int     i;
    float   f;
};
typedef jc::HashTable<uint32_t, SPod> hashtable_t;

uint32_t numelements    = 1000; // The maximum number of entries to store
uint32_t load_factor    = 85; // percent
uint32_t tablesize      = uint32_t(numelements / (load_factor/100.0f)); 
uint32_t sizeneeded     = hashtable_t::CalcSize(tablesize);

void* mem = malloc(sizeneeded);

hashtable_t ht;
ht.Create(numelements, mem);

SPod value = { 1, 2.0f };
ht.Put(17, value);

Spod* pval = ht.Get(17);
assert( pval->i == 1 );
assert( pval->f == 2.0f );

hashtable_t it = ht.Begin();
hashtable_t itend = ht.End();
for(; it != itend; ++it)
{
    printf("key: %u  value: %d, %f\n", *it.GetKey(), it.GetValue()->i, it.GetValue()->f);
}

ht.Erase(17);

free(mem);

containers's People

Contributors

jcash avatar mathiaswking avatar incrediblejr avatar

Watchers

James Cloos avatar Aaron Gagern 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.