{"library":"mnemonist","title":"Mnemonist Data Structures Library","description":"Mnemonist is a comprehensive, curated collection of over 50 data structures for JavaScript and TypeScript. It includes classic structures like Heaps, Queues, and LRU Caches, alongside more specialized and exotic options such as Burkhard-Keller Trees, Bloom Filters, and Fibonacci Heaps. The library emphasizes high performance, modularity, ease of use with an API consistent with standard JavaScript objects, and full TypeScript support. The current stable version is 0.40.3, with minor updates and fixes released regularly, often multiple times a month, addressing bug fixes and type declaration improvements. Its key differentiators are the sheer breadth of its offerings, from foundational structures to highly specialized algorithms for information retrieval and metric space indexation, all while maintaining a focus on performance and robust typing. Mnemonist does not include a Graph data structure due to its typical complexity.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install mnemonist"],"cli":null},"imports":["import { Heap } from 'mnemonist/heap';","import { BloomFilter } from 'mnemonist/bloom-filter';","import { intersection } from 'mnemonist/set';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { Heap } from 'mnemonist/heap';\nimport { BloomFilter } from 'mnemonist/bloom-filter';\nimport { BiMap } from 'mnemonist/bi-map';\nimport { intersection } from 'mnemonist/set'; // Note: 'set' module name for operations since v0.40.0\n\nconsole.log('--- Using a Min-Heap ---');\nconst minHeap = new Heap<number>((a, b) => a - b); // Custom comparator for min-heap\nminHeap.push(5);\nminHeap.push(2);\nminHeap.push(8);\nconsole.log('Heap size:', minHeap.size); // Expected: 3\nconsole.log('Min element:', minHeap.pop()); // Expected: 2\nconsole.log('Min element after pop:', minHeap.pop()); // Expected: 5\n\nconsole.log('\\n--- Using a Bloom Filter ---');\nconst filter = new BloomFilter(100, 3); // 100 bits, 3 hash functions\nfilter.add('apple');\nfilter.add('banana');\nconsole.log('Contains \"apple\":', filter.has('apple')); // Expected: true\nconsole.log('Contains \"orange\":', filter.has('orange')); // Expected: false (or very likely false)\n\nconsole.log('\\n--- Using a BiMap ---');\nconst biMap = new BiMap<string, number>();\nbiMap.set('one', 1);\nbiMap.set('two', 2);\nconsole.log('Value for \"one\":', biMap.get('one')); // Expected: 1\nconsole.log('Key for 2 via inverse map:', biMap.inverse.get(2)); // Expected: \"two\"\nconsole.log('Has \"three\":', biMap.has('three')); // Expected: false\n\nconsole.log('\\n--- Using Set Operations ---');\nconst setA = new Set([1, 2, 3]);\nconst setB = new Set([2, 3, 4]);\nconst commonElements = intersection(setA, setB);\nconsole.log('Intersection of {1,2,3} and {2,3,4}:', Array.from(commonElements)); // Expected: [2, 3]","lang":"typescript","description":"This quickstart demonstrates the instantiation and basic usage of a Min-Heap, a Bloom Filter, a BiMap, and a set intersection operation, showcasing common patterns for importing and interacting with Mnemonist data structures.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}