Exemple #1
0
int main()
{
    DLinkedList<string> Dl;
    Dl.addFront("World");
    Dl.addFront("Hello");
    Dl.addBack("It's a");
    Dl.addBack("C++ Prog");
    Dl.addBack("Doubly linkedlist");
    Dl.printList();
    cout<<endl<<endl;

    Dl.reverse(Dl);
    Dl.printList();
    cout<<endl<<endl;

    Dl.removeFront();
    Dl.removeBack();
    Dl.printList();
    cout<<endl<<endl;

    return 0;
}
Exemple #2
0
void DLinkedList<E>::reverse(DLinkedList& L)
{
    DLinkedList T;
    while(!L.empty())
    {
        string s=L.front();
        T.addFront(s);
        L.removeFront();
    }
    while(!T.empty())
    {
        string s= T.front();
        L.addBack(s);
        T.removeFront();
    }
}