dictionary

how to concatenate two dictionaries to create a new one in Python?

Say I have three dicts d1={1:2,3:4}, d2={5:6,7:9}, d3={10:8,13:22}, how do I create a new d4 that combines these three dictionaries. i.e d4={1:2,3:4,5:6,7:9,10:8,13:22}? ...

Dictionary with two hash functions in C# ?

I've got a huge (>>10m) list of entries. Each entry offers two hash functions: Cheap: quickly computes hash, but its distribution is terrible (may put 99% of items in 1% of hash space) Expensive: takes a lot of time to compute, but the distribution is a lot better also An ordinary Dictionary lets me use only one of these hash functio...

Tuples in Dicts

Is it possible in python to add a tuple as a value in a dictionary? And if it is,how can we add a new value, then? And how can we remove and change it? ...

how to fetch DictionaryEntry object from Hashtable?

I know the value of key for my Hashtable, from key how can I obtain the object of DictinaryEntry. I don't want to Iterate over Hashtable. ...

Make Dictionary From 2 List

trying to make dictionary with 2 list one being the key and one being the value but I'm having a problem. This is what I have so far: d={} for num in range(10): for nbr in range(len(key)): d[num]=key[nbr] say my key is a list from 1 to 9 and value list is [2,4,0,9,6,6,8,6,4,5] how do i assign so it that its like {0:2, 1:4, et...

How to avoid double check locking when adding items to a Dictionary<> object in .NET?

I have a question about improving the efficiency of my program. I have a Dictionary<string, Thingey> defined to hold named Thingeys. This is a web application that will create multiple named Thingey’s over time. Thingey’s are somewhat expensive to create (not prohibitively so) but I’d like to avoid it whenever possible. My logic for ...

Trying to convert xml to a dictionary

My xml looks like: <root> <blah1>some text</blah1> <someother>blah aasdf</someother> </root> I want to convert this to a dictionary So I can do: myDict["blah1"] and it returns the text 'some text' So far I have: Dictionary<string,string> myDict = (from elem in myXmlDoc.Element("Root").Elements() ...

can't I use TryGetValue and assign the value to a property?

I'm trying to do myDic.TryGetValue("username", out user.Username); but its not working. is this not possible? ...

Easy way to convert a Dictionary<string, string> to xml and visa versa

Wondering if there is a fast way, maybe with linq?, to convert a Dictionary into a XML document. And a way to convert the xml back to a dictionary. XML can look like: <root> <key>value</key> <key2>value</key2> </root> ...

Use a Plist dictionary for App settings

I want to be able to use a plist for settings Im implementing in my app. I want a dictionary "Settings" to hold my arrays, such as "Debug", "Option 1", Option 2", etc. How would I access "Debug"array under the "Settings" dictionary? This is what my code looks like: NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirect...

how to fetch data from nested Dictionary in c#

I need to fetch data from nested Dictionary IN C#. My Dictionary is like this: static Dictionary<string, Dictionary<ulong, string>> allOffset = new Dictionary<string, Dictionary<ulong, string>>(); I need to fetch all keys/values of the full dictionary, represented like so: string->>ulong, string Thanks in advance. ...

how to fetch data from nested Dictionary in C# code

I need to fetch data from nested Dictionary IN C#. My Dictionary is like this: static Dictionary<string, Dictionary<ulong, string>> allOffset = new Dictionary<string, Dictionary<ulong, string>>(); I need to fetch all keys/values of the full dictionary, represented like so: string->>ulong, string Thanks in advance. ...

Simple way to convert a string to a dictionary

What is the simplest way to convert a string of keyword=values to a dictionary, for example the following string: name="John Smith", age=34, height=173.2, location="US", avatar=":,=)" to the following python dictionary: {'name':'John Smith', 'age':34, 'height':173.2, 'location':'US', 'avatar':':,=)'} The 'avatar' key is just to sho...

Type inheritance in Dictionary<ulong,BaseObject>

Hi to all. Here's the situation: There's a base class of type BaseObject ,from which all other classes are derived(i.e. Task : BaseObject). There's also a base class collection of type BaseObjectCollection which inherits from Dictionary<ulong,BaseObject> and some other collections that inherit from it (i.e. TaskCollection:BaseObjectColle...

Custom dictionary object ?

I want to extend the VB.NET dictionary object to not bitch about an item being already in the associative array. This is what i want to do: Public Class BetterDictionary Inherits System.Collections.Generic.Dictionary(Of Object, Object) Public Sub Store(ByRef key As Object, ByVal value As Object) If Me.ContainsKey(k...

list? dictionary? array?

hi all i'm trying to come up with a very simple way to store a boolean value for each tabpage in a tabcontrol. each page has a textbox, and i would like to store a bool foreach page so if tabpage 1 has been saved, then bool1 is set to true, else false, and so on. then when they go to close the program it will go over all the tabpages a...

Convert a dictionary<string,string> to xml

I want to convert a dictionary<string,string> to this xml: <root> <key>value</key> <key2>value2</key2> </root> Can this be done using some fancy linq? ...

Dictionaries in DataTable

Say I have 3 Dictionary<string, string> objects. All 3 have the same key like so: Dic1 Dic2 Dic3 K V K V K V A s A z A i B d B e B u C a C r C o D w D t D p Now, I would want to combine these dictionaries in to one DataTable, the DataTable should look like: A s z i B d e u C a r o D w t p An...

Varying amount of dictionaries in a DataTable

Earlier I asked a question about merging a known number of dictionaries into 1 single DataTable: http://stackoverflow.com/questions/1831209/dictionaries-in-datatable Darin provided me with a satisfactory solution to the problem at hand. But my problemset has evolved. I can no long be certain of the amount of dictionaries I get supplied. ...

Can you have hash tables in lisp?

Can you have hash tables or dicts in Lisp? I mean the data structure that is a collection of pairs (key, value) where values can be acceded using keys. ...