You shouldn't care about the concrete type at all. Declare the variable like this:
Then when you add a new link, you can get the neighbor vertices like this:
I just wish they had overloaded comuteIfAbsent to not only take a Function<Key, Value> but also a Supplier<Value>. That would have allowed ArrayList::new instead of k -> new ArrayList<>().
I feel ya. One thing that often annoys me is when I use compute() to replace a value in the map, based solely the old value. It's really the same issue, it would be nice if they added
Post by:autobot
It's hard to fight evil. The little things, like a nice sandwich, really helps. Right tiny ad?
a bit of art, as a gift, that will fit in a stocking