++



         

- 11


void ilist::concat( const ilist &i1 ) {

if ( ! _at_end )

_at_front = i1._at_front;

else _at_end->next( i1._at_front );

_at_end = i1._at_end;

}

, ilist . , insert() remove(), , .   . insert_end():

void ilist::

concat( const ilist &i1 )

{

i1ist_item *ptr = i1._at_front;

while ( ptr ) {

insert_end( ptr->value() );

ptr = ptr->next();

}

}

reverse():

void

ilist::

reverse()

{

ilist_item *ptr = _at_front;

ilist_item *prev = 0;

_at_front = _at_end;

_at_end = ptr;

while ( ptr != _at_front )

{

ilist_item *tmp = ptr->next();

ptr->next( prev );

prev = ptr;

ptr = tmp;

}

_at_front->next( prev );

}

:

#include <iostream>

#include "ilist.h"

int main()

{

ilist mylist;

for ( int ix = 0; ix < 10; ++ix )

{ mylist.insert_front( ix ); }

mylist.display();

cout << "\n" << " \n";

mylist.reverse(); mylist.display();

ilist mylist_too;

mylist_too.insert_end(0); mylist_too.insert_end(1);

mylist_too.insert_end(1); mylist_too.insert_end(2);

mylist_too.insert_end(3); mylist_too.insert_end(5);

cout << "\n" << "mylist_too:\n";

mylist_too.display();

mylist.concat( mylist_too );

cout << "\n"

<< "mylist concat mylist_too:\n";

mylist.disp1ay();