Created
May 23, 2019 04:26
-
-
Save chelseatroy/7d487cbed1481c72c28b0cb75b907b3c to your computer and use it in GitHub Desktop.
Count Implementation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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