Java API whine
Object resize(int newSize)
Ideally this would be something like
T[] resize(int newSize)
but Java's templates don't really provide support for that that is worth it... so I'd prefer the first. While I'm complaining, I'd like Microsoft to add it to .Net as well.
Why? Because when you care about performance, ArrayList/Vector just don't cut it. I've seen some dramatic performance improvements by moving from ArrayList to object arrays. And when the value is something like 'int' which isn't an Object, you have no choice anyway. At least .Net Generics got that right. If that resize method was there I could replace code that looks like this:
... important stuff ...
... important stuff ...
if (index == array.length)
{
Foo[] temp = new Foo[index*2];
System.arraycopy(array, 0, temp, 0, index);
array = foo;
}
... important stuff ...
... important stuff ...
with this:
... important stuff ...
... important stuff ...
if (index == array.length)
array = (Foo[]) array.resize(index*2);
... important stuff ...
... important stuff ...
Some people will complain that I dropped the curly brackets, blah blah blah. That resize in only there because the builtin libraries are slow! It isn't topical to the code and hand and should be a small and insignificant as possible. That simple resize() method allow me to write it in a way that is out-of-the-way. That is how it should be.
I can dream, can't I?