Set
Figure 11 – Set collectable classes
1. Are duplicates allowed? Some collections disallow the insertion of an item equal to an item already in the collection. Other collections do permit duplicates, and have various ways to hold multiple matching items. The Essential Tools Module collections provide mechanisms for both checking for duplication and holding the duplicates.
2. Is the order of data meaningful? Some collections allow you to control the location of data within the collection. If you need to access data in a particular order, or based on a numeric index, then order is meaningful.
3. What is the storage method for duplicates? Duplicate items can be stored in a collection either as individual items or by a count of duplicates.
4. What is the comparison method when duplicates are not allowed? Key comparison uses either key equality in which the key must be equal, or key identity in which the key must reference the same address.
Figure 12 – Set template classes
1. Are duplicates allowed? Some collections disallow the insertion of an item equal to an item that is already in the collection. Other collections do permit duplicates, and have various ways to hold multiple matching items. The Essential Tools Module collections provide mechanisms for both checking for duplication and holding the duplicates.
2. Is the order of data meaningful? Some collections allow you to control the location of data within the collection. If you need to access data in a particular order, or based on a numeric index, then order is meaningful.
3. Use some extra memory in return for constant-time lookup by key? Achieve faster access by increasing each item’s memory requirement.