Tag Archives: dictionary

Why is a Dictionary “not ordered”?

Questions: I have read this in answer to many questions on here. But what exactly does it mean? var test = new Dictionary<int, string>(); test.Add(0, “zero”); test.Add(1, “one”); test.Add(2, “two”); test.Add(3, “three”); Assert(test.ElementAt(2).Value == “two”); The above code seems to work as expected. So in what manner is a dictionary considered unordered? Under what circumstances… Read More »

No generic implementation of OrderedDictionary?

Questions: There doesn’t appear to be a generic implementation of OrderedDictionary (which is in the System.Collections.Specialized namespace) in .NET 3.5. Is there one that I’m missing? I’ve found implementations out there to provide the functionality, but wondered if/why there isn’t a generic implementation out-of-the-box and if anyone knows whether it’s something in .NET 4.0? Answers:… Read More »

VBA I can't work Exists method with Dictionary

Questions: Dim memberDic As Object: Set memberDic = CreateObject(“Scripting.Dictionary”) Set memberDic(“Team A”) = CreateObject(“Scripting.Dictionary”) memberDic(“Team A”)(“Tanaka”) = 1 memberDic(“Team A”)(“Watanabe”) = 2 memberDic(“Team A”)(“Shimizu”) = 3 For Each person In ActiveSheet.PivotTables(fy).PivotFields(“name”).PivotItems If Not memberDic(“Team A”).Exists(person.Name) Then ‘hidden person except Team A End If Next person I’d like to excluse item with Exists method. Could you… Read More »

'NSFetchedResultsController does not support both change tracking and fetch request's with NSDictionaryResultType'

Questions: I have an application that was running just fine under OS3+. But it does not work under OS4. I get the following error message: ‘NSFetchedResultsController does not support both change tracking and fetch request’s with NSDictionaryResultType’ Does it ring a bell to anyone here? – (NSFetchedResultsController *)fetchedResultsController { if (fetchedResultsController != nil) { return… Read More »

UIWebView and define dictionary

Questions: I had the copy and define option built in with the UIWebView. It worked just fine on the iPad but on the iPhone, it only works once when I highlight the text and use the dictionary and the second time I tried it, it doesn’t show up the popover. Any idea? UPDATE: I am… Read More »

Traversing key/values of an NSDictionary, is enumerateKeysAndObjectsUsingBlock more efficient than looping keys and calling objectForkey:?

Questions: I need to traverse all key/values pairs of a dictionary and do something with both fields. I am wondering what is more efficient, the traditional ‘foreach key’ approach or the blocks approach using enumerateKeysAndObjectsUsingBlock:. Here you have an example: Traditional approach (before blocks) for (NSString* key in [self.dictionary allKeys] ) { [self processKey:key value:… Read More »