Esempio n. 1
0
int main(int argc,char** argv)
{
	LList* l = new LList();
	l->add(1)->p()->add(2)->p()->add(4)->p()->add(10)->p()->add(80)->p();
	l->reverse()->p();
	l->remove(44)->p()->remove(2)->p()->remove(10)->p()->remove(80)->p()->remove(1)->p()->remove(4)->p()->remove(99)->p();


	StackL* s = new StackL();
	s->push(1)->p()->push(2)->p()->push(5)->p()->push(3)->p();
	s->pop();
	s->p();
	s->pop();
	s->p();
	s->pop();
	s->p();
	s->pop();
	s->p();

	QueueL* q = new QueueL();
	q->enq(1)->p()->enq(2)->p()->enq(5)->p();
	q->dq()->p()->dq()->p()->dq()->p();

	return 0;
}
Esempio n. 2
0
int main()
{

	LList<int> llist;
	LList<int>::iterator it = llist.begin();
	LList<int>::iterator it2 = llist.end();
	it2 = LList<int>::iterator(it);
#if 1
	it  = llist.insert(it,1);
	it  = llist.insert(it,2);
	it  = llist.insert(it,3);
	it = llist.begin();
	cout<<"--------insert-------------"<<endl;
	for(;it != llist.end();it++)
		cout<<*it<<endl;

	llist.clear();

	llist.push_back(11);
	llist.push_back(12);
	llist.push_back(13);
	llist.erase(llist.begin());
	cout<<"--------push_back-------------"<<endl;
	for(it=llist.begin();it != llist.end();it++)
		cout<<*it<<endl;
	llist.clear();
	cout<<"--------size-------------"<<llist.size()<<endl;
	llist.push_back(14);
	llist.push_back(15);
	llist.push_back(16);
	for(it=llist.begin();it != llist.end();it++)
		cout<<*it<<endl;
	cout<<"--------transfer-------------"<<llist.size()<<endl;
	LList<int>::iterator first= ++llist.begin();
	LList<int>::iterator last= llist.end();
	llist.transfer(++llist.begin(),++first,last);
	for(it=llist.begin();it != llist.end();it++)
		cout<<*it<<endl;
	cout<<"--------reverse-------------"<<llist.size()<<endl;
	llist.reverse();
	for(it=llist.begin();it != llist.end();it++)
		cout<<*it<<endl;
#endif		
	return 0;
}
Esempio n. 3
0
void main() {

	//new list
	LList myList;
	int listCount;
	
	
	myList.Append(456);
	myList.Append(22);
	myList.Append(4);
	myList.Append(1095);
	myList.Append(1888);
	
	//myList.AppendMiddle(499, -1);	//test for entering negative position

	//myList.AppendMiddle(423, 4);

	myList.Print();
	cout << "Number of items in list: " << myList.ListLength() << endl << endl;
	
	cout << "Deleting a node... " << endl;
	myList.Delete(456);
	cout << "\n\n";
	myList.Delete(10);		//test for deleting a non-existent node
	cout << "Number of items in list: " << myList.ListLength();
	cout << "\n\n";
	myList.Print();
	

	cout << "\nTail: " << myList.Tail()->Data();

	//reverse the list
	myList.reverse();
	cout << "\n\nList reversed: ";
	myList.Print();
	cout << "Head: " << myList.Head()->Data();		//returns the head of the list
	
	getchar();		//pause console exit to examine output
}