Skip to main content

Questions tagged [hash-map]

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

50 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
8 votes
0 answers
1k views

IndexedArray Class: Uses a Dictionary Keys to Index a 2 Dimensional Array of Values

This class encapsulates a 2D Array and a Scripting Dictionary. Values are add or returned from to the Array using a Key and a ColumnIndex, e.g. ...
TinMan's user avatar
  • 4,143
7 votes
0 answers
118 views

Agent-based Immutable Map

I am in the process of removing the last few pieces of mutable state from an F#-based distributed system. Some of the remaining mutable state is a ...
Aaron M. Eshbach's user avatar
7 votes
0 answers
528 views

Bidirectional bijective hash map in C

I have this bidirectional hash map in C for dealing with bijective maps. Each key mapping consists of a primary key and a secondary key, and I can ask the data structure to give me a secondary key ...
coderodde's user avatar
  • 28.9k
6 votes
0 answers
99 views

Chapter 8 Challenge: Add employee names to a department

The boring but exciting challenge: Using a HashMap and HashSet, create a text interface to allow a user to add employee names ...
lml's user avatar
  • 61
6 votes
0 answers
1k views

Recursive conversion from ExpandoObject to Dictionary<string, object> #2

Because my original question was lacking many details, I have been advised to ask a new question. I will repeat the important parts of the original question and add examples etc to hopefully make it ...
Joelius's user avatar
  • 355
6 votes
0 answers
2k views

Decode HTML Entities in VBA using regex and dictionary

I receive HTML-encoded text that includes named and numbered entities, and I need the decoded HTML. There were just too many bad solutions for this online. I use regex pattern ...
ThunderFrame's user avatar
  • 1,959
5 votes
0 answers
436 views

HashMap exercise, Rust book Ch.8

I'm learning Rust by learning the Rust programming language book. I'm now implementing the solution for the third challenge. Using a hash map and vectors, create a text interface to allow a user to ...
afgomez's user avatar
  • 151
5 votes
0 answers
77 views

Elegant way to alter datasets with explicit filters

I would like to write a small helper to filter datasets. Each dataset is a dictionary and some filters I want to apply are common to all the datasets. That my needs, I wrote this following pattern: <...
nowox's user avatar
  • 1,099
4 votes
0 answers
106 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 ...
Cristian Buse's user avatar
4 votes
0 answers
93 views

General Purpose C Dictionary

I'm trying to create a general purpose C dictionary (as an opaque data type) capable of dynamically allocating basic types (ints, floats, strings and longs) as well as accepting void pointers to ...
user2418731's user avatar
3 votes
0 answers
249 views

Linear probing 16 hashmap elements in parallel using SIMD instrinsics

For my hashmap implementation, I'm caching hashes for each map element in an array of length NBUCKETS, where each element corresponds to an element in the hashmap. ...
gtmshrm's user avatar
  • 31
3 votes
0 answers
135 views

C# code for minimizing the sum of an array by dividing it's elements (repetition allowed) by 2 for k times

The assumption is that k is quite large as compared to no. of elements in the array and division by 2 returns ceiling of the result. Request for your review and suggestions for further improvements ...
Deepak Mishra's user avatar
3 votes
0 answers
2k views

Alternative for VLOOKUP/Index-Match in VBA

I am sharing this function I wrote with the community to provide an alternative to slow VLOOKUP and/or Index-...
rickmanalexander's user avatar
3 votes
0 answers
5k views

Ordered-by-insertion map

The main problem that I tried to tackle here was trying not to have the erase method to be \$O(n)\$. I kept two data structures: a linked-list of pairs and a map of a key and a pair containing a value ...
João Pires's user avatar
3 votes
0 answers
2k views

A map class based on an AVL tree

Here's an implementation of a class which is similar to std::map, but it's not a complete/identical implementation. I know C pretty well, but am a beginner with C++...
Paul's user avatar
  • 131
2 votes
0 answers
66 views

Directed weighted graph in C

I am working on a project that requires a directed weighted graph data structure. It looks like this: graph.h ...
coderodde's user avatar
  • 28.9k
2 votes
0 answers
75 views

Compute damages and savings for motor insurance claims

I am working on some claims data, where I have features such as The descriptions of the columns are: (A) the year of claim, (B) who's the insuring company (C) whether the vehicle is driven, (D) ...
Ravindra Rao's user avatar
2 votes
0 answers
573 views

3Sum - leetcode

Question: Given an integer array nums, return all the triplets [nums[i], nums[j], nums[k]] such that i != j, i != k, and j != k, and nums[i] + nums[j] + nums[k] == 0. Notice that the solution set ...
Joseph Gutstadt's user avatar
2 votes
0 answers
82 views

Modeling data from Excel sheets to parse to Excel sheet

Background: I have close to 50 excel files - I cannot change the data source - and I steadily get more. My task is to make sense of all that data and, lo an behold, save that as another excel file (I ...
Nacorid's user avatar
  • 121
2 votes
0 answers
71 views

Hashtable Visualizer in TypeScript

Implementation is based on the MVC design pattern, with callbacks to allow model and view to communicate with controller. Concerns: It's not ideal to have async code inside the model, i.e the model ...
L292092's user avatar
  • 419
2 votes
0 answers
39 views

Converts Pandas and Numpy into Dictionary and Converts back to original format for data split

I'm trying to refactor some code so that it does not have so much repetition to it. What I'm trying to do is create an input for a multiple channel/input neural network. The features that are being ...
machine_apprentice's user avatar
2 votes
0 answers
53 views

Linkedlist & hashmap _duplicates removal

I have implemented a LinkedList removal fo duplicates class by using HashMap. Looking forward to your reviews. Thanks. ...
Neslihan Bozer's user avatar
2 votes
0 answers
149 views

Trie to index files and search for them

Basic idea (foo and foa are filenames): ...
user227408's user avatar
2 votes
0 answers
67 views

Pythonic way to cast a dictionary into a pd.DataFrame with two columns?

I have a dictionary where for each key, a single value is stored. Say import pandas as pd dd = {'Alice': 40, 'Bob': 50, 'Charlie': 35} Now, I want to ...
Qaswed's user avatar
  • 183
2 votes
0 answers
804 views

Solution to 3Sum problem on Leetcode using HashTable

The problem of 3sum is described as: Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero....
Giang Nguyen's user avatar
2 votes
0 answers
74 views

Coding Challenge Solution - Find Number of Elements in a range in \$O(1)\$ with preprocessing

Overview This is my solution to the following Coding Challenge - Find Num of Elements in a Range in \$O(1)\$ with Preprocessing - Given an array and max element in the array, find the number of ...
Nicola Bernini's user avatar
2 votes
0 answers
47 views

Convert flat object hierarchy to json

I do work for a project currently, where the data is send to the server as application/x-www-form-urlencoded (which is bad, and it should be JSON, but unfortunately I am not able to change this one). ...
triplem's user avatar
  • 121
2 votes
0 answers
472 views

Ruby Hash to XML

I've just made this "serialization" module in Ruby that takes a hash and outputs a XML string. ...
vinibrsl's user avatar
  • 647
2 votes
0 answers
670 views

A fast integer key map in Java via a van Emde Boas tree

Introduction The following data structure is a dictionary mapping primitive int values to any value type. Basically, under the hood it is a hash table, where a ...
coderodde's user avatar
  • 28.9k
2 votes
0 answers
147 views

Spellchecker program is having issues due to vowel checking method

This program takes in a list of 275k or so words from '/usr/share/dict/words' and loads them into HashSet. It then takes in a list of 1000 words (taken from the dictionary and are scrambled (vowel ...
user131364's user avatar
2 votes
0 answers
56 views

List of lists from file

I'm writing a sub-routine in AppleScript to get text from a file and insert that text in a list of lists forming a dictionary. Text File: a:b c:d e:f Expected ...
Harrison Tran's user avatar
2 votes
0 answers
2k views

HashMap with binary search tree for chaining

My friend was asked to implement a hashtable with a binary search tree. I tried practicing it myself, and it turned out to be very verbose. I need suggestions to clean this up! ...
fluffychaos's user avatar
2 votes
0 answers
2k views

Map operation to update data | Hazelcast IMap returns clone object

I have a nested hazelcast distributed map: Map<CountryId, Map<CityCode, Map<data_key,data_value>>> where "data_key" is "population", "...
ppuskar's user avatar
  • 121
2 votes
0 answers
125 views

Universal nested get/set for trees in Python

Based on this source, I've made the following universal get / set function, to make it possible to work on OrderedDict trees for example. ...
hyperknot's user avatar
  • 215
2 votes
0 answers
1k views

Hash Table Implemented by Javascript

I recently tried to implement a simple hash table using Javascript. Could anyone help me review my implementation? ...
zhujy_8833's user avatar
2 votes
1 answer
2k views

Implementing a HashTable in Objective-C

I am trying to implement a hash table in Objective-C. I did some testing and the implementation seems to work. I am using an NSMutableArray to store linked lists ...
Yan's user avatar
  • 683
2 votes
1 answer
2k views

Java Concurrent Multimap

I've implemented a concurrent multimap that support concurrent put and remove but I'm unsure of its correctness. I would appreciate your feedback. ...
Elad Tolochinsky's user avatar
1 vote
0 answers
253 views

What’s the correct usage of volatile keyword in this Concurrent dictionary implementation?

Can I get some guidance around the usage of volatile keyword and design of the existing concurrent dictionary implementation, please. Here are a few design ...
Dhruv Sawhney's user avatar
1 vote
0 answers
79 views

Unpack a flattened hash into Hash/JSON

The following JSON ...
Samuel Vijaykumar's user avatar
1 vote
0 answers
79 views

A simple Java integer hash set - follow-up

(See the previous version.) (See the next version.) After incorporating changes in the previous post, I came up with this implementation. However, I left hashing as it is. ...
coderodde's user avatar
  • 28.9k
1 vote
0 answers
58 views

Global Dictionary Class

For a Django-Server I use several custom Error-Codes, error-titles and descriptions, possibly other fields might follow. I'm using right now a basic global dictionary. ...
Qohelet's user avatar
  • 151
1 vote
0 answers
2k views

What is the best implementation of a ignore case dictionary In C#

Imagine we have a custom dictionary class which is derived from Dictionary<string, object>. Dictionary is case-insensitive about keys and elements arrange is ...
M.H.Ahmadi's user avatar
1 vote
0 answers
46 views

regex on a log file utilizing stacks and queue's in Java

This would be for a MUD client, which has elements of a sort of telnet bot. Here, there's ...
Thufir's user avatar
  • 379
1 vote
0 answers
32 views

Simplifying decision tree when working with map which has two keys and value as a slice

Can this logic not be simplified more, the code works, but it has become too much of a spaghetti. The requirements are that there should always be one connection if possible in ...
JonB's user avatar
  • 431
1 vote
0 answers
108 views

Building maps for Dgraph integration tests in Java 8

I want to refactor this in Java to reduce my code duplication. ...
devinbost's user avatar
  • 119
1 vote
0 answers
516 views

Rust book ch 13 Closures + HashMap exercise

So the exercise is as follows: Try modifying Cacher to hold a hash map rather than a single value. The keys of the hash map will be the arg values that are passed in, and the values of the ...
Ahmed Masud's user avatar
1 vote
0 answers
450 views

Filling values for nested dictionaries

I have a text file where any name followed with sequence word is considered a dictionary. The task is to go through the keys and values of a particular dictionary, which is already identified, and see ...
user3777713's user avatar
1 vote
0 answers
484 views

java - A* search algorithm

I'm having trouble with my homework implementing A* search algorithm in java, I'm given the graph, origin and destination, I had to follow some specific tasks in the homework so the code might be a ...
John Doe's user avatar
1 vote
0 answers
705 views

constexpr hashtable string to user type

This creates something like constexpr mar<String, T> using C++14. Collision resolution is with static_assert and manually ...
Nick's user avatar
  • 1,582
1 vote
0 answers
830 views

A homemade variadic map

A bit of background: some time ago I wrote a piece of code that can be used for memoization with functions taking one parameter. Now I want to extend this to deal with functions with arbitrary number ...
463035818_is_not_a_number's user avatar