I'm building an Android app (so machines with limited resources) and I want to know how picky I should be with LinkedLists.
I know that arrays are the lightest containers and are the best at random access, so they're obviously the ideal choice if you only consider performance. However, their rigidness is a pain when you don't know how big your list will be.
So here's my question: is it worth it to systematically use the following type of mechanism in classes who have one or more list of unpredictable size:
public class unpredictable
public Object[]realArray;
private LinkedList<Object> temp;
//what using classes will call to add items
public void add(Object item)
{
temp.add( item );
}
//what the outer class calls when it knows there's nothing left to add
public void doneAdding()
{
realArray = new Object[tmp.size()];
transferAndRecycle();
}
private void transferAndRecycle()
{
// copy items from linkedlist to array
}
So I guess I'm asking if it's worth it to take the extra steps to get rid of the extra space Java's LinkedList object takes?
Any input? Thanks