Questions tagged [dictionary]

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.

Filter by
Sorted by
Tagged with
3
votes
1answer
684 views

Prime number dictionary

I attempted to write a read-only dictionary, containing primes: ...
-1
votes
1answer
26k 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
132 views

Searching for words in a dictionary

I'm using an open source program called MElt which lemmatize (give the lemma example:giving-->give) of words. MElt works on Linux and it's programmed in Perl and Python. So far it's working good but ...
1
vote
2answers
3k 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
508 views

Creating a dictionary with a path name and SHA-256 hash

The purpose is just to create a dictionary with a path name, along with the file's SHA-256 hash. I'm very new to Python, and have a feeling that there's a much better way to implement the following ...
6
votes
1answer
182 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 ...
13
votes
3answers
57k views

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

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: ...
12
votes
1answer
6k 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
3k 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 ...
0
votes
1answer
153 views

Dictionary Structure

I am brand new to dictionaries and coding and am hoping to get some suggestions on how I should structure my dictionary. I have a collector number which has meters connected to them. Each of the ...
1
vote
3answers
98 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
vote
3answers
11k 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 ...
3
votes
1answer
371 views

Applying a currency symbol based on a tested string value

My conditional code here seems repetitive and long. Is there a better approach? I want to test for a string value in a NSDictionary object and then depending upon ...
6
votes
2answers
3k 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: ...
6
votes
2answers
3k 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
888 views

Custom dictionary for caching assistance

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 ...
2
votes
2answers
148 views

Is there a better way of showing multiple NSDictionaries?

I have a method that contains a bunch of NSDictionaries (in fact, the only reason I have that method is to create those NSDictionaries). While I don't believe there are enough NSDictionaries ...
7
votes
3answers
1k views

Creating and searching a dictionary of passwords and MD5 hashes

In this program, I have been asked to read 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 the ...
8
votes
1answer
7k 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 ...
3
votes
1answer
3k views

Dictionary tree optimization

I was wondering if anyone could give me a little bit of help with optimizing a tree-structure in C++. I'm currently developing a dictionary program for a school project but want to take it a bit ...
3
votes
2answers
2k 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: <...
0
votes
2answers
1k views

Creating a dictionary of all prefixes of a string in Python

a=raw_input() prefix_dict = {} for j in xrange(1,len(a)+1): prefix = a[:j] prefix_dict[prefix] = len(prefix) print prefix_dict Is there any possibility of ...
10
votes
5answers
2k 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: ...
24
votes
4answers
38k 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 ...
5
votes
2answers
459 views

Transforming a Python dictionary into CSS

Recently I had the idea to write a module for the transformation of the dictionary into valid CSS code. And I would like to hear your comments on my code. License MIT, BSD etc. The code is very ...
8
votes
7answers
5k 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
983 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 ...
5
votes
1answer
1k views

Return Dictionary object having key/value pair of keywords and URLs

Can you please help me split this method to reuse the repeating code? Any advice/comments on the code are welcome. ...