A data structure that uses a hash function to map identifying values, known as keys, to their associated values
2
votes
1answer
25 views
Speed up code based on map with vectors as values
Following is the piece of code which represents the bottleneck of my application:
...
2
votes
1answer
34 views
Building and querying an immutable phone book
I wanted to get your opinion on this immutable implementation of a Phone Book using recursion to process a stream. I am especially interested in ways to speed up the code execution.
Here is an ...
5
votes
1answer
43 views
Fixed capacity unordered_map
I have a need for a container that behaves like an unordered_map, but has a fixed capacity, and an eviction policy where the least recently inserted key-value pair ...
7
votes
2answers
82 views
Hash map implementation
I'm a student in college, and while I have coded a lot, I still feel like I've only scraped the surface. I have learned a lot of things over the years, but very few of my professors ever did code ...
4
votes
1answer
38 views
Python Dictionary Manipulation
I just finished working on a coding challenge for learning Python 2.7. Essentially, I'm a function that if it is fed a string such as:
...
1
vote
2answers
71 views
Alternative to using Object and casting in a map
I have the following class which represents a set of properties.
...
2
votes
0answers
52 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!
...
2
votes
3answers
57 views
Optimizing Java SHA-512 String-to-Hash Generator
In an attempt to learn Java and SHA-2 I created a very simple String-to-SHA512 generator. Here is the code:
...
2
votes
3answers
300 views
Simple Chaining Implementation of HashMap
I'm practicing writing my own simple version of a Java HashMap. I don't have much experience with generics in Java.
...
2
votes
1answer
53 views
Bare bones implementation of Java HashMap
I've done a minimal implementation of a HashMap. Invite comments.
...
4
votes
1answer
70 views
Prints Books from a HashMap that are complete or incomplete
This code is meant to display book titles that are incomplete. I have a HashMap with the book title and a number that represents the amount of the book that has ...
4
votes
1answer
162 views
Using a LinkedList type of adjacency list to create the word game: WordLadder
The user puts in a starting word and an ending word. My code creates a ladder between these words of words that are different by one letter.
Start: gain
End: fire
Output:
...
2
votes
2answers
86 views
Print max occurring character in a String
This prints the character that occurs the most in a given string.
Input: String of word(s)
Output: Max occurring character
...
3
votes
1answer
53 views
class Taboo<T> — sort passed in List<T> according to 'rules'
I know as a matter of fact that there are many areas upon which my code could be improved. I was wondering if anyone can provide me with suggestions on how Taboo ...
0
votes
3answers
178 views
Detecting if two given strings are isomorphic using Java data structures
So I have written the following code and it works for various same length isomorphic strings I have tried. However I am not sure what are some time complexity improvements and coding tweaks that could ...
0
votes
0answers
19 views
Converting from a madlib program using hashmaps to using 3 different arrays to hold the noun, verb, and adjectives
Using erb and Sinatra, I need to make an array of each variable that can be added in, [noun], [verb] and [adjective], allowing me to return the number of each there are and create the appropriate ...
5
votes
1answer
259 views
Replacing multiple substrings in a string
Here are 2 functions defined that do the exactly same thing: take input a template (in which one wants to replace some substrings) and array of strings values (key value pair to replace, such as [...
4
votes
2answers
83 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
1answer
109 views
A basic pure Python hash map using a tree
I would like feedback on my first attempt to understand how hash tables work. I've read some on how hash tables use modulo operations to find the location of a key.
Can you help me understand, ...
4
votes
1answer
91 views
Evicting an entry from a size-limited HashMap<T, Integer>
I have a HashMap with a limited size of 1000 elements. When I want to put one more, the T with the lowest related Integer in the map should be replaced with the new one.
I already have this working ...
3
votes
1answer
62 views
“Space and Time Efficient” way of finding all anagram groups
I have written a program to find all anagram groups in a text file. I used first 26 Prime numbers as a mapper for 26 characters for finding anagram groups (Since character_set of all anagrams of a ...
8
votes
2answers
543 views
Program to index a book
Indexing a book. Write a program that reads in a text file from
standard input and compiles an alphabetical index of which words
appear on which lines, as in the following input. Ignore case and
...
3
votes
2answers
164 views
Custom C++ iterator
So I have written a custom iterator for std::map that allows access to just the "values" of the map and I was wondering if it is the "correct" way to implement <...
5
votes
2answers
159 views
Registering and looking up aliases
I've taken a coding challenge as part of a job interview and the recruiting process. Sadly I didn't get through it and couldn't secure the job. I am wondering if anyone can help me out here and show ...
0
votes
3answers
102 views
Database of students
At first, I had Database to contain std::list<Student> students, but because there are over 2000 students, searching by ...
3
votes
1answer
81 views
Bidirectional map
For fun and to learn a bit, I decided to implement a bidirectional map in Ruby, relying on Ruby core libraries where possible.
Its behavior is intended to be that of a Ruby Hash, but one in which '...
2
votes
1answer
241 views
Minimal Map implementation with weak values
What follows is an implementation of the java.util.Map interface with weak values. This means that entries should be removed from the map when their values become ...
8
votes
2answers
2k views
Simple linked hash map in JS (Node/browser)
I needed a simple data structure to cache the most recent few directory contents for this project I was working on. I thought a linked hash map would be the right approach since we will cache only one ...
10
votes
2answers
2k 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 ...
4
votes
2answers
1k 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 ...
6
votes
4answers
26k 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. ...
11
votes
2answers
9k views
Object key-value map reversal
I have implemented functions that will let me reverse a one-to-many value 'Map', that is a plain JavaScript object.
For example,
...
5
votes
2answers
155 views
Family finances - tracking and reporting
I am looking for clean way to accumulate amounts within a input dataset. In this example, there are 18 rows of data, and the output is a 3 rows of data, accumulated by Key, by ExpenseType.
My ...
4
votes
1answer
64 views
Synchronized LinkedHashed map
I've written the following code ages ago (10+ years) which is part of a simple chat server. I'm going to refactor it a bit in Java and then for fun I'm going to convert it to Scala and use Akka actors ...
20
votes
3answers
9k views
More elegant way to increment Integers in Map?
I have a HashMap<Token, Integer>, which counts occurrences of Token. Each time Token ...
6
votes
1answer
68 views
Implementing a data structure that is a collection of sets
I'm trying to optimize my code (time optimization) based on this problem:
Let S be a set of strings. Each string in S is ...
2
votes
2answers
325 views
Counting occurrences of Char8s in a file
To learn some Data.Map and Control.Monad.State, I have written the following code, which should count the occurrences of ...
2
votes
1answer
1k views
Generic util method to convert in single map from list of array of Object generally result of JPQL/ hibernate
I have designed a generic method to convert list of array of Objects to result into single map. This is working fine, but I want to check weather a key object is valid key (whether it is overriding ...
3
votes
1answer
663 views
Trains scheduled, find max platforms per stations
Given a "folder" which contains many "files," each file contains a time-table of trains, which stations they halt on and what time, per day.
...
10
votes
1answer
1k views
Is this the right way to implement a hashmap?
Is this the right way? Any comments on the hash functions? If asked a question like this in an interview, do I need to follow all OOP concepts(because I am using Java)? Like encapsulating the ...
3
votes
1answer
457 views
Bidirectional map based on memory manipulation
This is a bidirectional map implementation that stores the values as pairs on the heap, and uses pointer arithmetic for efficient lookup.
codepad link, may be easier to read
...
11
votes
1answer
675 views
Partitioned Multikey Map
Below is the code for what I've called a partitioned_multitype_map. This has two major facets:
Allowing a lookup based on keys of multiple lengths and of multiple ...
6
votes
3answers
336 views
How to refactor this code to get a source from property files?
I want to get the source of these files, but I don't know if I'm efficient.
I get the source of the file, put the source in a list, so I put this in a ...
4
votes
3answers
1k views
Find the longest unique string in the input list
Given a list, find the longest non-repeating (in other words I mean unique) string in the input list. Looking for code review, pointers on best practices, optimizations etc.
...
5
votes
2answers
4k views
4
votes
1answer
842 views
Insert tags around entities in body
Because we're passing object to Spring Framework in which Jackson classes convert them into JSON as a response, we chose to implement a simpler Tweet class rather ...
7
votes
0answers
176 views
Take two on type to instance map
I realised that what I was doing wasn't particularly smart, so I switched to a different approach. This costs more dynamic allocations but has a much simpler implementation:
...
6
votes
1answer
602 views
Map implementation in F#
Just as a refresher I put together a simple Map implementation and I would love to get some feedback on it.
...