Project

bhash

0.0
No commit activity in last 3 years
No release in over 3 years
Creates Bidirectional hash with key-to-key pair.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

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()