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

0
votes
0answers
12 views

Most efficient dict filter on key tuple?

I have a dict wherein a value needs to be retrievable by any one of several keys. It seemed that making multiple dictionaries or multiple entries in a single ...
5
votes
5answers
740 views

Generate a dictionary of passwords

I have a Python script that generates a dictionary of all possible 3 digit password combinations. It essentially works by just nesting for loops. This is fine, but ...
3
votes
2answers
63 views

Dynamic class instancing (with conditional parameters and methods) based on a dictionary

In a RPG game I'm developing, after building a base Weapon class, instead of having many subclasses of Weapon, I want the ...
1
vote
1answer
23 views

Writing a Counter object to a CSV-file in Python 3

In Python 3.4, a Counter object called cnt like this: ...
4
votes
2answers
81 views

Dictionary lookup of non-nullable struct into nullable destination

I've got an IDictionary<SomeT, DateTime> that does not always contain the desired key-value pair. For that reason, a target method expects a ...
4
votes
3answers
71 views

Efficient dictionary printing

Here's what my task is: Dependant on the "Logged In" user, they'll have different access rights and will see different menus. I have tried using the .get() ...
4
votes
3answers
77 views

Load recurring (but not strictly identical) sets of Key, Values into a DataFrame from text files

I am reading text files that contain data from observations. The format is not Fixed Width or Delimited, so I built a generator ...
1
vote
1answer
65 views

Custom Implementation of ObservableDictionary

I recently found myself in need of an IDictionary<TKey,TValue> implementation that was observable from a WPF UI. Since the .Net framework does not provide ...
7
votes
2answers
70 views

Copying a Dictionary and Replace its Values

I have a custom dictionary where the values are numpy arrays. I would like to have a convenience function that creates a copy of its content except that the values are changed. If no value is passed, ...
11
votes
1answer
62 views

iterating over the values of a list of ordered dictionaries

I am facing the following problem: I have a special data structure that is a dictionary whose keys are integers (dimensions). The values are also dictionaries whose keys are strings (geometric types) ...
6
votes
2answers
54 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 ...
3
votes
2answers
82 views

Compare dicts and record changes

My goal is to continually update an object and record any changes and the times they were made at. The input has to be JSON but the output/storage format doesn't. This function will check a JSON ...
1
vote
1answer
71 views

Test if a key exists anywhere in a nested object

I have complex objects containing nested objects. I need to check if a key exists anywhere in the nested object. I wrote this code as a makeshift solution. Is there any other way to search for the ...
1
vote
1answer
33 views

A Simple SortableDictionary for JavaScript

First, I must humbly admit that I've been a developer for many years but I've almost never had to work as a front-end, Web UI developer. I've been given an opportunity to work for an organization as ...
3
votes
2answers
72 views

Mapping a user input string to a corresponding block of code

My idea is I can define a block of code (inline) that corresponds to an input string then can call that block of code when given that input. I'm used to this sort ...
2
votes
1answer
93 views

Calculating sum of values in each child of dictionary for QTreeView

There is data stored in JSON file with the following structure: goods_data = {"year" : {"month" : {"day" : {"01" : {"name" : "some item", "price" : "10.01", "category" : "root | first | sub first ...
1
vote
1answer
62 views

Dictionary GetValueOrDefault

I'm pretty sure there's no better way to do this but I thought a consensus on here might be nice. Let me know what you think. ...
4
votes
2answers
374 views

Wrapping tuples to be used as keys in a Dictionary

I'm currently working on a project where I have to map some objects to several properties. Basically I need a Dictionary with Tuples as keys and instances of MyClass as values. As using tuples can ...
1
vote
1answer
27 views

Reading XML files and finding pairs between the files

I read three files and parse a few individual fields from each row of the XML. Using these fields, I find the dictionaries that contain the same keys (ItemK and either SensorK for sensors or PointK ...
3
votes
2answers
64 views

Practice with dictionaries

Post a cursory read of this I implemented a simple dictionary and an interface to assign, replace, look up, and redefine its terms to apply the concepts. It's simple, but I'd still like to know any ...
1
vote
1answer
53 views

Wrapper class for adding elements to HashSet

I have many object of class Test. I want to be sure that among them, there are no two objects o1 and ...
2
votes
2answers
54 views

Grouping over a list of dictionaries

I am consuming data from an API that reads from a SharePoint list. The API is basically this: ...
5
votes
2answers
223 views

Counting words from standard input in Swift

I know Swift isn't exactly meant to be used to write your classic stdin to stdout scripts, and that Python, Ruby, Perl, bash, awk, and friends are much better in this area, but I'd still like to see ...
1
vote
1answer
47 views

Map all symbols in module to dictionary

The div and add functions are located randomly in my package structure. I have a function with this signature: ...
0
votes
1answer
92 views

Data Structures C# Dictionary<int,user> and user has a property that is a list<numbers>

I am about to post a question to Stack Overflow about how to do a better job adding a number to the list inside the User class. But I feel if I refactored this I ...
2
votes
2answers
59 views

Iterate over large amount of words in Python

I wrote a program that should check a dictionary that contains about 50000 other dictionaries. In those dictionaries, one of the keys has a list of words as value. Now, I iterate over those words, ...
2
votes
3answers
58 views

Search dictionary by value

I have a dictionary which I use to lookup my binary and ASCII values (from A - P). It works, but my ascii2bin function just doesn't really feel right (and ...
5
votes
0answers
134 views
+50

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

InfixDictionary: Data structure for Infix string lookup

I needed a data structure to quickly find all previously inserted values, that have the given string as key or substring (full text search). At first, I tried out some tree structures (infix ...
4
votes
4answers
667 views

DuplicateDictionary - A dictionary-like class which allows duplicates

Since I couldn't find any good answers I made my own class called DuplicateDictionary for personal usage. I would like some tips to improve it. ...
2
votes
1answer
38 views

CSV parsing program that creates distinct header rows with transaction rows underneath

My code reads in the data using DictReader, then creates a header row that contains my composite key (PEOPLE_ID, DON_DATE), and then adds various values that are ...
4
votes
2answers
118 views

Commission calculation

I am trying to improve the performance of the current solution for calculating commission in a betting platform. The following is the code currently used to solve the problem. The primary problem ...
2
votes
1answer
196 views

Unique dictionary values - print keys

I'm working on this code for exam in an MIT Python course. It's working but I'm trying to improve it. What could I do, and what should I avoid? ...
6
votes
4answers
479 views

Fast evaluation of Euclidean distance with sparse data

I am working on a KNN implementation for sparse datasets (that I apply to text analysis). My points are represented by a Dictionary<string, double>, each key ...
4
votes
3answers
773 views

Return IEnumerable<KeyValuePair> from a private method; use Dictionary or anon. type?

Is it okay to return IEnumerable<KeyValuePair<string, string>> from a private method instead of returning a read-only dictionary? This allows for ...
1
vote
1answer
66 views

Dictionary file manager

The dictionary class loads entries from a file and then can perform operations on them. The dictionary class then stores the entries back into the file. I would like to know the best way to check if ...
4
votes
1answer
228 views

Updating a .csv file

I have a CSV file, call it csv_file. It has the following content: Username, Password name1, pass1 name2, pass2 ... I also have a dictionary, call it ...
4
votes
2answers
170 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? ...
8
votes
1answer
997 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 ...
5
votes
1answer
125 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
53 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
1answer
59 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
115 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
224 views

Read from csv file, transform to dictionnary

First of all, here's the code I'm working on: ...
6
votes
2answers
1k 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
258 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
115 views

A function to convert FASTA .txt to a dictionary

I'd like feedback on my function to convert FASTA data to a dictionary in Python. Here's an example of FASTA text: ...
6
votes
3answers
4k views

Convert dict entries to sets and lists

Can you please tell me if there is a better way to do this? ...
11
votes
4answers
2k views

Using a Dictionary to retrieve BOOL values

I have some values pulled from a web service giving me a bool value for a key. I did it this way, but feel like it is repeating without need. How can I refactor this? Please note that the key on ...
3
votes
1answer
940 views

Creating a fast Android dictionary (word counts)

This is a follow-up of my question here: I am currently working on an application for various statistics. One task is to analyse a good amount of sentences for their word counts. The specifications ...