A dictionary, in computer science, is a data structure that maps keys to values such that given a key its corresponding value can be efficiently retrieved.

learn more… | top users | synonyms

2
votes
1answer
44 views

Scraping thefreedictionary.com

Scrape results from thefreedictionary.com ...
6
votes
1answer
42 views

Dictionary<TKey, TValue> Implementation

This class encapsulates a List<KeyValuePair> (see List<T> implementation here, and ...
7
votes
3answers
94 views

Collect and calculate average times from log, then display top 10 longest durations

Here's a novel-length summary of the issue: I'm trying to write a VB.net program to help me collect remote site statistics from system-generated logs, but I'm a little like a carpenter who only knows ...
7
votes
2answers
161 views

Game passive skill system

I'm trying to create some easily accessible database of different skills. General idea is that every skill should do something different and be able to act on different things (ex. one skill which ...
10
votes
3answers
125 views

Refactoring if-else structure with elements of dict

I have code which gets data from a POST request (request.form dict), compares with corresponding attribute in object ...
1
vote
1answer
145 views

Making adding to a dictionary more efficient?

I have the following code and it's taking quite some time to run. I'm getting an Out of Memory Exception due to the high volume of answers there are. Is there any ...
8
votes
3answers
276 views

Scrabble algorithm review and performance suggestions

After finishing Project Euler 24, I decided to make a scrabble type of application using /usr/lib/dict as my dictionary what I cat that into a word file. It does take a few seconds, and the dictionary ...
5
votes
2answers
404 views

Elegant way to split an NSArray into NSDictionary of array

I need to split one NSArray into NSDictionary. Every key in NSDictionary will contain an ...
2
votes
2answers
83 views

Special dictionary

I need a special dictionary that would do as follows: if key is set to more than once, the values are a list of all set values. Such a list is returned as value on get. if key is set only once, it ...
3
votes
1answer
142 views

Recursively convert a list of lists into a dict of dicts

As a challenge to myself, I wrote a solution to this Stack Overflow question. For completeness, the bulk of the question is as follows: Problem Input: ...
3
votes
5answers
633 views

Is there a better, more efficient way than Dictionary(Of Tuple(), MyClass)?

Suppose I have data coming from different sources that tells me information about a large group of stores that has the following (just an example): Necessary to define what store we're dealing with: ...
0
votes
1answer
127 views

Copying Dictionary collection into an array [closed]

Hi I want to minimize the following code: ...
3
votes
2answers
229 views

Test if two IDictionary objects contain the same values

I'm adding a function to my test library to assist in testing if two IDictionary objects contain the same keys/values. I need the method to be generic and support ...
0
votes
1answer
181 views

opening a text file and building a dictionary

Need to write a function that takes an open file as the only parameter and returns a dictionary that maps a string to a list of strings and integers. each line in the text will have a username, ...
2
votes
2answers
98 views

Word analysis on input from a file

How do I improve the below code, which takes input from a file and does some word analysis? I find a lot of redundancy in it. I want to know a better way of implementing it. ...
5
votes
3answers
174 views

How best to differentiate boolean values in a long list?

I have a large C# Dictionary of string keys and boolean values. Background on the reason for it is this: my program builds up a bunch of the same objects from two different sources, and then compares ...
3
votes
1answer
126 views

Prime number dictionary

I attempted to write a read-only dictionary, containing primes: ...
1
vote
1answer
1k views

Proper way to compare two Dictionaries [closed]

I am implementing an IEqualityComparer for Dictionary objects and am looking for input on a couple of different approaches. I define equality in this case to be that both dictionaries contain the same ...
1
vote
2answers
99 views

Optimization of a while-loop searching for words in a dictionary

This is my first question here. I'm using an open source program called MElt which lemmatize (give the lemma example:giving-->give) of words. MElt works on Linux and its programmed in Perl and ...
2
votes
2answers
169 views

Python code snippet could probably be more elegant

I'm looking to let people define arbitrarily nested lists of lists and return a random json document for them. Right now the assumption is that if you have a structure like this: ...
1
vote
2answers
162 views

Making a 2D dict readable

I am building a 2d dictionary with an altered list at the end Afterwords I want to find the min of each list. Is there a better way to do it? Better being faster or at least less of an eyesore. ...
1
vote
3answers
178 views

A Better For Loop

I'm very new to Python, and have a feeling that there's a much better way to implement the following code. It works, I'd just like to clean it up a bit. The purpose is just to create a dictionary with ...
4
votes
1answer
179 views

Prime Numbers Store

Problem definition: Lets say we need to create a store for selling prime numbers. Users enter the store and ask to buy a number. If the number asked is a prime number, 1.1. then it's either ...
5
votes
1answer
78 views

Load drinks and their ingredients into dictionaries

I'm working on a web application using bottle, and it is, at this point, functional. The gist of it is that I have a database of drinks, with associated IDs, and associated sets of ingredients. the ...
2
votes
1answer
695 views

Setting variable if it doesn't exist in Dictionary [closed]

I was wondering if this was good design from client side calls. In the event that the key doesn't exist, go ahead and add it. ...
2
votes
3answers
2k views

Set a default if key not in a dictionary, *or* value is None

Let's say I have a key 'messages' that is usually a list, but might be None, or might not be present. So these are all valid inputs: ...
7
votes
1answer
628 views

Simple trie implementation in JavaScript

After experimenting with a sorted trie implementation in C, I felt that I understood tries pretty well, but was having trouble explaining how they work. Since the C code was based on existing code, I ...
1
vote
1answer
130 views

Sorted trie implementation in C

I wanted to store some dictionary data (key/value pairs of strings) in C, and decided to use a trie. I found what looks like a good implementation here, along with some nice notes. In this ...
1
vote
3answers
79 views

update list based on other values

Basically I have a 2d list containing movies. Movies are specified by name, version and description. For example ['Jaws', 1, 'Movie about sharks'] - where ...
-1
votes
2answers
235 views

What is a good name for bidirectional dictionary structure? [closed]

I'm writing a generic bidirectional dictionary which will be a part of a (somewhat) public API. This is how the dictionary works: It will hold key-key pairs where ...
1
vote
3answers
86 views

Updating list of Dictionaries from other such list

Basically I have created a function which takes two lists of dicts, for example: oldList = [{'a':2}, {'v':2}] newList = [{'a':4},{'c':4},{'e':5}] My aim is to ...
2
votes
1answer
201 views

Iterating X times (where X > Y) over Y element dictionary - is there a nicer way of doing this?

I need to write a procedure, that will take a dictionary consisting of server names and their available slots and a number of slots required, and redispatch it over the servers, so that every server ...
2
votes
1answer
105 views

Readability concerns with literal dictionary lookup vs if-else

I'm having concerns about readability of this piece of code: messages_dict = {'error':errors, 'warning':warnings}[severity] messages_dict[field_key] = message ...
5
votes
2answers
454 views

Convert dictionary of lists of tuples to list of lists/tuples in python

I've got dictionary of lists of tuples. Each tuple has timestamp as first element and values in others. Timestamps could be different for other keys: ...
3
votes
2answers
539 views

Refactor deeply nested if-else

I found a code on my computer that i wrote a while ago. It is based on an exercise from O'Reilly book Programming the Semantic Web. There is a class, that stores RDF triples, that is data in the form ...
4
votes
1answer
324 views

Is this custom dictionary thread-safe?

I'm writing a custom dictionary which is to be used as a helper for caching. The reason I use delegates is because it must interface with generated code, so I can't change this. However, you can ...
6
votes
3answers
236 views

Would appreciate feedback on college-level project

In this program, I have been asked to read a an existing textfile (1324passlist) containing a list of passwords, then create a dictionary file with both the password and MD5 hash of the password on ...
7
votes
1answer
2k views

Thread-safe LRU Dictionary in C#

Can't seem to find one, so trying to build a very simple but fast implementation. Thought I would post on SO for review/feedback, and so that others can just copy/paste for their own use. I'm using a ...
4
votes
2answers
322 views

Iterating thousands of times over large collections: advices

This is a pet project :) I have hundreds of playlist files .m3u whose many entries have a wrong path. I'd like to fix them programmatically. Suppose one of my .m3U contains the following entry: ...
9
votes
6answers
717 views

Simple word counter

I've decided to do this by writing a simple word counter. The app gets all the params and outputs all the unique words, each one with a counter: "Hello world Hello" would return "Hello: 2", "world: ...
7
votes
2answers
5k views

Type-safe Dictionary for various types

Assume the following situation: you have an object that can store any object based on a key (basically, IDictionary<string, object>). You want to store ...
7
votes
7answers
340 views

Any way of simplifying the following two short snippets regarding Dictionary?

Example 1 if (myList.ContainsKey(myKey)) { myList[myKey]++; } else { myList.Add(myKey,1); } Example 2 ...
6
votes
5answers
938 views

Holding records using dictionary

Can you please help me with the following script? At the moment the script is taking up to 20 mins to execute, depending on the amount of data being processed (each time the script is executed, it ...