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
6
votes
2answers
131 views

Unicode-capable symbol table (N-way search tree with hash buckets)

As in my previous question, this module is coupled with its own testing framework. As a symbol-table for a Unicode-capable programming language interpreter, I decided to combine the 3 types of ...
6
votes
4answers
6k views

Hash table and linked list implementation in C++

I'm trying to improve my understanding of inheritance and template classes in C++ so I coded a hash table (see compilable source code below). I would be greatly appreciative of any comments on how to ...
6
votes
1answer
3k views

Remove a key from a hash table efficiently

I am trying to remove a key from a hash table, which is built using linear probing. Removing a key works fine but I know I need to rehash a portion of the table after the removal but my method down ...
7
votes
2answers
1k views

Trie key/value store implementation comparing with HashMap

I have implemented a Trie-based concurrent key/value store using hashcode similar to HashMap. It is something like, if your ...
3
votes
1answer
7k views

Hash function for strings

Implementation of a hash function in java, haven't got round to dealing with collisions yet. I tried to use good code, refactored, descriptive variable names, nice syntax. My code must be efficient ...
1
vote
1answer
1k views

Hash Map Library for any type (Void Pointers)

This is a hash map library for C that stores void* pointers with char* strings (null terminated) for keys ...
10
votes
1answer
337 views

ConcurrentDecayingHashMap<K,V>, a concurrent decaying HashMap

I wrote a wrapper for Java's ConcurrentHashMap that enables you to add a decay time to inserted values, meaning they will be automatically removed after the given ...
3
votes
2answers
2k views

Using EqualityComparer to find contained value

While searching for a method in HashSet which allows me to actually find an object in \$O(1)\$ (not just Contains, I need the ...
4
votes
1answer
44 views

Optimizing “complex” iteration over Map with auxiliary maps

This will be tough to explain. I am implementing a tool to support RFC6020. But when it comes to the Choice Statement, things get weird. For the sake of better understanding, I have to remember you a ...
10
votes
1answer
3k views

HashMap and HashSet classes for ES6

The new EcmaScript standard, ES6, contains specifications for Map and Set built-in classes. Each of these collections treats an ...
3
votes
1answer
166 views

Creating simulated items sold at a store into a hash

I am writing code that creates a hash for a store that has an item, price, and sku. The hash is inserted into an array. I also create another hash based on the sku that holds the amount of inventory ...
1
vote
1answer
85 views

Gathering metadata on files in GitHub

I am a relatively new programmer and am currently working on something with the egit GitHub client library which requires me to iterate over a bunch of values and if a condition is met, add a bunch of ...
3
votes
1answer
97 views

Constructing NewsArticle objects from a database table

This class seems to be able to represent the data stored in any possible database table: ...
13
votes
3answers
7k views

HashTable implementation in C++

I made a simple hash table and I was wondering if there was any way to increase the efficiency of search times. My table class is called Dictionary, because C# has ...
2
votes
1answer
511 views

My own implementation of an hashtable

This is my own implementation of an hashtable. I would like to receive some reviews or some feedbacks. ...
2
votes
1answer
248 views

(Y.E.S.E.J.) Yet Another Singleton with Enum in Java

I have a Java class which has to be generated only once for all the objects that I have - it is a small program. This singleton class holds a mapping of characters. I Googled stack overflow and found ...
8
votes
3answers
2k views

Initialize a hash with all 0 values based on two arrays

Given two arrays (for instance a list of people and a list of subjects), I need to initialise a Hash with all zeros for all possible combinations of these two ...
6
votes
3answers
5k views

Simple cache dictionary

I decided to write a simple dictionary to use as a cache: ...
11
votes
1answer
421 views

OOP paradigm implementation of a Dictionary data model

Here is the implementation of interface Dictionary using chained hash table class HashTableChained. Despite item 22* saying ...
4
votes
1answer
119 views

Unordered (hash) map for C

I am still working on basic data structures for C. Now I came up with a hash map: unordered_map.h: ...
3
votes
1answer
104 views

Ordered map for C using AVL tree

I was in the mood for some data structures and I decided to code up an ordered map using AVL tree. I will post only map.h and ...
3
votes
1answer
281 views

Duplicate integers in an array

Code shows duplicate values of integers in an array with indexes and the number of occurrences. Can you please critique my code and provide your thoughts on where I should improve my code? ...
1
vote
1answer
32 views

Capping values in a map while keeping one fixed

I'm working with some Clojurescript code that reacts to user input over three sliders. These sliders get stored in a map, and I need to make sure that the sum of all is <= a ...
5
votes
2answers
606 views

Find the rarest in a map

Write a method rarest that accepts a map whose keys are strings and whose values are integers as a parameter and returns the integer value that occurs the fewest times in the map. If there is a ...
6
votes
5answers
10k views

Finding the most common character in a string with a hash map

I created a method for finding the most common character in a string (using HashMap): ...
5
votes
2answers
5k views

Function that shortens a String based on a term/abbreviation mapping

I have a function that takes a description as a String and returns a shortened version of the description. The shortening is done by checking if a word matches the ...
4
votes
3answers
9k views

Most common occurrence of an int in an array

I am prepping for a junior level interview in C#. I am hoping I can get some feedback on how to improve my code to print the most common occurrence of an int in an ...
2
votes
1answer
1k views

Chained hash table implementation to store student's information

This is my implementation of a Hash Table to store information about a student. Everything seems to work as expected, but I'd like some feedback on the following: Is my style good? Is it easy to read ...
6
votes
2answers
1k views

Hash table based key/value dictionary in C++ with murmur hash function, linked list buckets in 200 LOC

hashdic.h -- suggested for direct include or copy paste to your project. ...
6
votes
1answer
65 views

Dump hash in columns

I tried to answer the question "How to print a hash in Perl, such that 3 key value pairs are printed on each line?" like this. As I got an uncommented downvote, I'd like to ask: What's wrong with/How ...
5
votes
1answer
2k views

ConcurrentHashMap Implementation

I have written a simplified version of my own MyConcurrentHashMap. I tried to make use of a Lock[] array for ...
1
vote
3answers
533 views

Faster method for loading a hash table

I'm looking to make my code faster for loading a hash table. Any pointers would be appreciated. Below are my includes, the node def and the loading code. The dictionary loaded could be any *.txt ...
4
votes
1answer
107 views

Concatenating a SoundCloud Playlist Update JSON

I am currently working on an implementation of SoundCloud for a 3rd party iOS app, and as there is no SDK anymore I am doing all my calls via Alamofire. This is what SC expects you to send in your ...
2
votes
1answer
2k views

LRU cache design using dict and doubly linked list

Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and set. get(key) - Get the value (will always be positive) of the ...
3
votes
1answer
410 views

A minimal HashTable implementation

For an assignment, I wrote a minimal HashTable implementation (it only supports additions; no deletions). To resolve collisions, it uses Linear Probing (required by the assignment). I'm looking for ...
5
votes
1answer
317 views

Hash table for Coursera's algorithms course

I implemented a hash table for Coursera's Algorithms and Design class. I am looking for feedback on coding style and other improvements. I want to practice C++ coding but I see myself drifting to C ...
2
votes
2answers
1k views

Count of words in a mutable Map

The function should get some text on input and return a map in a following format: ("word1" -> 1, "word2" -> 2 ...) The keys are words from text and the ...
3
votes
1answer
717 views

Hash table with “Time To Live” elements

Recently, I got a very interesting task: to realize the hash table that works in multi-process server in common memory, each element of which must have a TTL property. It was suggested to implement ...
3
votes
1answer
512 views

Safely storing Azure Topic clients in concurreny dictionary

I am trying to optimize the usage of TopicClients in my app. The instance is originally covered by interface and passed by IoC, so the IoC will dispose it at the end of the program life cycle. This ...
6
votes
2answers
2k views

Recursively merge dictionaries with generic types in C#

I am looking to implement a method that is capable of merging 2 dictionaries using generics. I've seen several great answers on SO already, but none handle the case of nested dictionaries. As in, what ...
2
votes
1answer
767 views

Reducing the size of JSON objects

I wrote a function to reduce the size of JSON objects that works simply by turning every associative array into an indexed one, and moving each property's name to the first row of the data array (...
1
vote
1answer
808 views

Shakespeare and dictionaries

The following snippet will return a list containing the words in all of the works of Shakespeare: ...
2
votes
2answers
88 views

Python script to read CSVs and regroup it into the data types I need

This code does the following: Read CSV file and determine sub_type based on series_desc. Turn row into dictionaries ...
6
votes
2answers
18k views

Creating a dictionary from two lists

I have working code here which takes two lists and turns them into a dictionary with the first list being the keys and the second being the values. If the keys exceed the values the value "None" will ...
1
vote
2answers
6k views

Comparing two columns in two different rows

I want to go through each line of the a .csv file and compare to see if the first field of line 1 is the same as first field of next line and so on. If it finds a match then I would like to ignore ...
6
votes
2answers
4k views

The most efficient way to merge two lists in Java

I am looking for a way to merge two files with a list of distinct words, one word per line. I have to create a new txt file that would contain all the words of the first list and all the words from ...
4
votes
2answers
440 views

Return all words which have their reverse present in a string

Problem Statement: Given a string of words return all words which have their reverse present in the string as ( (word1 , reverseword1 ) , (word2 ,reverseword2) ) Example Case: Input: Sachin ...
3
votes
1answer
2k views

Rename subkeys of nested dictionary dynamically

My nested (ordered) dictionary looks like this: ...
3
votes
3answers
7k views

Intersection of subset between two lists of dicts

I want to find the intersection of two lists of dicts. Note that equality—i.e.: what is to appear in the intersection—is given by which keys they must have equal. See the ...
2
votes
2answers
252 views

Scraper for words from Wiktionary

I wrote this code in Java using the Jaunt library. The program scrapes all words from Wiktionary from category "English_uncountable_nouns". And after save each world to text file. I am not sure that ...