Questions tagged [hash-map]
A data structure that uses a hash function to map identifying values, known as keys, to their associated values
898 questions
3
votes
2
answers
356
views
Hashmap in C (with templates?)
I started implementing my own hashmap in C after taking inspiration from Git's hashmap API. As far as I know, the closest thing to templates in C are macros. I've seen that they are used in uthash or ...
9
votes
2
answers
1k
views
A simple C++ function converting the environment variables in main() to an unordered_map
I had this program:
...
7
votes
2
answers
989
views
Desperately seeking a hashing function
A recent CR exchange led me to dust off and adapt some code I'd written a few years ago. Long, long ago, when core meant ferro-magnetic memory cells, I spent an hour formulating a "simple" ...
7
votes
3
answers
1k
views
Naive attempt at implementing a dictionary in C. Stack-based and O(n)
I am a C++ programmer trying to learn C.
Please critique my C code here. I am trying to make a small "hash table" that's \$O(n)\$ lookup. But, it is stack-based and so should be no slower ...
7
votes
1
answer
248
views
Robin Hood Hash Table
The following code comes from an intrusive container library I am working on in C23. So far, it works correctly due to extensive testing and sample programs I have written with it. I have implemented ...
1
vote
2
answers
147
views
Implementation of my multidict in Python
I need a code review for my implementation of my multidict in Python.
I'm not sure that my method below is implemented the best way:
...
1
vote
1
answer
44
views
Separate Chaining Hash Table Implementation in C++
I've implemented a separate chaining hash table in C++ and would appreciate any feedback or suggestions for improvement.
Code:
...
5
votes
2
answers
1k
views
Optimized data structure mapping finite set of integers to values in C++
I'm looking for a mapping data structure, but knowing that the possible values of my keys are small numbers, I would like to trade memory for better performances (for both random access and value ...
3
votes
2
answers
178
views
Check for key in dictionary without magic value comparison
I'm using pydantic in a project to check file formatting for an object, as well as pylint for linting. Whenever I read a file with an invalid format, I want to raise an exception with a descriptive ...
-3
votes
1
answer
72
views
Multiple key swap algorithm [closed]
I have a dictionary with key - data pairs. My data comes from excel sheets. When I create the dictionary my objects are placed in order by their keys ex. 1 -> data of sheet1, 2 -> data of sheet2 ...
5
votes
1
answer
428
views
Optimizing Perfect Hash Table Implementation in C for Improved Performance
I wrote code that implements perfect hash table, according to its description in the book "Introduction to Algorithms by Thomas H Cormen", but the code does not pass time tests in contest. I ...
5
votes
0
answers
202
views
A new Dictionary for VBA
The latest version of the Dictionary class presented in this question is available in the VBA-FastDictionary repository under the latest release.
Motivation
I ...
4
votes
3
answers
311
views
Given two sparse vectors, compute their dot product
Problem Statement:
Given two sparse vectors, compute their dot product.
Implement class SparseVector:
SparseVector(nums) Initializes the object with the vector nums
dotProduct(vec) Compute the dot ...
6
votes
3
answers
725
views
Program that brute forces to find the minimum dominating set
This program solves the minimum dominating set but it takes an insanely long time to run. In case you do not know, in graph theory, a dominating set for a graph G is a subset D of its vertices, such ...
4
votes
2
answers
439
views
Map constructor utility class in Java 8
In a Java 8 project, I'm using several maps, many of which contain static or default content. In Java 9 and newer, there's the convenient Map.of() method and I want ...