I'm converting some Java code to C#. Part of my code uses Google Guava TreeMultiMap to provide a mechanism to have the equivalent of a dictionary sorted by key and allows duplicate null keys).
Is there an equivalent or library available to match this, Dictionary doesn't seem to support duplicate and Lookup class doesn't seem a match either as I need to keep adding (Lookup is immutable) and I need to add null values and keep it sorted.
This is the kind of thing I'm doing with it:
//declaration section
Multimap<Location, Interconnect> interconnects;
interconnects = TreeMultimap.create(Ordering.natural(),
Interconnect.ORDER_NATURAL_NULLCHECK);
//comparator provider
static final Ordering<Interconnect> ORDER_NATURAL_NULLCHECK = new Ordering<Interconnect>() {
@Override
public int compare(@Nullable final Interconnect arg0,
@Nullable final Interconnect arg1) {
return Ordering.natural().nullsFirst().compare(arg0, arg1);
}
};
//and I can do kind of the following quite happily:
interconnects.put(new Location(), null);
interconnects.put(new Location(), null);
interconnects.put(new Location(), null);
interconnects.put(new Location(), new Interconnect("A"));
interconnects.put(new Location(), new Interconnect("A");