Coder Social home page Coder Social logo

novoht's Introduction

class is NoVoHT. to create an instance the constructor is:

NoVoHT(string filename, int size, int rewrite) OR NoVoHT(string filename, int size, int rewrite, float resize)

where filename is the file to write persistant version to, set this to NULL for no persistance. size is the number of slots in the hash table array. (map can overfill) rewrite is number of removes before total rewrite of file -1 here would set no rewriting

resize is the ratio at which to resize array. 2/3 means at two thirds capacity. keep in mind array size doubles by default unless you modify the source code.

standard hash table methods put(key, value) where key is string and value is int (i can change this if necessary) 0 = success -1 = didnt insert/failed -2 = insert but didnt write get(key) returns pointer to value

remove(key) removes key-value pair 0 = success -1 = didnt remove/failed >=-2 = removed but didnt rewrite

added: writeFile() as public so if wanted, one could set no rewrites and rewrite based on the client program such as with a timer so rewrite based on time rather than number of removes returns 0 if successful and -2 if fails

also, simple get functions getSize() returns number of pairs in the map getCap() returns number of buckets in the base array of the map.

Documentation:

NoVoHT(string filename, int size, int rewrite) OR NoVoHT(string filename, int size, int rewrite, float resize) filename = persistent file (empty string for no persistance) size = initial number of slots in map rewrite = number of removes before garbage collection (-1 to not rewrite based on number of removals) resize = percentage of size before size is doubled

int put(string key, string val) returns 0 if succesful -1 if it fails, and -2 if it fails to write

*string get(string key) returns pointer to string value, or NULL if not found

int remove(string key) returns 0 if succesful -1 if it fails, and -2 if it fails to write

int append(string key, string val)

writeFile() writes file. best used on a timer

novoht's People

Contributors

kjbrandstatter avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  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.