MatthewRueben / sock-pairing

Try several sock pairing algorithms as an exercise in writing beautiful Java.
MIT License
0 stars 0 forks source link

Put the sock sequence copier into its own (generic?) method. #22

Closed MatthewRueben closed 3 weeks ago

MatthewRueben commented 3 weeks ago

Maybe I don't even need to make a copy since (1) we don't try to modify field ID, and it's final anyway, (2) we don't try to delete any sock objects, and you can't really do that in Java, anyway, and (3) the sock sequence is already in a separate List from the one in the instances field of a MatchablePool, so removing it from the first list doesn't make it eligible for garbage collection yet. Try it!

MatthewRueben commented 3 weeks ago

Gah! I forgot that Collections2::orderedPermutations returns an ImmutableList (but calls it a List even though you can't call, e.g., removeFirst() on it?!)...ok, but I figured out an easy way to make a (mutable) ArrayList with the same contents. cf02148f82f14d8fe05c8473833640a1fc58333c