dictionary

Dictionaries and Lambdas fun

Why would this compile: public Dictionary<ValueLineType, Func<HtmlHelper, string, object, Type, string>> constructor = new Dictionary<ValueLineType, Func<HtmlHelper, ...

How to get value list from generic dictionary

I've used this ObjectPool class as the basis of my Identity Map. However, I need to bring back the list of all objects of a type. Matthew has : public IEnumerable<T> GetItems<T>() { Type myType = typeof(T); if (!m_pool.ContainsKey(myType)) return new T[0]; return m_pool[myType].Values as I...

How to create an empty dictionary for optional argument in VB.NET

Basically, I have a function that has an optional dictionary argument. Since it's optional, it needs a default value, and I'd like to set it to an empty dictionary instead of Nothing. How do I go about that? In Java, I would simply do this: Collections.<K,V>emptyMap() How do I do the equivalent in VB.NET? (I'm using .NET 3.5). ...

Hashtable/Dictionary collisions

Using the standard English letters and underscore only, how many characters can be used at a maximum without causing a potential collision in a hashtable/dictionary. So strings like: blur Blur b Blur_The_Shades_Slightly_With_A_Tint_Of_Blue ... ...

Weak-keyed dictionary in Objective-C

Hello, I'm wondering if it's possible to have something similar to ActionScript 3's Dictionary object with weak keys in Objective-C. I want to be able to 'attach' an instance of a class to other arbitrary instances. Example; MetaData *meta = [MetaData metaDataForObject:someObject]; meta.whatever = foo; And later: foo = [MetaData me...

A text file with a list of words

I am looking for a simple text file that contains all the words in a moderm dictionary. I play a game called scramble, and would like to create a program that takes an input of letters and will tell me what kind of words could be made out of the combination of letters. DNOC DCIA ELRJ IIOT Circle, Cocain,...

Do I need to override GetHashCode() on reference types?

I read most questions on StackOverflow with regards to GetHashCode. But I am still not sure whether I have to override GetHashCode on reference types. I picked up the following from someones answer in another question: Object.GetHashCode() uses an internal field in the System.Object class to generate the hash value. Each object ...

Free word list for use programatically?

A friend of mine was talking about a word game she liked to play where you try to convert one word to another (they have the same number of letters) by switching one letter at a time, where each iteration produces a real word. Example: MOON --> WOLF GOON GOOF GOLF WOLF I figured it'd be a fun little project to write a prog...

Python base clase method call: unexpected behavior

Why does str(A()) seemingly call A.__repr__() and not dict.__str__() in the example below? class A(dict): def __repr__(self): return 'repr(A)' def __str__(self): return dict.__str__(self) class B(dict): def __str__(self): return dict.__str__(self) print 'call: repr(A) expect: repr(A) get:', repr(A...

Python equivalent of PHP's compact() and extract()

compact() and extract() are functions in PHP I find tremendously handy. compact() takes a list of names in the symbol table and creates a hashtable with just their values. extract does the opposite. e.g., $foo = 'what'; $bar = 'ever'; $a = compact('foo', 'bar'); $a['foo'] # what $a['baz'] = 'another' extract(a) $baz # another Is th...

Using Dictionary.app’s thesaurus function programmatically on OSX (preferably via Ruby)

I need to write a Ruby method that takes a word, runs it through OS 10.5’s Dictionary.app’s thesaurus function, and returns alternative words. If the Ruby method ends up calling the command-line, that’s fine; I just need to be able to do it programmatically from Ruby. After looking through Ruby OSA, I realize that the Dictionary is acc...

Two Way Data Binding With a Dictionary in WPF

I'd like to bind a Dictionary<string, int> to a ListView in WPF. I'd like to do this in such a way that the Values in the Dictionary get updated via the data binding mechanism. I don't want to change the Keys just the Values. I also don't care about adding new mappings to the Dictionary. I just want to update existing ones. Setting the ...

Static dictionary in .Net Thread safety

Reading msdn documentation for dictionaries it says : "Public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe." Those this mean that with a dictionary such as this : static object syncObject = new object(); static Dictionary<string,MyObject> mydictionary= ...

C# DropDownList with a Dictionary as DataSource

I want to set DataTextField and DataValueField of a Dropdownlist (languageList) using a Dictionary (list) of languageCod (en-gb) as key and language name (english) as the text to display. Relevant Code: string[] languageCodsList= service.LanguagesAvailable(); Dictionary<string, string> list = new Dictionary<string, ...

Creating dictionaries with pre-defined keys.

In python, is there a way to create a class that is treated like a dictionary but have the keys pre-defined when a new instance is created? ...

SQLite C++ Access Columns by Name

Is there a way to access SQLite results by column name (like a C++ Map) instead of index number in C/C++? For example, Python's SQLite access allows dictionary access Results = Query("SELECT * FROM table"); print Results['colname'] print Results['anothercol'] Any similar methods available in C++ for the SQLite's interface? ...

Is there any decryption algorithm that uses a dictionary to decrypt an encrypted algorithm?

Well I have been working on an assigment and it states: A program has to be developed, and coded in C language, to decipher a document written in Italian that is encoded using a secret key. The secret key is obtained as random permutation of all the uppercase letters, lowercase letters, numbers and blank space. As an example, let us con...

Which is faster/more efficient: Dictionary<string,object> or Dictionary<enum,object>?

Are enum types faster/more efficient than string types when used as dictionary keys? IDictionary<string,object> or IDictionary<enum,object> As a matter of fact, which data type is most suitable as a dictionary key and why? Consider the following: NOTE: Only 5 properties for simplicity struct MyKeys { public string Incomplete = "...

Can I get an English dictionary word list somewhere?

I'm creating this cool answer engine that answers "who" questions. I will share the URL soon. However, I need a list of English words for that, so find "proper nouns". Can I get an English dictionary dump or just a list of all English words, preferably British and American. Any help will be amazingly helpful! ...

How can I retrieve first n elements from Dictionary<string, int> in C# ?

Hi all, Is there a way to retrieve first n elements from a Dictionary in C#? ...