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.

learn more… | top users | synonyms (1)

4
votes
2answers
70 views

Is this the right way to implement a simple hash table in C++?

Does this look like a proper implementation of a hash table in C++? Any errors anyone can find? Thanks in advance (: ...
1
vote
0answers
25 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 ...
9
votes
3answers
1k views

Simple C# HashTable Implementation

Haven't put one of these together since college. How does this look overall? ...
2
votes
1answer
37 views

Displaying a String array in tabular format

I have an array of strings called theArray. All strings in theArray are of length 20. I wish to display this array in tabular ...
0
votes
1answer
33 views

NestedHash Class

I want to make a Ruby nested hash table class to avoid repeating ugly code and to keep my programs as true to the OOP paradigm as I can. Are there any ways to make this class definition smaller ...
1
vote
1answer
68 views

Creating a dictionary

I have a Ruby programming task. My code passes all the rspec requirements, but I am not sure if I've done it in the right way. And I'm not quite sure why I need ...
2
votes
1answer
49 views

Basic toy hashtable

I wrote a minimal implementation of a hashtable in python as an exercise. ...
4
votes
3answers
221 views

Python Hash Table Implementation

I'm attempting to implement a basic hash table in Python using only lists. Any tips would be appreciated (including better hash functions). I intend this to handle collisions with separate chaining. ...
2
votes
1answer
550 views

Convert Multivalued map to HashMap

I have a Multivalued map (javax.ws.rs.core.MultivaluedMap<String, String>) which I want to convert to regular HashMap so I got below code: ...
2
votes
1answer
114 views

Hackerrank challenge - Dictionaries and Maps in Erlang

This question is really similar to an existing one in Ruby. So the task is also the same: Day 8: Dictionaries and Maps! The problem is that on Hackerrank my solution only passes the first and last ...
-3
votes
1answer
283 views

Mapping phone numbers to names [closed]

Problem description: You are given a phone book that consists of your friend's names and their phone number. After that you will be given your friend's name as query. For each query, print the ...
4
votes
2answers
372 views

Hackerrank challenge - Dictionaries and Maps

This is a solution for the Day 8 hackerrank.com challenge. The basic idea of the challenge is to create a mapping of names to phone numbers based on the the given input, and later look up the phone ...
0
votes
2answers
52 views

Adding polynomials represented as maps

I'm using maps to represent a polynomial. The key is the exponent and the value is the coefficient : Map(exp -> coef) e.g. ...
5
votes
2answers
42 views

Refactoring if statement based on a hash key

I have to call Article.to_draft/to_archive/publish method depending on the presence of the ...
4
votes
2answers
112 views

Dictionary implementation using hash table in C

I have written the below code which loads the dictionary and checks if the given word is present or not. The implementation is using a hash table with a chained linked list. In regards to the hash ...
3
votes
2answers
216 views

HashMap or associative arrays in C

I am trying to implement an HashMap in C. I am trying to used a linked list style of interfacing to make adding and removing keys easy and efficient. Searching is ...
4
votes
0answers
20 views

Variation of the internal PHP hashtable

I'm working on a PHP extension in an attempt to learn some C. I've implemented a variation of the internal PHP hashtable, which uses a lookup table and a separate bucket table. The lookup table simply ...
6
votes
2answers
70 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
359 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
82 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
320 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 ...
2
votes
0answers
85 views

Jacob's Ladder compression [closed]

I'm currently interested in a logical decay algorithm which will need me to have the correct coordination of 3 bytes. I have 2 of them, initially. After that, I have to get 2 from the one, but in that ...
3
votes
1answer
331 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
158 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
93 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
249 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
33 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 ...
3
votes
0answers
121 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
39 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
64 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
94 views

Constructing NewsArticle objects from a database table

This class seems to be able to represent the data stored in any possible database table: ...
11
votes
3answers
2k 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
57 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
97 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
280 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 ...
4
votes
3answers
394 views

Simple cache dictionary

I decided to write a simple dictionary to use as a cache: ...
11
votes
1answer
241 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
62 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
64 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
178 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
29 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
189 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 ...
5
votes
4answers
1k 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): ...
0
votes
0answers
92 views

Custom ConcurrentHashMap for ints

I've implemented a concurrent hash map for int primitives. ...
5
votes
2answers
320 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
1k 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
106 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 ...
6
votes
2answers
485 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
48 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 ...