A KeyValuePair in Java [duplicate]

This question already has answers here: A Java collection of value pairs? (tuples?) (21 answers) Closed 2 years ago. I’m looking for a KeyValuePair class in Java. Since java.util heavily uses interfaces there is no concrete implementation provided, only the Map.Entry interface. Is there some canonical implementation I can import? It is one of those … Read more

How do you create a dictionary in Java? [closed]

It’s difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 9 years ago. The community reviewed whether to reopen this question … Read more

for each loop in Objective-C for accessing NSMutable dictionary

I am finding some difficulty in accessing mutable dictionary keys and values in Objective-C. Suppose I have this: NSMutableDictionary *xyz=[[NSMutableDictionary alloc] init]; I can set keys and values. Now, I just want to access each key and value, but I don’t know the number of keys set. In PHP it is very easy, something as … Read more

The default for KeyValuePair

I have an object of the type IEnumerable<KeyValuePair<T,U>> keyValueList, I am using var getResult= keyValueList.SingleOrDefault(); if(getResult==/*default */) { } else { } How can I check whether getResult is the default, in case I can’t find the correct element? I can’t check whether it is null or not, because KeyValuePair is a struct. 8 Answers … Read more

How to remove elements from a generic list while iterating over it?

I am looking for a better pattern for working with a list of elements which each need processed and then depending on the outcome are removed from the list. You can’t use .Remove(element) inside a foreach (var element in X) (because it results in Collection was modified; enumeration operation may not execute. exception)… you also … Read more

Java Class that implements Map and keeps insertion order?

I’m looking for a class in java that has key-value association, but without using hashes. Here is what I’m currently doing: Add values to a Hashtable. Get an iterator for the Hashtable.entrySet(). Iterate through all values and: Get a Map.Entry for the iterator. Create an object of type Module (a custom class) based on the … Read more