Code Monkey home page Code Monkey logo

hashmap-hashset's Introduction

HashMap and HashSet JavaScript Implementation 🗺️

This project implements both HashMap and HashSet data structures in JavaScript, providing efficient ways to store and manage collections of keys or key-value pairs.

Project Goals

  • Understanding Data Structures: Implement HashMap and HashSet from scratch to gain a deeper understanding of their underlying principles and mechanisms.
  • Collision Handling: Explore and implement collision resolution techniques to handle hash collisions effectively.
  • Efficiency: Design and optimize the implementations for efficient insertion, retrieval, and deletion of elements.
  • Flexibility: Allow customization of the hash function and other parameters to adapt the data structures to different use cases.
  • Data Structure Practice: Gain practical experience in building and working with fundamental data structures in JavaScript.

Usage

  1. import the HashMap and HashSet classes from the main module.
import { HashMap, HashSet } from './main';
  1. Create instances and use the methods:
// Create a new HashMap
const myMap = new HashMap();

// Add key-value pairs
myMap.set('key1', 'value1');
myMap.set('key2', 'value2');

// Get a value
const value = myMap.get('key1'); // value = 'value1'

// Create a new HashSet
const mySet = new HashSet();

// Add elements
mySet.add('element1');
mySet.add('element2');

// Check if an element exists
const exists = mySet.has('element1'); // exists = true

Complete Example:

import { HashMap, HashSet } from './main';

// Using HashMap
const userMap = new HashMap();
userMap.set('user123', { name: 'John', age: 30 });
const userData = userMap.get('user123');
console.log(userData.name); // Output: John

// Using HashSet
const allowedRoles = new HashSet();
allowedRoles.add('admin');
allowedRoles.add('user');
const isAdmin = allowedRoles.has('admin');
console.log(isAdmin); // Output: true

Contributing

Contributions are welcome! Feel free to submit pull requests for bug fixes, improvements, or additional features.

License

This project is licensed under the MIT License.

hashmap-hashset's People

Contributors

sebastianmsz avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.