Skip to content

Instantly share code, notes, and snippets.

@chelseatroy
Created May 23, 2019 04:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chelseatroy/7d487cbed1481c72c28b0cb75b907b3c to your computer and use it in GitHub Desktop.
Save chelseatroy/7d487cbed1481c72c28b0cb75b907b3c to your computer and use it in GitHub Desktop.
Count Implementation
class Database
def initialize
@count = Hash.new(0)
@db = Hash.new()
end
# CRUD COMMANDS
def set(key, value)
@db[key] = value
@count[value] += 1
return nil
end
def get(key)
@db.fetch(key, "NULL")
end
def count(value)
@count.fetch(value, 0)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment