(^544) | Array-Based Lists
The first thing we notice is that the observers do not change.They remain the same whether
the list is sorted by value or not. The transformersinsertanddeleteand the iterator now have
additional constraints, however. Rather than designing an entirely new class, we can derive
SortedListfromList, overriding those methods whose implementations need changing.
Class Name: SortedList Superclass: List Subclasses:
Responsibilities Collaborations
Create itself (maxItems) None
Insert into list (item), keeping the list sorted String
Delete from list (item), keeping the list sorted String
Look at each item in sorted order String
Class Name: List Superclass: Object Subclasses:
Responsibilities Collaborations
Create itself (maxItems) None
Is list full? None
return boolean
Is list empty? None
return boolean
Know length
Delete from list (item), keeping list sorted
None
return int
None
Set up for iteration None
Know next item in sorted order None
return boolean
Insert into list (item), keeping list sorted None
Is an item in the list? None
やまだぃちぅ
(やまだぃちぅ)
#1