{"id":19945562,"url":"https://github.com/odilson-dev/hashmap","last_synced_at":"2025-10-24T08:26:58.210Z","repository":{"id":216540436,"uuid":"741493797","full_name":"odilson-dev/hashmap","owner":"odilson-dev","description":"The Hashmap Project is an assignment from TOP's curriculum, where participants work on creating and implementing a hashmap data structure as part of their learning exercises.","archived":false,"fork":false,"pushed_at":"2024-01-12T19:19:32.000Z","size":11,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-23T20:52:43.378Z","etag":null,"topics":["data-structures","hashmap","ruby","theodinproject"],"latest_commit_sha":null,"homepage":"https://www.theodinproject.com/lessons/ruby-hashmap","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/odilson-dev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-01-10T14:09:18.000Z","updated_at":"2024-03-16T20:20:29.000Z","dependencies_parsed_at":"2024-01-12T05:25:23.831Z","dependency_job_id":"8e9d4ee3-fcd2-4fd6-93cc-53eaf6a9355e","html_url":"https://github.com/odilson-dev/hashmap","commit_stats":null,"previous_names":["odilsoncode/hashmap","odilson-dev/hashmap"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/odilson-dev%2Fhashmap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/odilson-dev%2Fhashmap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/odilson-dev%2Fhashmap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/odilson-dev%2Fhashmap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/odilson-dev","download_url":"https://codeload.github.com/odilson-dev/hashmap/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241374515,"owners_count":19952544,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["data-structures","hashmap","ruby","theodinproject"],"created_at":"2024-11-13T00:26:01.102Z","updated_at":"2025-10-24T08:26:53.173Z","avatar_url":"https://github.com/odilson-dev.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# HashMap Implementation in Ruby\n\nThis is an exercise that implements a hash map structure in the Ruby language. Done as part of [The Odin Project curriculum](https://www.theodinproject.com/lessons/ruby-hashmap).\n\nThis repository contains a comprehensive implementation of a hash map in Ruby, featuring a robust linked list for handling collisions. The implementation is designed with scalability and simplicity in mind, making it suitable for a wide range of applications.\n\n## Files Included\n\n### `linked_list.rb`\n\nThis file defines the `LinkedList` class, a fundamental component for handling collisions in the hash map. The linked list is a dynamic data structure that allows for efficient insertion and retrieval of key-value pairs. Each node in the linked list contains a key, data, and a reference to the next node.\n\n### `hashmap.rb`\n\nThe `HashMap` class is the core component of this repository, showcasing a powerful hash map implementation utilizing the linked list for managing collisions. The hash map is initialized with a fixed number of buckets (default: 16) to store key-value pairs efficiently. It provides methods for setting key-value pairs, retrieving values by key, checking for key existence, clearing all elements, and obtaining arrays of keys, values, and entries.\n\n### `node.rb`\n\nThe `Node` class defines the structure of a node in the linked list. Each node encapsulates a key, data, and a reference to the next node. This class is an integral part of the linked list and contributes to the overall functionality of the hash map.\n\n## Features\n- Collision Handling: Utilizes a linked list to manage collisions efficiently.\n- Dynamic Sizing: The number of buckets in the hash map is customizable for optimization.\n- Key-Value Operations: Provides methods for setting, getting, and checking the existence of key-value pairs.\n- Clearing Elements: Clears all elements from the hash map.\n\n## Usage Example\n\n```ruby\n# Create a new HashMap\nmy_hash_map = HashMap.new\n\n# Set key-value pairs\nmy_hash_map.set(\"name\", \"John\")\nmy_hash_map.set(\"age\", 25)\nmy_hash_map.set(\"city\", \"New York\")\n\n# Retrieve values\nputs \"Name: #{my_hash_map.get(\"name\")}\"\nputs \"Age: #{my_hash_map.get(\"age\")}\"\nputs \"City: #{my_hash_map.get(\"city\")}\"\n\n# Display all keys, values, and entries\nputs \"All Keys: #{my_hash_map.keys}\"\nputs \"All Values: #{my_hash_map.values}\"\nputs \"All Entries: #{my_hash_map.entries}\"\n\n# Returns true or false based on whether or not the key is in the hash map\nputs my_hash_map.key?(\"name\") #true\nputs my_hash_map.key?(\"age\") #true\nputs my_hash_map.key?(\"city\") #true\n\nputs my_hash_map.key?(\"hello\") #false\n\n# returns the number of stored keys in the hash map\nputs my_hash_map.length # 3\n\nmy_hash_map.remove(\"name\")\nputs my_hash_map.length # 2\nputs my_hash_map.get(\"name\") # nil\nputs my_hash_map.key?(\"name\") # false\n\np my_hash_map.keys [\"age\", \"city\"]\n\n\n# removes all entries in the hash map.\nmy_hash_map.clear\n\nputs my_hash_map.length # 0\nputs my_hash_map.keys # []\n\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fodilson-dev%2Fhashmap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fodilson-dev%2Fhashmap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fodilson-dev%2Fhashmap/lists"}