dictionary

How do I store a dictionary object in my web.config file?

I'd like to store a simple key/value string dictionary in my web config file. Visual Studio makes it easy to store a string collection(see sample below) but I'm not sure how to do it with a dictionary collection. <ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt...

What is the equivalent of Java's AbstractMap in C#?

I need to create an object which exposes an IDictionary<K,V> interface, but I don't want to fill in the entire interface implemntation. It would be nice to have the equivalent of Java's AbstractDictionary, which leaves you very little to impelment a complete dictionary (HashMap, in Java): If you don't need to iterate the collection, y...

Python 3.0 - dict methods return views - why?

dict methods dict.keys(), dict.items() and dict.values() return “views” instead of lists. http://docs.python.org/dev/3.0/whatsnew//3.0.html First of all how is a view different from an iterator? Secondly, what is the benefit of this change? Is it just for performance reasons? It doesn't seem intuitive to me, i.e., I'm ask...

Sample [English] Dictionary SQL Script to populate table?

Does anyone know of a link to a reference on the web that contains a sample English dictionary word script, that can be used to populate a dictionary table in SQL Server? I can handle a .txt or .csv file, or something similar. Alternatively, I'm adding custom spellchecking functionality to my web apps...but I don't want to integrate th...

What's quicker at resolving, DataSet.Tables or Dictionary<string, Tables>

I am creating a mock database for import export tests (of the algorithm reading and writing complex data structures to our database, not just to test IO operations), and am trying to decide whether to use a DataSet to store the mock tables (by table name) in the faux-database, or Dictionary() In terms of retrieving a datatable by name, ...

Is there any implementation of IDictionary<K,V> with better performance of the BCL one?

Hi, I'm looking for an implementation of IDictionary with better performance of the standard BCL one. I'm looking for something with constant lookup time that performs really well with large number of elements (>10K) and is more GC friendly. Ps: No, I'm not able to write one by myself :) ...

How to get the FxCop custom dictionary to work?

How is it possible to get the FxCop custom dictionary to work correctly? I have tried adding words to be recognised to the file 'CustomDictionary.xml', which is kept in the same folder as the FxCop project file. This does not seem to work, as I still get the 'Identifiers should be spelled correctly' FxCop message, even after reloading ...

XML serialization of a Dictionary with a custom IEqualityComparer

Hi, I want to serialize a Dictionary that has a custom IEqualityComparer. I've tried using DataContractSerializer but I can't get the Comparer to be serialized. I can't use BinaryFormatter because of this. I can always do something like: var myDictionary = new MyDictionary(deserializedDictionary, myComparer); But that means I'd need...

Python dictionary clear

In python, is there a difference between calling clear() and assigning {} to a dictionary? If yes, what is it? Example:d = {"stuff":"things"} d.clear() #this way d = {} #vs this way ...

Dictionary (from Python) component for Delphi?

Is there similar component for Delphi like dictionary of Python? I'm now using TStringList to map string/object pairs, but I'd like more general approach and maybe more powerful (TStringList has binary search when it is sorted). Solutions for pre-D2009 are also welcome. ...

How to get a list of all users with a specific permission group in Django

Hi, I want to get a list of all Django auth user with a specific permission group, something like this: user_dict = { 'queryset': User.objects.filter(permisson='blogger') } But I cant seem to find out how to do this. How are the permissions groups saved in the user model? ...

Retrieving Dictionary Value Best Practices

I just recently noticed Dictionary.TryGetValue(TKey key, out TValue value) and was curious as to which is the better approach to retrieving a value from the Dictionary. I've traditionally done: if (myDict.Contains(someKey)) someVal = myDict[someKey]; ... unless I know it has to be in there. Is it better to just do: if (my...

C# Dictionary Memory Management

I have a Dictionary<string,int> that has the potential to contain upwards of 10+ million unique keys. I am trying to reduce the amount of memory that this takes, while still maintaining the functionality of the dictionary. I had the idea of storing a hash of the string as a long instead, this decreases the apps memory usage to an accept...

How to do this - python dictionary traverse and search

I have nested dictionaries: {'key0': {'attrs': {'entity': 'p', 'hash': '34nj3h43b4n3', 'id': '4130'}, u'key1': {'attrs': {'entity': 'r', 'hash': '34njasd3h43b4n3', 'id': '4130-1'}, u'key2': {'attrs': {'entity': 'c', ...

C#: What does the [string] indexer of Dictionary return?

What does the [string] indexer of Dictionary return when the key doesn't exist in the Dictionary? I am new to C# and I can't seem to find a reference as good as the Javadocs. Do I get null, or do I get an exception? ...

Why doesn't a Dictionary access nonexistent keys like a Hashtable does?

If I'm using a Hashtable, I can write code like this: object item = hashtable[key] ?? default_value; That works whether or not key appears in the Hashtable. I can't do that with a Dictionary<TKey. TValue>. If the key's not present in the dictionary, that will throw a KeyNotFoundException. So I have to write code like this: MyClass...

How do I attatch a Key value pair to a UIView on iPhone?

Hiya, When I started iPhone development, I read somewhere that it's possible to attach a key value pair to a UIView. I understood that all UIViews could be used as dictionaries to store any data you may want to attatch to them to prevent unnecessary subclassing. However, I've searched everywhere to find the reference and tried to implem...

Compression Algorithm for Encoding Word Lists

I'm am looking for specific suggestions or references to an algorithm and/or data structures for encoding a list of words into what would effectively would turn out to be a spell checking dictionary. The objectives of this scheme would result in a very high compression ratio of the raw word list into the encoded form. The only output req...

C++ Service Providers

Hi everyone, I've been learning C++, coming from C#, where I've gotten used to using service providers: basically a Dictionary<Type, object>. Unfortunately, I can't figure out how to do this in C++. So the questions are basically: How would I make a dictionary in C++. How would I use 'Type' with it, as far as I know there is no 'Type' ...

Should a .NET generic dictionary be initialised with a capacity equal to the number of items it will contain?

If I have, say, 100 items that'll be stored in a dictionary, should I initialise it thus? var myDictionary = new Dictionary<Key, Value>(100); My understanding is that the .NET dictionary internally resizes itself when it reaches a given loading, and that the loading threshold is defined as a ratio of the capacity. That would suggest ...