dictionary

C# Linq Result ToDictionary Help

I have a lambda expression that gets results from a Dictionary. var sortedDict = (from entry in dctMetrics orderby entry.Value descending select entry); The expression pulls back the pairs I need, I can see them in the IDE's debug mode. How do I convert this back a dictionary of the same type as ...

How do I find next largest key in a collection?

Suppose I have a dictionary in C#. Assuming the keys are comparable, how do I find the smallest key greater than a given k (of the same type as the keys of the dictionary)? However I would like to do this efficiently with a collection like a SortedDictionary. Clearly, if it were not a question of doing it efficiently one could start w...

UITableView from plist dictionary KEYS iPhone

I am attempting to get the name of the custom ringtones in the itunes directory on the iPhone. I can successfully list the custom ringtones, but they re displayed as HWYH1.m4r, which is what iTunes renames the file, but I know theres a way to decipher the actualy name of the song, for example: UHHEN2.m4r = TheSongName. NSMutableDict...

How to use pyparsing to parse and hash strings enclosed by special characters?

The majority of pyparsing examples that I have seen have dealt with linear expressions. a = 1 + 2 I'd like to parse mediawiki headlines, and hash them to their sections. e.g. Introduction goes here ==Hello== foo foo ===World=== bar bar Dict would look like: {'Introduction':'Whoot introduction goes here', 'Hello':"foo\nfoo", 'World...

How to reset a Dictionary.

Hello. If I declared a dictionary like this. private static Dictionary<string, object> aDict = new Dictionary<string, object>(); And i still want to use it at another place. How to reset it? aDict = new Dictionary<string, object>(); // like this? aDict = null; // Like this ? or other reset styles? THANK YOU. I love the site, ...

Complex Dictionary Print

Hi Guys. I created a complex dictionary. mainDict<mainKey, SubDict> subDict<subKey, sub1Dict> sub1Dict<sub1Key, sub2Dict> sub2Dict<sub2Key, sub2Value> ....... How to print it out like this (vs2005 & .net 2.0 based) mainKey/subKey/sub1Key/sub2Key, sub2Value Do i need convert mainDict to a List and call join()? thank you. ...

How to iterate through Dictionary without using foreach

I am not sure if the title formulates it well so sorry. I basically have a bunch of elements listing targets for a communication. I placed them in a dictionary though i am open to moving them to a different data structure. My problem is that i have a tree-like structure where a key is a branch and each branch has many leaves. Both the...

In Python, what does dict.pop(a,b) mean?

class a(object): data={'a':'aaa','b':'bbb','c':'ccc'} def pop(self, key, *args): return self.data.pop(key, *args)#what is this mean. b=a() print b.pop('a',{'b':'bbb'}) print b.data self.data.pop(key, *args) ------ why is there a second argument? ...

How do I trust the order of a Python dictionary?

I'm trying to make a dictionary in Python that I can sort through but it seems to change order when I add new things. Is there a way around this? ...

How to detect a Dictionary included a subDictionary or not?

Hi, I declared a static mainDict like this, private static Dictionary<string, object> mainDict = new Dictionary<string, object>(); Dictionary<string, object> aSubDict = new Dictionary<string,object>(); mainDict.Add("StringA0Key", "StringValue"); mainDict.Add("StringA1Key", aSubDict); How to detect the Value Type is a string(StringValu...

pass dictionary to controller asp.net mvc

I am wanting to pass a dictionary of type <int,int> to my controller via an Ajax post. The main reason here is the post may have between 1-3 key value pairs here (none of these values are known at compile time) and in the future it may go up to 5. Also in the post I have to pass in some other data, such as Id and name, which all works a...

In Java, which is the most recommended class for a dictionary data structure?

I need a data structure to store users which should be retrieved by id. I noticed there are several classes that implement the Map interface. Which one should be my default choice? They all seem quite equivalent to me. ...

Using int as a type parameter for java.util.Dictionary

When I try to declare a Dictionary as such: private Dictionary<String, int> map; The compiler gives me the following error: Syntax error on token "int", Dimensions expected after this token But it works fine with Integer. I'm vaguely aware that java treats int / Integer differently (I come from a .NET background), but I was hopi...

How to Get Dictionary TValue from TKey in C#?

Hi, I declared the dictionary obj. Dictionary<string, string> aDict = new Dictionary<string, string>(); aDict .Add("IP", "Host"); As I remembered, The expression of aDict[IP] can return the value (Host). Now if I go in the opposite direction. How to get the Key from Value ? aDict[Host] ? Does the Dictionary is a one-way...

C#: Issues using dictionary with languages other than english

Ok, so i'm basically trying to load the contents of a .txt file that contains 1 word per line into a dictionary. I had no problems doing so when the words in that file were in english, but changing the file to a language with accents, i started having problems. Had to change the encoding while creating the stream reader, also the cultu...

Using a list objects to look up items in a dictionary in Python

I have a a wxPython checklist box that returns a list of integers. I want to use the integers to look up items in a dictionary. I am not really sure the best way to do this. Any suggestions? ...

Dictionary<int [], bool> - compare values in the array, not reference?

Hi, I am using dictionary for storing ID,otherID and bool value. Unfortunately it compares array reference, therefore I cannot use it. Is there any way how to have an array as key but compare its values instead of reference? Thanks ...

C# Dictionary ContainsValue look up by object attribute

Hello, I have Dictionary<long, Location> PostalCodes . While i m adding new elements to this Dictionary I want to make a lookup to this dictionary and if the Location.PostalCode is not in this dictionary, I want to insert it. Otherwise I want to skip it. So , need to know if the PostalCode is already in the Collection. Cant use it as ...

How can I keep from generating inappropriate words when autogenerating strings from an alphabet?

Is there a downloadable dictionary (essentially just a textfile) that contains common swear or otherwise inappropriate words in different languages? Background: I'm rewriting an URL Shortener (Just a Proof of Concept app - the world has enough shorteners already anyway) and for that I convert Numeric IDs into Strings by Base36 encoding ...

List to Anonymous Type in c#

The short story: I want to convert a list/dictionary into an anonymous object Basically what I had before was: var model = from item in IEnumerable<Item> select new { name = item.Name value = item.Value } etc. If I have name, item.Name in a list or dictionary, how can I go about creating the same anonymous obje...