Skip to content

tejas7777/BHash

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 

Repository files navigation

BHash

Ruby gem to make a bi-directional hash map. A bi-directional hash is a key, key pair hash, where the corresposnding key to a given key can be found in constant time.

Install

gem install bhash

Using BHash

Loading the gem in your Ruby script

require 'bhash'

Initialize

Initializing empty BHash

hash = BHash.new()

Initializing BHash with a Hash object

hash = BHash.new({"Dog=>"Cat","Horse"=>"Girrafe", 1=>2})

Adding keys

Add single key, key pair

hash.add("Apple","Oranges")

Add multiple key,key pairs

hash.add({"Dog=>"Cat","Horse"=>"Girrafe", 1=>2})

Find a key corresponding to a given key

hash.find("Alaska")

Delete a key, key pair

Pass either of the key from key, key to be deleted

hash.delete("Golf")

Check if a key is present

hash.present?("Mozart")

Update a key

hash.update_key(old_key,new_key)

Update corresponding key of a given key

hash.update_value(given_key,new_corresponding_key)

Printing a BHash

hash.print()

About

Ruby gem to make a bi-directional hash map.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages