java - Looking for the right collection - bidirectional unique pairs -
i need collection in java represents next info structure: if next inputs need store them described below:
a->b //should stored
a->c //should stored
a->b //should not allowed (stored) anymore in collection already
b->a //should not allowed (stored) a->b in collection
c->b //should stored
d->c //should stored
i hope idea.
i tried hashmap<set<string>, set<string>> mutating keysets goes wrong, described here: http://stackoverflow.com/a/2393748/2346207
you utilize java.util defaults also, illustration set of sets:
hashset<hashset<string>> h = new hashset<hashset<string>>(); h.add(new hashset<string>(arrays.aslist("a", "b"))); h.add(new hashset<string>(arrays.aslist("b", "a"))); // ignored h.add(new hashset<string>(arrays.aslist("b", "c"))); // ok, new fellow member a bit wordy in java oneliners, works.
java collections
No comments:
Post a Comment