C M S C     2 1 4
C o m p u t e r   S c i e n c e   I I
F a l l   2 0 0 2


ItemSortedList Specifications, Part 2

Updates

None so far.

Main Part

Three modifications made to this class.

The reason for the changes is to make it easier to templatize the class.

ItemSortedList

Modify the following public methods.

Public Methods

bool remove( const Item & other ) ;
Remove a Item object from the DLL, with the same name as other (the points are ignored when checking if item is in the list). Return true if such a node was successfully removed. Return false if the node is not in the tree, and therefore not removed.

You MUST use locate() to implement this method.

locate() does its comparisons based on the relational operators defined on Item.

bool contains( const Item &dataIn ) const ;
Even though contains() now takes an Item as argument, you compare items based on operator== defined in Item which only compares the name of the item, while ignoring points. It still behaves the same way as it did before, when string was the parameter.

You MUST use locate() to implement this method. locate() does its comparisons based on the relational operators defined on Item.

(10/13) Added const to method

Private Methods

bool locate( const Item & keyIn,
             ItemSortedList::Node * & curr ) const ;
locate() now takes an Item reference. Use the relational operators of Item to do the comparison. However, once you templatize it, you will use the Comparator object to do the comparison.

This change affects how add(), remove(), contains(), and update() makes its calls (but only just a little).


See the class syllabus for policies concerning email
Last Modified: Tue Sep 17 19:01:23 EDT 2002
left up down right home

Web Accessibility