The Stack Overflow podcast is back! Listen to an interview with our new CEO.

Questions tagged [hash-table]

A hash table is a data structure used to implement an associative array (a structure that can map keys to values). It uses a "hash function" to compute an index into an array from which the value can be found.

Filter by
Sorted by
Tagged with
4
votes
3answers
996 views

Build a dictionary based on split string

I've written a simple script that takes a string filled with brackets and strings and builds them to a dictionary. Example Input: ...
2
votes
1answer
1k views

Denormalizing an OrderedDict to CSV

Cross post from stackoverflow, as suggested. I have an ordereddict, and I need to store it in CSV file. Input: ...
3
votes
2answers
826 views

Generating a table of differences between two dictionaries

...
0
votes
2answers
129 views
2
votes
2answers
2k views

Restructuring nested maps

I am in the process of making an assembler and one of the needed steps is actually getting the opcode from a table. However, the instruction set I'm working on has a handful of different addressing ...
1
vote
2answers
5k views

Add 100 to all values in nested dictionary

I want to change all values in a multidimensional dictionary. I have written this line of code, which does what I want it to do and I am trying to find out if this is the optimal way or just some ...
2
votes
2answers
1k views

Dictionary foreach loop with multiple occurences

A little look on what are Dictionaries: dictWordCounter<string, int> dictWordPercent<string, double> topTwentySeven<string, double> ...
5
votes
2answers
25k views

Convert a string into a dictionary

I have a string like "food | dairy | milk". The string may consist of more or less words. How do I turn it into a dictionary ...
2
votes
2answers
1k views

Inverse mapping of a dictionary

For the below question picked from here: Write make_inverse_dict(d) that returns a new dictionary with the 'inverse' mapping. The 'inverse' mapping of a ...
3
votes
0answers
993 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++...
4
votes
1answer
156 views

Numerate every item in dict

I have a .json file with a complex structure: dict in a dict, it has no constant structure and is dynamically changed. The goal is to make new dict where the keys are numbers of hierarchy and values ...
4
votes
1answer
213 views

Self Implemented Hash Map Performance

I have written two hash map implementations, one that stores Vertices and one that stores self implemented vectors of Edges. They are all fully functioning, however in my application they are quite ...
5
votes
2answers
1k views

Forming a dictionary where all values are only conditionally set [closed]

I have lots of dictionary keys with conditional values, ternary in this case: ...
10
votes
2answers
4k views

Checking for any character common to two strings — Go is 50× slower than Python

I decided to learn Go, knowing Python. My approach is by solving easy problems like this one: You are given two strings, A and B. Find if there is a substring that appears in both A and B. ...
1
vote
2answers
85 views

Data loading Hash Map

I'm trying to improve my code's performance, and I've found an area where the execution time is being significantly increased. I've had a look through the code but I can't see how I can improve it. <...
1
vote
1answer
2k views

Reading two csv files as dictionaries with differing key definitions

My script reads two .csv files and generates one dictionary per .csv file. ...
4
votes
3answers
55k views

Check for null/empty in dictionary

I am doing the following about 10 times with other strings, so the code is duplicated. How can I refactor this? queryWhere is a ...
2
votes
0answers
1k 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", "...
4
votes
1answer
183 views

String find and replace method optimization

I am trying to find a specific header string from different Maps (LEDES1998Bheaders, LEDES98BIheaders and ...
1
vote
1answer
796 views

Reordering OrderedDict

Goal: create a new OrderedDict instance's keys in such way that keys in the specified order list appear first. If some keys in order list are not present in ...
8
votes
1answer
29k views

A dictionary that allows multiple keys for one value

I'm trying to learn to program on my own with the help of books and the Internet and thought I'd start a project (a sub-project for a project). I want to build a dictionary that allows multiple keys ...
29
votes
0answers
889 views

Making a generic NSMapTable replacement written in Swift thread-safe

This is a follow-up to this question. While discussing some details about the code I posted there, I came upon a problem with thread-safety. After searching and trying different things, I reached a ...
7
votes
2answers
2k views

Generic NSMapTable replacement written in Swift

This is my attempt at writing a generic NSMapTable with weak keys and strong values (after your feedback I'll be trying to write Strong-Key/Weak-Value and Weak-Key/...
9
votes
2answers
12k views

Convert a list of dictionaries to a dictionary of dictionaries

I need to convert a list of dictionaries to a dictionary of dictionaries, with a particular item as the new key. This is the way I'm currently doing it: ...
7
votes
2answers
27k views

Simple string hashing algorithm implementation

I thought of a simple way to hash a string. By taking the ASCII decimal value of each character, multiplying it by 10, and adding all of the values computed together for each character in a string. Is ...
3
votes
1answer
112 views

Haskell requires more memory than Python when I read map from file. Why?

I have this simple code in Python: ...
6
votes
2answers
4k views

“Invert” a JavaScript object hash whose values are arrays to produce a new object hash with keys as the elements of those original value vectors

Background lodash and underscore have an invert function that takes an object hash and converts it to a new one, which has keys as the input object's values and ...
0
votes
1answer
109 views

log(n) “sort by value” Map<K, V>?

I've read so much arguing about "sort by value maps". Well, I wrote the following log(n) sort by value Map . And, by the way, a real Map , does not allow duplicate keys. Many of the maps I googled ...
1
vote
1answer
41 views

Search strings within a list from strings within a dictionary with the least complexity

I have the following input: newValue = [['men', 'John Doe,Chris perry'], ['women', 'Mary,Anne,Lita']] - list within list ...
4
votes
2answers
303 views

Data Persistence

I was wondering if I could get some feedback on the library I created to persist data online. JitterPushDemo.java ...
3
votes
1answer
448 views

An intrusive chained Hash Table

I was interested in experimenting with some intrusive versions of common data structures, so I've written this simple chained hash-table using the approach: ...
2
votes
0answers
116 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. ...
5
votes
2answers
3k views

Simple Chained HashMap

I am very inexperienced at C++. I wrote a Hash Map which uses chaining for collision resolution. I intentionally did not use smart-pointers, as the objective of this was to learn and showcase. I ...
24
votes
2answers
1k views

Mapping arbitrary Int values to a linear index space

This is part of a growing "primitive" tools collection here on github, and is the initial use-case for the IntArray for review here. Often, when processing data, you encounter unique values that you ...
0
votes
4answers
6k views

Finding all integers in an array with odd occurrence

I am doing an interview exercise problem from here. The problem is to find "all numbers that occurred an odd-number of times in an array". Here is my high level psuedo code thinking: Construct a ...
3
votes
2answers
1k views

Thread Safe Objects in CSharp - ConcurrentDictionary

I'm using ConcurrentDictionary to hold the records.. I'm reading files from the local system in parallel, to speed up the process. Sample 1: ...
4
votes
1answer
1k views

Dictionary with restricted keys

I'm currently building some software that works with systemd unit files, and I've been trying to improve how we construct the unit files. This is all running in Python 3.4 This first block is the ...
8
votes
3answers
12k views

Replace keys in values with key->values from same dictionary

I have a dictionary whose values may contain keys that are already in the dictionary. What we are actually talking about are parameters. Sometimes a parameter is defined by a number plus another ...
2
votes
1answer
2k views

LRU Cache Design using LinkedHashMap

This is a follow-on qestion from: LRU cache design Revised Implementation ...
6
votes
2answers
1k views

Optimizing this method (HashSet.RemoveWhere performance issue)

I have the following method: ...
10
votes
1answer
208 views

BiDirectional Dictionary (and its Mutable friend can come too)

I've attempted to implement a 1-to-1 dictionary in Objective-C. I'm probably missing some convenient methods that one might commonly want to use. These are both declared in the same ...
0
votes
1answer
51 views

Simplifying the code with same list comprehensions [closed]

I have such method where: primary_images is dict, additional is ...
2
votes
1answer
5k views

Hash table with double hashing

I writing a hash table with double hashing. This code works ONLY with ASCII text files and finding the number of occurrences of each word in input file! Please point out mistakes and shortcomings. <...
2
votes
1answer
62 views

Use of dictionary for file-saving function

I have the following function: ...
6
votes
2answers
522 views

VSTO Write Dictionary To Range Extension Method

I was hoping to receive some criticism on this block of code. I wrote it to write the contents of a dictionary to excel range in VSTO. It works well. I am interested to see how people could improve it....
1
vote
1answer
217 views

Filtering stocks by dividend yield

I have a dict of stock tickers (KEY) and a data point (VALUE; e.g. dividend yield). I want to know which tickers have a value between a specified min and max value. Given ...
5
votes
3answers
3k views

Optimize huge text file search

I have several huge 100MB text files that I need to scan through to pick out certain frame numbers which relate to a specific log packet of interest. My plan was to scan for these frame numbers and ...
4
votes
1answer
4k views

Hashing a struct in C

I'm trying to learn how chained hashing works, but can't get any further than this. I think hashing works, but after finishing this little program, someone told me that what I have created so far has ...
1
vote
1answer
1k views

Handling overwriting of unique Dictionary values

I am working in C# to write a scheduling application for operations in a factory. I have a custom class Workday, with properties to represent a ...
2
votes
0answers
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? ...