Return to Snippet

Revision: 35916
at November 15, 2010 06:12 by ppofuk


Initial Code
#ifndef ATP_STOG
#define ATP_STOG

#ifdef STACK_TYPE

#define _S_NAME stog
#define _S_INIT InitS
#define _S_P_NAME S
#define _S_EMPTY_NAME IsEmpty
#define _S_TOP_NAME TopS
#define _S_TOP PushS
#define _S_ADD_E x
#define _S_POP PopS
#define STACK_TYPE_LIST

typedef STACK_TYPE element_t;
typedef struct _stack
{
	element_t element; 
	_stack *next;
} _S_NAME; 

#define _NEW_STACK(name) \
	_S_NAME *name = new _stack

static inline void _S_INIT (_S_NAME* _S_P_NAME)
{
	_S_P_NAME->next = NULL;
} 

static inline bool _S_EMPTY_NAME (_S_NAME* _S_P_NAME)
{
	return (_S_P_NAME->next == NULL);
} 

static inline element_t _S_TOP_NAME (_S_NAME* _S_P_NAME)
{
	return _S_P_NAME->next->element;
} 

static inline void _S_TOP (element_t _S_ADD_E ,_S_NAME* _S_P_NAME)
{
	_S_NAME *_new_stack = new _stack;
	_new_stack->next = _S_P_NAME->next;
	_new_stack->element = _S_ADD_E;
	_S_P_NAME->next = _new_stack;
} 

static inline void _S_POP (_S_NAME * _S_P_NAME)
{
	_S_NAME *_del_stack = _S_P_NAME->next;
	_S_P_NAME->next = _del_stack->next;
	delete _del_stack;
} 

#endif
#endif

Initial URL

                                

Initial Description

                                

Initial Title
Implementacija stoga pomocu pokazivaca

Initial Tags
list

Initial Language
C++