particularly if not at start/end
Linked Lists
Strengths | Weaknesses |
Inserting and deleting elements | Direct access requires traversal of the list |
Iterating through the collection | Searching and sorting (same as direct access) |
Stacks and Queues
Strengths | Weaknesses |
Design for LIFO/FIFO | Direct access |
| Searching and sorting |
Hash Tables
Strengths | Weaknesses |
Speed of insertion and deletion | Some overhead |
Speed of access | Retrieving in a sorted order |
| Searching for a specific value |
Sets
Strengths | Do not use for |
Checking existence | Direct access |
Avoiding duplicates | |
Binary Search Trees
Strengths | Weaknesses |
Speed for insertion and deletion | Some overhead |
Speed of access | |
Maintaining sorted order | |
Other things to consider are:
- Fixed structures are faster and smaller.
- Choose fixed (immutable) structures whenever is possible.
- Use mutable structures so you can load it up with unpredictable amounts of data. Consider then copying it into an immutable one if all you need to do from then on is only accessing the data.