>>> You could use instead LinkedHashSet for instance.
>> The obvious implementation would be to copy the set into a list.
[quoted text clipped - 4 lines]
> (I speak from too much sad experience -- coding even moderately complicated
> array-oriented algorithms without the benefit of array syntax is painful.)
[me:]
> > I'd think an array would be better. The performance might not be much
> > better but the code would be a lot clearer.
[quoted text clipped - 6 lines]
> The other week I wrote some code using BigIntegers. Yuck. However, I
> don't think it should really be much of a problem here.
It depends on the algorithms you are trying to express. My own code in this
sort of area (permutations, combinations, and whatnot) is rather array heavy.
I know -- 'cos it's written in a language which lacks C-style array access
syntax (albeit not as bad as Java Collections) -- that the lack of array syntax
hurts badly.
> The real problem is ye olde arrays don't mix well with generics. It
> needs either an Object array and (T)set.get(i), or (T[])set.toArray().
> Stick with Dr Bloch's collections, and everything will be fine.
If it comes down to a choice between writing code of adequate clarity, and
using generics, then I'm afraid that generics will loose every time -- no
contest at all. If Dr Bloch's Collections are so tangled up with generics that
they have to be chucked out too, then so be it.
There are plenty of cases where ArrayLists are to be preferred to raw arrays, I
agree, but this is most definitely not one of them.
-- chris