< previous page page_1089 next page >

Page 1089
            //     All nodes before current first node in list
            //     have been deallocated

        RemoveTop(temp);
}

//******************************************************************

int CardPile::Length() const

// Postcondition:
//     Function value == listLength

{
    return listLength;
}

//******************************************************************

CardType CardPile::CardAt( /* in */ int n ) const

// Precondition:
//     l <= n <= listLength
// Postcondition:
//     Function value == card member of list node at position n

{
    int     count;              // Loop control variable
    NodePtr currPtr = head;     // Moving pointer variable

    for (count = 1; count << n; count++)

            // Invariant (prior to test):
            //      l <= count <= n
            //  && currPtr points to the list node at
            //       position count

        currPtr = currPtr->link;
    return currPtr->card;
}

//******************************************************************

void CardPile::InsertTop( /* in */ CardType newCard )

// Precondition:
//     newCard is assigned

 
< previous page page_1089 next page >