dictionary

Collections of collections and Objective-C memory management

I have a pretty simple question. While I am fairly new to Objective-C, I have gotten pretty comfortable with the language and the memory management model. I understand ownership pretty well and the notion of explicit and implicit. I also understand that when you add anything to a collection, it takes ownership of the keys and values a...

Best approach to make an online dictionary?

Hi, guys! I'm trying to create an online dictionary (some rare languages) and need you suggestions. My php, mysql and javascript knowledge though is far from excellent, but is enough to understand the code and make some changes to it. I've done some projects with Drupal before and now thinking about trying a php framework for this proje...

Better name for dictionaries.

I'm designing a programming language, so I've been putting a lot of thought into the way base types are named. "Dictionary" seems like a bad name for what dictionaries do. They aren't organized lists of words with their definitions; they don't deal with words, they don't with definitions, and they aren't lists. The only vague associat...

Python: Does a dict value pointer store its key?

I'm wondering if there is a built-in way to do this... Take this simple code for example: D = {'one': objectA(), 'two': objectB(), 'three': objectC()} object_a = D['one'] I believe object_a is just pointing at the objectA() created on the first line, and knows nothing about the dictionary D, but my question is, does Python store the K...

Unable to set initial value when databinding combobox to Dictionary<char,string>

I have a simple Dictionary defined as ResultOptions = new Dictionary<char, string> and my viewmodel has a public property ResultCode of type char. My XAML is as follow: <ComboBox ItemsSource="{Binding ResultOptions}" DisplayMemberPath="Value" SelectedValuePath="Key" ...

PHP Access to Dictionary Audio files

I am looking for an api file to a dictionary that I can access audio files that are used as well as definitions. So far there have only been references to some sites that provide help in the definition area. does anyone know of any? ...

C#: Remove duplicate values from dictionary?

How can I create a dictionary with no duplicate values from a dictionary that may have duplicate values? IDictionary<string, string> myDict = new Dictionary<string, string>(); myDict.Add("1", "blue"); myDict.Add("2", "blue"); myDict.Add("3", "red"); myDict.Add("4", "green"); uniqueValueDict = myDict.??? Edit: -I don't care which k...

Whats the best way to INSERT (500-700) words into an MySQL database, for the purpose of a dictionary/histogram

I have to create a histogram/dictionary of all words found in parsing an html file. This includes a dictionary of all words found, and a histogram of their frequency. I cant think of how to do this with PHP/MySQL because there could be potentially 2000 words that would have to be INSERTED at once =/ Any ideas? ...

LINQ Convert Dictionary to Lookup

I have a variable of type Dictionary<MyType, List<MyOtherType>> I want to convert it to a Lookup<MyType, MyOtehrType>. I wanted to use Lambda functions to first, flatten the dictionary and then convert this to Lookup using the ToLookup(). I got stuck with the dictionary. I thought about using SelectMany but can't get it working. Anyon...

C# dictionary initializer compilation inconsistency

The following code compiles, but fails with a NullReferenceException: class Test { public Dictionary<string, string> Dictionary { get; set; } } static void Main(string[] args) { var x = new Test { Dictionary = // fails { { "key", "value" }, { "key2", "value2" } } }; } If you repla...

C# - Locking a resource when obtained from dictionary

I have a Dictionary that tracks objects (ClientObject). Both the dictionary and ClientObject's are accessed by multiple threads. When I modify or read any object in this dictionary, I obtain a read or write lock on the dictionary using ReaderWriterLockSlim (rwl_clients) then obtain an exclusive lock on the actual object. I just wanted t...

How to split string into a Dictionary<string,string>

I need to create an dictionary by splitting a string like this: [SenderName] Some name [SenderEmail] Some email address [ElementTemplate] Some text for an element [BodyHtml] This will contain the html body text in multi lines [BodyText] This will be multiline for text body The key could be surrounded by anything if that easier, e.g. ...

Can you programatically look up a word in the Mac OS's built-in dictionary?

I'd like to have a program of mine retrieve a definition of a word. Is there a way to access the built-in dictionary using Objective C? (i.e. the one that Dictionary.app and command-control-D use) Thanks! ...

Mapping std::map to Python

Sometimes it makes sense to have a key-ordered dictionary. In C++, this is often implemented with a Red-black tree. But any self-balancing binary search tree will do (fwiw, Knuth is particularly clear on this subject). The best solution I've been able to come up with so far is to take R. McGraw's AVL-tree type and create a wrapper class ...

How to define hash tables in bash?

Just what title says. I am surprised by insufficiency of results in Google search for this question! What I want to is the equivalent of Python dictionaries but in bash (and hence, should work across OSX, Ubuntu and other major Linux distributions). ...

Combining Dictionaries Of Lists In Python

I have a very large collection of (p, q) tuples that I would like to convert into a dictionary of lists where the first item in each tuple is a key that indexes a list that contains q. Example: Original List: (1, 2), (1, 3), (2, 3) Resultant Dictionary: {1:[2, 3], 2:[3]} Furthermore, I would like to efficiently combine these dict...

C# Dictionary with two Values per Key?

I have a situation in code where a Dictionary<string, string> seemed like the best idea - I need a collection of these objects and I need them to be accessible via a unique key. Exactly what the Dictionary concept is for, right? Well, the requirements have expanded to the point where I now need to hold an additional bit of information p...

How to implement a multi-index dictionary?

Basically I want something like Dictionary<Tkey1, TKey2, TValue>, but not (as I've seen here in other question) with the keys in AND, but in OR. To better explain: I want to be able to find an element in the dictionary providing just one of the keys, not both. I also think we should consider thread-safety and the ability to easily scale...

How to bind Dictionary to ListBox in winforms

It is possible to bind a dictionary to a listbox, keeping in sync between the listbox and the member property? ...

KeyError with dict.fromkeys() and dict-like object

Hi, In Python, you can use a dictionary as the first argument to dict.fromkeys(), e.g.: In [1]: d = {'a': 1, 'b': 2} In [2]: dict.fromkeys(d) Out[2]: {'a': None, 'b': None} I tried to do the same with a dict-like object, but that always raises a KeyError, e.g.: In [1]: class SemiDict: ...: def __init__(self): ...: ...