Skip to main content

Questions tagged [dictionary]

Filter by
Sorted by
Tagged with
0 votes
1 answer
158 views

I have an excel macro that imports daily share price files, and finds the highest price for a share after a given date. Each of these daily stock price files has ~1000 rows of data. Currently I have ...
Frankie139's user avatar
1 vote
1 answer
114 views

I'm looking for a method to map the content of a structured text file to a nested dictionary (dictionary tree). The text file consists of (nested) sections with each section starting with the pattern ...
user71769's user avatar
  • 121
3 votes
5 answers
2k views

I am designing a program and I am looking to decide over a Dictionary vs a List. Since I know I have unique values per item I imagined a Dictionary/List that looks like: Dictionary<(int k1, string ...
Ranald Fong's user avatar
1 vote
1 answer
139 views

I'm implementing an API key based authentication scheme and I'm caching valid API key entries (hash, scope etc.) in a memory cache. For the cache key, I had been using the first 8 characters of the ...
Daniel Vernall's user avatar
1 vote
1 answer
105 views

I am playing around with a cross-language spell-check sort of thing, and am still in the prototyping/ideation phases. Basically I have thought of something like a Trie data structure, but I keep ...
Lance Pollard's user avatar
7 votes
1 answer
3k views

In Python there are basically two ways to get a value from a dictionary: dictionary["key"] dictionary.get("key") Is there any - maybe historical - reason for this behavior? I ...
Thomas Junk's user avatar
  • 9,623
0 votes
0 answers
142 views

I am working on a ChildModelListSheetHandler, that has a childModelListDict. As what you're probably thinking, it maps the foreign keys that are the IDs of the parent models, to the list of child ...
Mike Warren's user avatar
2 votes
1 answer
872 views

In the simplest case, I have some code where the user may want to do one thing (a), another thing, (b), or both (a+b). The options are reasonably complex and have their own functions, but I would like ...
QuantumChris's user avatar
0 votes
1 answer
2k views

I have a list of python dictionaries (let's assume each dict is flat for the time being). The keys are all strings and the values are strings or real numbers. I would like the user to have the freedom ...
najeem's user avatar
  • 125
1 vote
2 answers
2k views

What is the intended usage of the ImmutableDictionary<TKey,TValue>.ValueComparer property? Why is it useful being able to compare dictionary values by using a specified equality semantic? I ...
Enrico Massone's user avatar
-4 votes
4 answers
3k views

Given an array of integers, we want to find how many explicit pairs can be made such that their sum is divisible by 60. The pairs are not necessarily non-unique. For example, let's say the input into ...
8protons's user avatar
  • 1,389
0 votes
1 answer
3k views

If python dictionaries are essentially hash tables and the length of hashes used in the python dictionary implementation is 32 bits, that would mean that regardless of the number of key-value pairs ...
MShakeG's user avatar
  • 127
-2 votes
1 answer
88 views

I have million of objects, each with an array smaller than 10 elements, which are the names of other objects in the dataset. Basically { a:[b,c,d,], b:[c,d,e], c:[a,e,f], ... e:[a,b,c] } will ...
DsCpp's user avatar
  • 97
0 votes
1 answer
2k views

my_dict = { 1: 11, 2: 12, 3: 13 } If I want to work on the list of keys from my_dict there appear to be (at least) three ways to do this in Python >3.5 (i.e. on or after PEP 448) List Comprehension: ...
dumbledad's user avatar
  • 317
1 vote
3 answers
558 views

Array := {"title": "Book Title", "author": "John Doe"} Some people use the following terminology: title and author are keys. Book Title and John Doe are values. "title": "Book Title" and "author": "...
john c. j.'s user avatar
-2 votes
1 answer
196 views

Say I have two Map instances in JavaScript (or HashMap in Java, or Dictionary in C#), A and B. I want to synchronize B to A, so that B is a copy of A. I can't copy the reference and I don't want to ...
TrueWill's user avatar
  • 432
8 votes
3 answers
2k views

Until recently I used to think that it was preferred to reference objects by pointers or references than to keep objects in some sort of a central, authoritative array or dictionary and only keep ...
gaazkam's user avatar
  • 4,529
35 votes
9 answers
51k views

I find myself often looking up questions online, and many solutions include dictionaries. However, whenever I try to implement them, I get this horrible reek in my code. For example every time I want ...
Adam B's user avatar
  • 1,660
-1 votes
3 answers
459 views

I have a case where I have a dictionary object and a value with no key. The object can have the system values and then a user value. I have to store that value. I could use a reserved word or I ...
1.21 gigawatts's user avatar
-1 votes
1 answer
828 views

I am writing a software specification and I got confused with the data dictionaries section. is it a full detail of the interfaces and stored models ( like of a database ) or a just a second step of ...
Kaki Master Of Time's user avatar
-1 votes
4 answers
2k views

I've read that an object's hashcode should not change while it is part of a Dictionary. Because if it changed, there would be no way to find it in the Dictionary. Why doesn't the Dictionary class ...
David Klempfner's user avatar
-3 votes
1 answer
106 views

I have three attributes for a user: connectionId (e.g. "sd4-h4sdg-u4j-a2rr3"), userName, and placeInLine. I can't think of a single data structure that will handle my scenario of only allowing a ...
JacobIRR's user avatar
  • 159
32 votes
5 answers
20k views

The specific example in mind is a list of filenames and their sizes. I can't decide whether each item in the list should be of the form {"filename": "blabla", "size": 123}, or just ("blabla", 123). A ...
clb's user avatar
  • 521
4 votes
5 answers
14k views

I understand the difference between ordered and unordered sets, and I understand why for many purposes, we don't need ordered sets. But all set operations are still possible on ordered sets, and sets ...
oulenz's user avatar
  • 167
1 vote
1 answer
1k views

I have a table UserItems {ID, UserID, ItemID} Items must be in RAM (not in db table). What is better for this? As enum with attributes or as dictionary of items?: enum Items { [InternalParam("...
Glebka's user avatar
  • 141
5 votes
1 answer
3k views

In Think Python the author introduces defaultdict. The following is an excerpt from the book regarding defaultdict: If you are making a dictionary of lists, you can often write simpler code using ...
Mahmood Muhammad Nageeb's user avatar
0 votes
1 answer
3k views

I've got a scenario where I need to compare two JSON files and override one if the values are different. These JSONs also include arrays (i.e. [) My approach is to traverse one JSON to dictionary O(n)...
Simply_me's user avatar
  • 145
0 votes
1 answer
282 views

I want to make a dictionary that stores some values I want to use within my code. Would it be better to use an instance variable to hold the dictionary, or an XML file to hold the dictionary, or ...
Mohamed Moselhy's user avatar
0 votes
1 answer
2k views

The problem: Let's say I want to create a java app (currently using java 8) that works like a dictionary. I want the app to give the user the capacity to add and search for words, every word must ...
Roäc's user avatar
  • 3
32 votes
3 answers
15k views

At one point or another you might come over functions with a lot of arguments. Sometimes it makes sense to combine some of the arguments into super-arguments. I've often done this with dicts, but now ...
André Christoffer Andersen's user avatar
3 votes
2 answers
7k views

I'm loading a config file. I'm considering the following ways of doing it. Version 1: config = json.load('myconfig.json') config_elm = config.get('some_config_elm') if config_elm is not None: # ...
André Christoffer Andersen's user avatar
6 votes
2 answers
6k views

Why is there no key specified with .NET KeyNotFoundException (in message/property)? Is it because of performance reasons? Is it because when Dictionary finds out there isnt any requested object by the ...
NeverStopLearning's user avatar
3 votes
1 answer
8k views

Do you name a dictionary by the key or the value? I have a dictionary that will hold gradient data and the component: dictionary[gradient] = component; Do I name it gradientDictionary or ...
1.21 gigawatts's user avatar
3 votes
2 answers
690 views

I'm wanting to create a class that stores words in a set so that I can see if a word belongs to that set or not. I'm not wanting to build ever set every time I instantiate the class, so I'm using what ...
WP0987's user avatar
  • 591
3 votes
2 answers
308 views

Let's take French and Japanese adjectives as simple examples. French adjectives have gender (masculine or feminine) and number (singular or plural), whereas Japanese nouns have neither. However, ...
Chris Cirefice's user avatar
4 votes
2 answers
280 views

Based on the List monad I set out to define Monad instances for the Map type from Data.Map, to perform chained unions and folds on Maps like lists, but with the efficient sorting and merging of Maps: ...
Herng Yi's user avatar
  • 323
4 votes
2 answers
20k views

I am working on an API in C#. I am trying to think about the simplest way to expose my API for consumers of it. In particular, I have a class in my exposed data model that has a dictionary property. ...
Brian's user avatar
  • 183
7 votes
1 answer
24k views

My question: is there a canonical way of creating a dictionary of dictionaries and providing an outer/inner key pair? Is there a NugetPackage out there with an implementation? In my code, I have now ...
Frank Bryce's user avatar
4 votes
1 answer
292 views

simple question, I want to know if there's a word/term used to describe the collection/pair of a key and value in a C# Dictionary.
Bojangles's user avatar
2 votes
2 answers
795 views

We have an word game commercial mobile application for which we want to use dictionaries for various languages. Most of them have GPLv3 or CC-NC3 licenses. We modify the dictionaries: basically, we ...
Oliv's user avatar
  • 123
0 votes
1 answer
199 views

There is one thing I can't really understand in JavaScript or Python, and that's the delete or del syntax. In JavaScript: obj = {ha: 123, hi: 3.14} delete obj.ha # now obj is {hi: 3.14}...
nonopolarity's user avatar
  • 1,837
0 votes
1 answer
1k views

I'm writing an application in javascript where given a word, I need to get all the possible versions of the word with the suffix being the difference between each form. For example: "sponsor" should ...
Harsha Reaper's user avatar
4 votes
2 answers
12k views

It seems like a pretty straightforward thing to add, but I just want to be sure .NET doesn't already provide one and save me from adding unnecessary code: I need a lookup table (like a Dictionary) ...
Jarryd Le Breton's user avatar
-3 votes
2 answers
1k views

For my project, I need to map integers so that inputting int X will output int Y where both X and Y are defined during runtime. I've used Dictionary<int,int> in .NET but its memory use is too ...
JPtheK9's user avatar
  • 199
-3 votes
1 answer
2k views

As python memory model is dictionaries of dictionaries, looks like any object in JavaScript has similar representation. Below code, > foo = {} makes foo as an empty dictionary {}. fine. If code ...
overexchange's user avatar
  • 2,325
10 votes
3 answers
33k views

I've been brushing up on algorithms and reviewed these two methods of implementing hash tables. It seems like they largely have similar performance characteristics and memory requirements. I can ...
Casey's user avatar
  • 273
27 votes
1 answer
74k views

C# dictionaries are a simple way to find if something exists etc etc. I have a question though on how they work. Let's say instead of a dictionary I use an ArrayList. Instead of using ContainsKey (or ...
John Demetriou's user avatar
7 votes
2 answers
3k views

My logic goes like this: def A(val): return {'a':val} print(A(7)['a']) is the same as class A: def __init__(self, val): self.a = val print(A(7).a) Obviously, there are problems and ...
user3808430's user avatar
0 votes
2 answers
739 views

I am creating a program (mostly just for fun) that displays live prices for horse racing markets and the prices that several models predict they should be. I am very interested in the optimal way to ...
janderson's user avatar
  • 123
3 votes
2 answers
39k views

Let's start with the problem: There is a large dictionary X that contains {key, value} pairs, i.e.: X = [{100, 10}, {101, 0}, {103, 0}, {106, 2}, {110, 1}] Every t seconds, X has to be updated with ...
Macin's user avatar
  • 211