/*
This function sets Success to true if the list contains an
element with key matching theKey. Otherwise it sets it to
false.
In the case Success=true, the value returned by the function is
the position the matching element has in the list.
In the case Success=false, the value returned is the position
an element with key value equal to theKey should have.
If all the elements in the list have keys smaller than theKey,
then a new element with key equal to theKey should be appended
at the end of the list. Otherwise, the position should be the
position of the first element in the current list with key
greater than theKey.
*/
int PosOfKey (keyType theKey, bool& Success) const
{
Position <-- 1;
while (Position <= lastPosition in list)
AND (the list element at Position has key smaller
than theKey)
do add 1 to Position ;
if Position is now more than lastPosition then Success <-- false
else if the list element at Position has key equal to theKey
then Success <-- true
else Success <-- false ;
return the value of Position ;
}