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 (3)

2
votes
1answer
40 views

Use of dictionary for file-saving function

I have the following function: ...
5
votes
2answers
38 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 ...
1
vote
1answer
31 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
140 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 ...
3
votes
1answer
42 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
41 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 ...
1
vote
0answers
41 views

Hash Table Implemented by Javascript

I recently tried to implement a simple hash table using Javascript. Could anyone help me review my implementation? ...
1
vote
2answers
87 views

Counting a cycle

An interview question I got - Each element of an int array points to the another element, eventually creating a cycle. Starting at ...
2
votes
1answer
50 views

Iterating and fetching values from dictionary

Here is my dictionary: c_result1 = {"1": {"time": "89.46%"}, "2": {"date": "10.54%"}} c_result2 = {"1": {"money": "89.46%"}, "2": {"finance": "10.54%"}} I want ...
3
votes
2answers
66 views

Ruby hashes of status counts

I have a method that takes a model object, reads through its children and returns a hash of status counts. It should only return a count on a status if one exists. This method works, but I was ...
0
votes
1answer
47 views

A double mapped cache with WeakReferences for second key type

I needed a way to cache a large number of objects with two different types of keys. In my case: A String key represents my object in a serialized form. This way ...
1
vote
1answer
67 views

Determining the existence of string Intersections

Problem: Given 2 strings, consider all the substrings within them of length len. Len will be 1 or more. Returns true if there are any such substrings which appear in both strings. Compute ...
1
vote
1answer
54 views

Getting key-value from Object in Java

This takes a collection of Objects from JavaScript and puts them into a Java project. How can I improve this code? What's the best solution? ...
4
votes
2answers
154 views

Map String to list of string

Input: String : Title; List Tags Problem statement: Need to map title to tags, e.g. title is "china man japan beijing bell" and tags are ...
4
votes
1answer
68 views

Follow-up 2 to Morse Code String

This is my second follow-up. Major changes made: Use a Map instead of an enum for the Morse Characters Added ...
8
votes
3answers
189 views

Recursive Insertion in Hash Table (Linear Probing)

I was practicing implementing a hash function. I tried to use linear probing to insert in hash table. The insertion is working alright but I am not satisfied with the recursion. It doesn't feel like ...
4
votes
0answers
43 views

Finding Facebook Friends on app, and not on app

This code gets all of a user's Facebook friends who use our app and returns a dictionary with keys that are their id's in our database and values that are a default connection level. The code should ...
0
votes
2answers
46 views

Split a Map into sublists

I may get a Map of many many items that needs to be requested to an API. In order to improve performance, I thought about splitting that list into smaller ...
0
votes
4answers
70 views

Merge two dict in separate list by id

I have following data structure >>> a = [{'id': 1, 'name': 'a'}, {'id': 2, 'name': 'b'}] >>> b = [{'id': 1, 'age': 12}, {'id': 2, 'age': 21}] I ...
3
votes
1answer
51 views

Mapping yielding lots of warnings in use

Recently, I wrote a C header file that defines a new type called HashMap that allows for the storage of key/value pairs. I am just learning about the wonders of ...
6
votes
2answers
240 views

HashTable implementation

I have been trying to implement the Hash Table function in Java and here is what I came up with. I would just like to get an opinion on this work. Would there be a better way or any improvement to ...
5
votes
2answers
98 views

Hash Binary Tree Map

I made a map based on a binary tree ordered by hashcodes, with collisions fixed with equals(). Are there any improvements I could make? ...
5
votes
1answer
74 views

Regex matching keys in a Dictionary

I have extended this class http://wiki.unity3d.com/index.php/CSharpMessenger_Extended to accept strings containing wildcards as eventTypes, therefore I am able to ...
1
vote
1answer
43 views

Spatial hash triangles from multiple assets

I am implementing the spatial hashing algorithm described in Optimized Spatial Hashing for Collision Detection of Deformable Objects with a few adjustments, the largest one being that each bucket in ...
3
votes
0answers
35 views

Weeding out triangles for triangle-triangle collision detection using a spatial hash

I am implementing a multi-phase collision detection system whose final collision check is checking the triangles of one shape against those of another. As the number of triangle-triangle comparisons ...
3
votes
1answer
53 views

Finding average word length in a given year

I have written a function which takes the year in question and words as a data which is a dictionary that maps words to the list of year/count. Now I am wondering how I can improve the code that I ...
10
votes
4answers
534 views

Strategy pattern - design hash table

My programming skill has gotten rusty, so I would like to elicit constructive criticism that can make me write code better. I know the standard design is to use templates, and even obtain the hash ...
2
votes
2answers
222 views

Swift complexities with Dictionary

I have been trying to learn the various aspects of the languages I know so far to do the Daily Challenges in reddit (/r/DailyProgrammer). The one which I am working on just now asks for an ...
1
vote
1answer
86 views

Flattening a HashMap of (String → ArrayList) to an ArrayList

I have one HashMap<String, ArrayList<String>> and I want to concatenate a key with every item in its ArrayList. ...
-1
votes
2answers
79 views

Sorting array with respect to two properties

I'm sorting with respect to Width and Length. However, Width has the significance ...
5
votes
1answer
71 views

Dictionary Key look up with variable length inputs

I am decoding GS1 barcodes and need to match up application identifiers with relevant data about them. ...
4
votes
2answers
89 views

Convert Object Keys according to Table/Map object

I have implemented a recursive function that converts an object's keys according to another lookup table/map. You are able to convert back and forth using the 3rd ...
2
votes
2answers
85 views

Make a dict class from scratch in Python

Here's the API my teacher assigned: and here is what I came up with: ...
5
votes
3answers
169 views

Map with different types for values

I am trying to implements a map (that can work as a cache) that has strings as keys and values of different types. In my real case once set the key/values in the map will not change. I used these ...
5
votes
2answers
111 views

Chained hash table implementation

While reading a data structure book, I have implemented a chained hash table. I want to share the code with you and get your opinion about it. chained_hash_table.h ...
4
votes
2answers
91 views

Fetch plist file

I have a plist file with many nested dictionaries inside of it, and I wanna fetch them all to my code. Isn't there any more efficient way to do that than nested for-loops? ...
3
votes
1answer
32 views

Generating a complicated data structure in a more efficient manner

I need to convert some CSV data into a format recognizable by some old script my work uses. Changing the format is pretty much out of the question. So I've written this: ...
8
votes
1answer
311 views

Dictionary (with silly hash)

Based on this question (but fixed so it can run). I have kept the code as close to the original as possible. I have Marked all the changes with Loki (should be easy to spot). Code here is written in ...
9
votes
2answers
372 views

Implementation of fixed size hash map

I'm trying to brush up on my algorithms and data structures and wrote a fixed sized hash map assuming both key and value will be only integers. This is a significant simplification of the real case ...
5
votes
1answer
54 views

Python DictionaryTagger class takes too long to initialize

With big inspiration from code from different webpages, I have created this DictionaryTagger. My problem is that it takes around 2 sec. to initialize the taggers / ...
2
votes
1answer
42 views

Print dict with varying-length lists

Is there a shorter way of taking a dict with varying length lists and printing it to screen? Shortcomings of this method also include that values which aren't lists are printed as letters separated by ...
2
votes
2answers
51 views

Get ruby Hash#each to return a built hash

I'm golfing some code while waiting for a coworker, and I shortened a function to this: ...
2
votes
1answer
40 views

Iterate over items in a set of dicts

I'm using the following code to initialise 8 I/O-ports (i.e. GPIO pins on a Raspberry Pi). That's 4 x 2 pins, each duo controls a switch, A to D, and each duo consists of a pin for On and a pin for ...
1
vote
2answers
84 views

Code to generate a dictionary from two lists

I created a script to perform a union on 2 lists: keys and words. I needed to create a dictionary from them. If there are more keys than words, missing words are replaced with "None". Any excess words ...
3
votes
1answer
108 views

Read from csv file, transform to dictionnary

First of all, here's the code I'm working on: ...
4
votes
2answers
161 views

Traversing and printing complex Dictionary types (Scripting.Dictionary) - Dictionary inside of a Dictionary

Based on this SO post - also reposted on vba4all.com with a few more details and explanations. Please notice there currently is no error handling whatsoever as I didn't analyse and consider any traps ...
2
votes
1answer
79 views

Fuzzy matching dict keys

What do you think of this idea? It's supposed to be a dict that makes a reasonable guess at the key you were trying to access for getters and deleters. Setters should be untouched. Similar to how ...
2
votes
1answer
47 views

Mapping object values from one object to another

I have an object called defaultOptions and a function that accepts as an argument an object called newValues meant to override ...
4
votes
2answers
238 views

Performance of hashmap-based session object

Unfortunately, I can't use the Tomcat session for storing the key/value pairs for each user (restricted because it's an IVR domain-based project). But I need the same functionality like a ...
5
votes
4answers
3k views

Simple implementation of HashMap

I have implemented a HashMap which supports insertions of integer key value pairs. The approach uses an array for simplicity and uses a standard hash function. ...