Questions tagged [hash-map]

A data structure that uses a hash function to map identifying values, known as keys, to their associated values

Filter by
Sorted by
Tagged with
-2 votes
0 answers
17 views

HashTable C implementation

Someone to help me and tell me if my work is correct: hashtable_init: Initializes the table with a size and a hash function. hashtable_del: Frees table memory, including elements and their data. ...
AKEO's user avatar
  • 1
3 votes
1 answer
81 views

Simple hash table written in C with REPL

This is a simple hash table I've written in C. It is a closed-addressing hash table with TABLE_SIZE number of buckets. The hash ...
Amir reza Riahi's user avatar
2 votes
2 answers
73 views

Dictionary additional function implementations

I've written a utility class BetterDict to help me on some of my other projects. I've implemented the &, ...
Linny's user avatar
  • 9,989
5 votes
2 answers
730 views

Fast unpack of SAM flag bitfield to named symbols

...
Crispy13's user avatar
  • 153
1 vote
1 answer
76 views

Implemented a basic dictionary in python using lists as linked list and murmur hash as a hash function

...
piepi's user avatar
  • 823
5 votes
2 answers
182 views

C# console app that computes the Jaccard Index

So I wrote a basic C# console application that computes the Jaccard Index. This has its applications in cybersecurity and machine learning. Given two sets X and Y, the basic formula is: $$ J(X, Y) = \...
Aleksey's user avatar
  • 153
0 votes
1 answer
68 views

An immutable class that contains Dictionary properties and needs a distinct hash code based on those Dictionaries

I have a Job class that represents jobs in a manufacturing system. The idea is that a job requires some quantity of certain materials, and it outputs some quantity ...
J.K.'s user avatar
  • 11
4 votes
1 answer
155 views

Set implementation

I believe reinventing the wheel is in fact a good learning exercise. How can I improve my Set implementation without just copying ...
Sergey's user avatar
  • 401
2 votes
3 answers
219 views

A hierarchical dictionary for dotnet

Is there an existing class in .Net for representing and querying hierarchical data; i.e. providing methods which allow you to test whether one item is an ancestor or descendant of another, or to ...
JohnLBevan's user avatar
  • 1,409
3 votes
2 answers
126 views

Covid Data Base Hash Map in C++

This is a follow up question to Date Checking in C++ I have these two function prototypes: void CovidDB::add_covid_data(std::string const COVID_FILE) ...
I_throw_but_dont_catch's user avatar
0 votes
2 answers
60 views

Checking which programs are used for scripting

I have a directory where there are some script files, some binary files, and some subdirectories. I have tried to write a program which gets names of all files in directory, and excludes if they are ...
rnso's user avatar
  • 266
4 votes
1 answer
116 views

Find the longest palindromic subsequence - Using a hashmap in Rust

This is a leetcode question which I wanted to solve using Rust as I'm learning Rust at the moment. I would appreciate some feedback on how to write it idiomatically. Link to the question: https://...
bluprince13's user avatar
5 votes
2 answers
1k views

SHA-256 Hash with a short string length in javascript

I think I've found a way to somewhat "compress" the length of a SHA-256 hash. I am doing some addition, so I wanted to know whether an approach like this is secure or not. ...
rfl890's user avatar
  • 101
4 votes
3 answers
156 views

quadratic probing hashmap and its time efficiency

I am writing small a hashmap library (not full featured yet) but I have some questions about the algorithm I wrote, the formula I hope I got right from wikipedia and general things. Measured ~14.3 ...
mortytheshorty's user avatar
2 votes
1 answer
45 views

Remove inputted keys separated by spaces from map and output the resulting map, including alias recognition

I'm looking to integrate Kotlin idioms (including code style) and maybe better performance. I wonder if there's a better way to do line 17 (the str.split(' ') one). ...
Aaron Liu's user avatar
  • 131
5 votes
1 answer
590 views

Merge multiple map with java stream api

I am trying to merge multiple map with Java stream API. The reqiurements like ... this method can receive multiple map, does not care hot many of it support 2 merge method: intersection, union if key ...
Juneyoung Oh's user avatar
3 votes
2 answers
127 views

Sort a dict by keys, assuming keys are orderable

I found a suspicious code snipped in an existing project in which I am involved as a developer. The code sorts a dict by its keys, so that if iterated over the dict,...
Looser User's user avatar
7 votes
4 answers
1k views

Calculate average values for each day of the week for each Meter

I have a program with these two methods. One method to import a set of data from a CSV within the given time period and store them in a dictionary. Here the data in CSV file is stored in following ...
HARINDA VITHANA's user avatar
4 votes
1 answer
2k views

Merge two dictionaries

This function merges two dictionaries, using the value from the later dictionary to resolve conflicts. I have 5 tests that the program passes successfully: ...
alorl's user avatar
  • 41
3 votes
3 answers
421 views

VBA Very Slow Performance using objects with scripting dictionary

I have a simple code that loops through a text file to fix a few things in it and I use mostly dictionaries to find and handle the adjustment. However, with larger files (about 30K lines) it seems to ...
KE_1234's user avatar
  • 31
3 votes
1 answer
201 views

C void* Generic Hash Table

Some time ago I tried to make a generic linked list in pure C (no external libraries, only the C standard library) using void*s here. Building on top of that and ...
404 Name Not Found's user avatar
3 votes
2 answers
1k views

Implementation of Hash Function in C language

I'm new to programming. and I'm learning a C language. Currently working on Harvard's CS50 problem set (this one: https://cs50.harvard.edu/x/2022/psets/5/speller/). In that problem, they want us to ...
Kevinkun's user avatar
  • 133
4 votes
3 answers
1k views

Switch case on an enum to return a specific mapped object from IMapper

I have an ever growing switch case statement I plan on adding 3 more case statements to. Given an int, compare it to an enum, and call ...
Luminous's user avatar
  • 143
0 votes
1 answer
46 views

Count occurrence of elements in map during creation

This code works, but it's so ugly, so I was hesitant to put it on display. There must be a nicer/easier way to achieve this. The main issue is to count each unique occurrence during runtime when the ...
JonB's user avatar
  • 431
6 votes
1 answer
186 views

Creating a Dictionary<string,string> to generate the most frequent continuations (without Linq)

Main is added to compare the expected result with the result of the function, the war field is GetMostFrequentNextWords. What ...
Sheeba334's user avatar
2 votes
1 answer
105 views

Write a function that takes a list of dicts and combine them

There is an exercise in the book Python Workout: 50 Ten-minute Exercises that asks to write a function to do the following: Write a function that takes a list of dicts and returns a single dict that ...
Mathemagician's user avatar
2 votes
1 answer
181 views

Finger Exercise: Update book cipher by creating new book

I'm working my way through the finger exercises in John Guttag's book Introduction to Python Programming, third edition. The following finger exercise on page 143 describes encryption/decryption with ...
Wolric's user avatar
  • 123
3 votes
1 answer
47 views

Optimizing code for this function that filters a JSON file

I made a function that turns all child from a JSON file to parents (or brothers?). It adds the parent name to the key, so there are no duplicates. It works ok, but I would like to ask if there are ...
Albert's user avatar
  • 31
1 vote
2 answers
138 views

Parse list of UserPrincipal objects into custom class

I'm wondering how I could optimize this method that takes in a list of UserPrincipal objects, filters them by Regex and inserts the new class instance into a list. It takes 4 to 5 seconds for an input ...
mvi2110's user avatar
  • 11
3 votes
1 answer
94 views

Multiway map in C++

I recently had the problem that I wanted a hashmap where there would be a variable amount of distinct classes which each could be used to look up each other. I couldn't find any implementation online ...
gurkensaas's user avatar
0 votes
2 answers
108 views

Create all words that correspond to a telephone digit sequence

I wrote a terrible function to map E.161 keys to letter strings. I think the logic could be simplified using a recursive function; however I have never been good at recursive methods. Any suggestions ...
KellCOMnet's user avatar
1 vote
3 answers
142 views

Caesar cipher - Encode text from external file using HashMap Java

This is one of my school assignments and I just wanted to ask if there are some obvious mistakes or things I could maybe improve in this code. Thank you for any suggestions. ...
Almezj's user avatar
  • 11
1 vote
2 answers
143 views

Implementation of Hashtable in C99

I tried implementing a general purpose hashtable in C99. The basic structure is I have a huge array of hashtable entries and each entry is the entry point to a doubly linked list so that in case there ...
Jaysmito Mukherjee's user avatar
4 votes
1 answer
1k views

Transliterate between Cyrillic and Latin scripts

I want to get a code review on the following transliteration code. I wrote it because there were some libraries that I have tried and they were specifically failing with the name "Yuliya" ...
nop's user avatar
  • 719
2 votes
1 answer
69 views

Implementation of JSON schem parser to extract some attributes

I have three different types of schema possibilities as below: ...
ParthS007's user avatar
  • 197
2 votes
1 answer
42 views

API request into a dictionary

I have the code below which currently pulls pricing data for Ethereum from CoinGecko API. From this request I am building a dictionary that contains the pieces of information and returning it to be ...
OrcaDrive's user avatar
3 votes
1 answer
89 views

Hashtable solution to 2 sum

...
Aaryan Tiwary's user avatar
2 votes
1 answer
71 views

Processing charge current error messages with HashMap<>

I have certain error states that I am displaying in my Android TextView but only one message is displayed at a time and if all values are set to 0, no message is displayed. So, I check all the values ...
Dylon Jaynes's user avatar
2 votes
1 answer
169 views

Finding anagram groups using hashing and mapping the alphabet to random numbers

I was solving Group Anagram problem in leetcode. Link for the problem https://leetcode.com/problems/group-anagrams/ Below is the code which I wrote ...
susil95's user avatar
  • 287
3 votes
1 answer
53 views

Implementation of building nested dictionary from list

I have a value test-1 and a list of keys as below: ...
ParthS007's user avatar
  • 197
2 votes
1 answer
127 views

Hash table C implementation - Separate Chaining

I've written a C implementation of a hashmap of strings including the basic operations and a strategy for handling hash collisons. Additionally, I've included some tests, specifically for cases ...
Joe Boyle's user avatar
  • 137
6 votes
2 answers
676 views

Codeforces #806 Problem D: Double Strings

I tried solving the following problem by following the suggested approach to solving the problem in the problem tutorial. However, the online judge still says my solution exceeds the time limit. Is ...
Sam's user avatar
  • 61
6 votes
1 answer
424 views

Fastest function to `Remove Duplicate Lines` per each cell

The below function is used to Remove Duplicate Lines per each cell. It works without problem, but it is slow with a range of only one column and 17k rows. Actually, ...
Leedo's user avatar
  • 275
0 votes
1 answer
123 views

LeetCode - LRU Cache by rodde

I have solved this LeetCode problem. Depending (perhaps) on the server load, I once scored the following performance figures: My code follows: ...
coderodde's user avatar
  • 27k
1 vote
2 answers
261 views

My LRU Cache implementation in Java

...
learner's user avatar
  • 11
1 vote
2 answers
61 views

Shortest way possible to generate javascript string from a large array of values to A, B, C and n others

I have an array of values containing names, e.g. let members = [{id: 1, name: 'Tyler'}, {id: 2, name: 'John'}, {id: 3, name: 'Dayo'}, ..., {id: 7, name: 'George'] ...
Salman Malik's user avatar
1 vote
1 answer
120 views

Minimum number of swaps to sort a array, but swaps only allowed with elements 2 apart

I wanted to solve a problem where I sort an array of any size and return the minimum number of swaps. The explanation for the distance 2 is that I choose 3 neighboring elements ABC and then swap them ...
programmerNoob1234's user avatar
0 votes
1 answer
178 views

Sorting Dictionary in a lexicographical order and applying MD5 encryption

I'm sorting a Dictionary in a lexicographical order and applying MD5 encryption. I would like to wrap the sorting somewhere inside the encryption method or so. Official Java example - here Docs <...
nop's user avatar
  • 719
2 votes
2 answers
854 views

C++ Hash table, Hash function, benchmark vs std::unordered_set and std::hash

I wrote my own hash function and my own hash table. My hash function seems to work surprisingly well! Feel free to comment anything! Hash function: ...
frozenca's user avatar
  • 1,693
4 votes
1 answer
167 views

Langton's Ant cellular automaton in Java

I made a couple of little games and cellular automata in Java. For every new 'game', I used the same code as a base, except for the game logic of course. With every iteration of me customizing my ...
plankins's user avatar

1
2 3 4 5
19