I’m building a simple shape designer it’s simple enough – add shapes to an area and you can resize them and move them by dragging and dropping – think the form designer in VS.
At present I have a base class of Shape which represents common properties (Location, Size) and methods. Other classes representing objects on the designer inherit from Shape e.g. Circle, Square etc. I store the objects in a generic list e.g. List<Shape>
My question is about List vs. other generic data structures, and when to use them.
Edit: Thanks to Mathias for pointing out what I really meant.
Cheers
It really depends. One of the main concerns should be how you are using the list of shapes. The speed of access, insertion, and removal will change depending on the type of collection you use.
For example:
List<T>is appropriate.LinkedList<T>or a similar structure may be beneficial. This provides fast enumeration, but much quick insert or removal than aList<T>(especially if you’re removing from the middle of the list).