Whenever you have a collection of objects to manage there are many factors to consider e.g.
- Is there a large amount of data?
- Is the data volatile / non-volatile? In other words will you be adding/removing objects from the collection a lot?
- Do you need to iterate over the whole collection a lot?
- Do you need to search the collection a lot e.g. for particular objects or objects to delete?
- Do the objects have some unique feature that can be used as a search key?
Since you are talking about thousands of objects then the answer to the first question is yes.
An ArrayList or LinkedList is fine if the data does not need sorting and the primary actions are iterating the collection and adding objects.
If on the other hand you are going to be removing objects or searching the collection a lot then I would avoid the ArrayList and the LinkedList.
This leaves two possible options depending on whether the data can be sorted or not.
A binary search tree e.g. a tree structure e.g. TreeSet or TreeMap holds sorted data (your object classes would have to implement the Comparable interface or objects from another class that implements the Comparitor class). Both TreeSet and TreeMap are straightforward to iterate over.
If the data cannot be sorted then you might consider the HashSet or HashMap classes. These rely on the object being the search key (set) or the object having a seperate search key (map).
In both case the set implementations in Java are based on there corresponding map implementations and generally the map is easier to work with.
In all 4 cases (TreeSet, TreeMap, HashSet, HashMap) the collection can only store unique values / keys so you must consider this when designing your object classes.
Oracle provide quite a bit of info on the
Java Collection Framework
Unless there is dire need I would avoid trying to create your own collections class. I have found that in most cases the Java collections are enough and on the odd occasion I need something special then a collection of collections may do what I want. For instance the code below comes from a game AI library I am developing that uses partitioning to improve performance. It works by breaking the world into partitions each identified by a Point and for each partition a HashSet for any items in that partition.
// For use with partitions
private HashMap<Point, HashSet<Building>> building_parts;
private HashMap<Point, HashSet<Wall>> wall_parts;
private HashMap<Point, HashSet<Obstacle>> obstacle_parts;
private HashMap<Point, HashSet<MovingEntity>> moving_parts;
The moving entities are forever being removed and added to partitions as they move accross boundaries, so I needed a fast way of finding a particular partition and then a fast way of adding/removing items in that partition as well as fast iteration to process collision detection, steering behaviours etc. If you are interested you can see an example of the library in action
here.
With regard to drawing the tiles, if you have a fairly steady background and a lot of images being used to make it then using an off-screen buffer for the background would probably improve performance.
HTH