Giter Club home page Giter Club logo

cuckoohashing's Introduction

CuckooHash

The CuckooHash class implements 5 methods (including the constructor):

  • constructor(size): return an instance of the class with pre-allocated space for the given number of objects.
  • boolean set(key, value): stores the given key/value pair in the hash map. Returns a boolean value indicating success / failure of the operation.
  • get(key): return the value associated with the given key, or null if no value is set.
  • delete(key): delete the value associated with the given key, returning the value on success or null if the key has no value.
  • float load(): return a float value representing the load factor ((items in hash map)/(size of hash map)) of the data structure. Since the size of the dat structure is fixed, this should never be greater than 1.

Implementation

This specific implementation follows that of the original paper (Pugh and Rodler, 2001) except that:

  • only a single table was used, as opposed to one for each hash function, in order to keep the code as simple as possible
  • 8 hash functions were used instead of 2 to improve performance at higher load factors. This meant that when a new key/value pair was being set, first all 8 hashes were computed and the pair was placed in the first slot that was free. If all of the hashes led to collisions, the pair was placed in the slot corresponding to the first hash, and the process was repeated for the pair that was bumped out of the table.

cuckoohashing's People

Contributors

felixzhuologist avatar

Watchers

James Cloos 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.