Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static hash_t myHashFunc(const void* key) {
- return (int) key;
- }
- int main() {
- // maps::OLD_ArrayMap<int, int> map = maps::OLD_ArrayMap<int, int>();
- // map.put(25, 69);
- // map.put(50, 420);
- // map.put(150, 1337);
- // // tests
- // for (maps::Node<int, int>& node : map) {
- // std::cout << "Key(" << node.mKey << ") = " << node.mVal << std::endl;
- // }
- // std::cout << "Removing 50..." << std::endl;
- // map.remove(50);
- // for (maps::Node<int, int>& node : map) {
- // std::cout << "Key(" << node.mKey << ") = " << node.mVal << std::endl;
- // }
- // std::cout << "Replacing key 25 with value 2020..." << std::endl;
- // map.put(25, 2020);
- // for (maps::Node<int, int>& node : map) {
- // std::cout << "Key(" << node.mKey << ") = " << node.mVal << std::endl;
- // }
- ArrayMap* map = new_array_map(myHashFunc);
- arraymap_put(map, (void*) 25, (void*) 69);
- arraymap_put(map, (void*) 50, (void*) 420);
- arraymap_put(map, (void*) 150, (void*) 1337);
- // tests
- for (int i = 0; i < map->m_tab_len; i++) {
- ArrayMapNode node = map->m_tab[i];
- std::cout << "Key(" << (int) node.m_key << ") = " << (int) node.m_val << std::endl;
- }
- std::cout << "Removing 50..." << std::endl;
- arraymap_remove(map, (void*) 50);
- for (int i = 0; i < map->m_tab_len; i++) {
- ArrayMapNode node = map->m_tab[i];
- std::cout << "Key(" << (int) node.m_key << ") = " << (int) node.m_val << std::endl;
- }
- std::cout << "Replacing key 25 with value 2020..." << std::endl;
- arraymap_put(map, (void*) 25, (void*) 2020);
- for (int i = 0; i < map->m_tab_len; i++) {
- ArrayMapNode node = map->m_tab[i];
- std::cout << "Key(" << (int) node.m_key << ") = " << (int) node.m_val << std::endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement