Data Structures and Algorithms with Object-Oriented Design Patterns in C#
next up previous contents index

Finding the Position of an Item and Accessing by Position

The FindPosition method of the OrderedListAsLinkedList class is used to determine the position of an item in an ordered list implemented as a linked list. Its result is an instance of the inner class MyCursor. The FindPosition method is defined in Program gif

   program9615
Program: OrderedListAsLinkedList class FindPosition method

The FindPosition method takes as its argument a ComparableObject that is the target of the search. The search algorithm used by FindPosition is identical to that of Find, which is given in Program gif. Consequently, the running time is the same: tex2html_wrap_inline60791, where tex2html_wrap_inline60789 is the time required to match two ComparableObjects, and tex2html_wrap_inline60465 is the number of items in the ordered list.


next up previous contents index

Bruno Copyright © 2001 by Bruno R. Preiss, P.Eng. All rights reserved.