Skip to content

Add unordered_map, unordered_set, multiset, multimap #11

@AnshMNSoni

Description

@AnshMNSoni

Problem

The library has stl_map and stl_set, but is missing their hash-based (O(1) average) and multi-key variants. These are among the most used containers in C++ STL, especially in competitive programming.


Missing Containers

Container C++ Equivalent Key Feature
unordered_map std::unordered_map<K,V> Hash map, avg O(1) lookup
unordered_set std::unordered_set<T> Hash set, avg O(1) lookup
unordered_multimap std::unordered_multimap<K,V> Hash map with duplicate keys
unordered_multiset std::unordered_multiset<T> Hash set with duplicate values
multiset std::multiset<T> Sorted set allowing duplicates
multimap std::multimap<K,V> Sorted map allowing duplicate keys

Expected API (Example for unordered_map)

from pythonstl import unordered_map

um = unordered_map()
um.insert("key", 42)
print(um.find("key"))   # 42
print(um.count("key"))  # 1
um.erase("key")
print(um.size())        # 0

Checklist

  • unordered_map
  • unordered_set
  • unordered_multimap
  • unordered_multiset
  • multiset
  • multimap
  • Unit tests for each
  • Docstrings with time complexity annotations

Notes

  • unordered_map and unordered_set should be prioritized as they are the most frequently used.
  • multiset and multimap are natural extensions of the already existing stl_set and stl_map.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions