{"id":25490179,"url":"https://github.com/fix2015/structure_set","last_synced_at":"2025-11-08T12:30:35.010Z","repository":{"id":273081815,"uuid":"918655626","full_name":"fix2015/structure_set","owner":"fix2015","description":"A simple implementation of the **Set** data structure in JavaScript. This repository demonstrates how to create a set class with essential methods and explains its functionality with practical examples.  ","archived":false,"fork":false,"pushed_at":"2025-01-18T14:12:11.000Z","size":5,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-18T15:24:04.546Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/fix2015.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":"2025-01-18T14:10:32.000Z","updated_at":"2025-01-18T14:41:20.000Z","dependencies_parsed_at":"2025-01-18T15:34:10.807Z","dependency_job_id":null,"html_url":"https://github.com/fix2015/structure_set","commit_stats":null,"previous_names":["fix2015/structure_set"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fix2015%2Fstructure_set","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fix2015%2Fstructure_set/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fix2015%2Fstructure_set/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fix2015%2Fstructure_set/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fix2015","download_url":"https://codeload.github.com/fix2015/structure_set/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239552865,"owners_count":19658003,"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":[],"created_at":"2025-02-18T21:27:26.786Z","updated_at":"2025-11-08T12:30:34.944Z","avatar_url":"https://github.com/fix2015.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Set Data Structure in JavaScript 🚀  \n\nA simple implementation of the **Set** data structure in JavaScript. This repository demonstrates how to create a set class with essential methods and explains its functionality with practical examples.  \n\n---\n\n## What is a Set?  \nA **Set** is a collection of unique elements, meaning no duplicates are allowed. It is an unordered data structure that allows efficient membership tests, additions, and deletions. Sets are often used when you need to ensure that no duplicates exist in a collection.  \n\n---\n\n## Features  \n- **Add**: Add a new element to the set.  \n- **Delete**: Remove an element from the set.  \n- **Has**: Check if an element exists in the set.  \n- **Size**: Get the number of elements in the set.  \n- **Clear**: Remove all elements from the set.  \n\n---\n\n## Code Implementation  \n\nHere’s the JavaScript implementation of the set:  \n\n```javascript\nclass Set {\n    constructor() {\n        this.items = {}; // Store elements as object keys\n    }\n\n    // Add an element to the set\n    add(element) {\n        if (!this.has(element)) {\n            this.items[element] = element;\n        }\n    }\n\n    // Remove an element from the set\n    delete(element) {\n        if (this.has(element)) {\n            delete this.items[element];\n        }\n    }\n\n    // Check if an element exists in the set\n    has(element) {\n        return this.items.hasOwnProperty(element);\n    }\n\n    // Get the size of the set\n    size() {\n        return Object.keys(this.items).length;\n    }\n\n    // Clear all elements from the set\n    clear() {\n        this.items = {};\n    }\n}\n```\n\n---\n\n## Example Usage  \n\n```javascript\n// Initialize the set\nconst set = new Set();\n\n// Add elements to the set\nset.add(1);\nset.add(2);\nset.add(3);\n\n// Check if an element exists\nconsole.log(set.has(2)); // Output: true\nconsole.log(set.has(4)); // Output: false\n\n// Get the size of the set\nconsole.log(set.size()); // Output: 3\n\n// Remove an element from the set\nset.delete(2);\nconsole.log(set.has(2)); // Output: false\n\n// Clear the set\nset.clear();\nconsole.log(set.size()); // Output: 0\n```\n\n---\n\n## Real-World Applications  \n1. **Removing Duplicates**: Ensuring unique elements in collections such as arrays.  \n2. **Membership Testing**: Efficiently checking if an element exists in a collection.  \n3. **Set Operations**: Performing union, intersection, and difference between sets.  \n4. **Data Validation**: Ensuring that data doesn't contain duplicates before processing.  \n\n---\n\n## TikTok Tutorial 🎥  \nWant to see a quick tutorial on how to build this? Check out this TikTok video:  \n[]()  \n\n---\n\n## How to Run the Code  \n1. Clone the repository:  \n   ```bash\n   git clone https://github.com/fix2015/structure_set\n   cd structure_set\n   ```\n2. Open the file `index.js` in your favorite code editor.  \n3. Run the file using Node.js:  \n   ```bash\n   node index.js\n   ```\n\n---\n\n## Contributing  \nContributions are welcome! If you have suggestions or want to add new features, feel free to create a pull request.  \n\n---\n\n## License  \nThis project is licensed under the MIT License.  \n\n---\n\n## Connect with Me:\n- [LinkedIn - Vitalii Semianchuk](https://www.linkedin.com/in/vitalii-semianchuk-9812a786/)\n- [Telegram - @jsmentorfree](https://t.me/jsmentorfree) - We do a lot of free teaching on this channel! Join us to learn and grow in web development.\n- [Tiktok - @jsmentoring](https://www.tiktok.com/@jsmentoring) Everyday new videos\n- [Youtube - @jsmentor-uk](https://www.youtube.com/@jsmentor-uk) Mentor live streams\n- [Dev.to - fix2015](https://dev.to/fix2015) Javascript featured, live, experience but about Set\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffix2015%2Fstructure_set","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffix2015%2Fstructure_set","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffix2015%2Fstructure_set/lists"}