//////////////////////////////////////
// START of File: C0_STACK.CPP
//////////////////////////////////////


//===================================================================
//
// COPYRIGHT NOTICE:  This code is protected by Copyright!
//
// Copyright (c) 1994, 1995, 1996, 1997 by DPC Technology.
// All rights reserved.
//
// See files "cf_copyr.h" and "cf_licen.h" for details of
// copyright and license specifications, and contact information.
//
//===================================================================

#include	<stdio.h>
#include	<cf_api/bf_defs.h>
#include    <cf_api/c0_stack.hpp>


class cf_StackNode
{
public:
	void*			data_;
	cf_StackNode*	next_;
};



cf_Stack::cf_Stack()
{
	head_ = NULL;
}



cf_Stack::~cf_Stack()
{
	while (pop() != NULL);
}




void
cf_Stack::push
		( void* item)
{
	cf_StackNode*		new_node = new cf_StackNode;

	new_node -> data_ = item;
	new_node -> next_ = head_;
	head_ = new_node;
}




void*
cf_Stack::pop()
{
	void*			head_data;
	cf_StackNode*	old_head;


	if (head_ == NULL)
		return (NULL);

	old_head = head_;
	head_data = head_ -> data_;

	head_ = head_ -> next_;
	delete old_head;

	return (head_data);
}





void*
cf_Stack::top()
{
	if (head_ == NULL)
		return (NULL);

	return (head_ -> data_);
}


//////////////////////////////////////
// END of File: C0_STACK.CPP
//////////////////////////////////////




