Return to Snippet

Revision: 35917
at November 15, 2010 06:13 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_ARRAY
#define MAXLENGTH 1000

typedef STACK_TYPE element_t;
typedef struct _stack
{
	element_t elements[MAXLENGTH];
	unsigned short cursor;
} _S_NAME;

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

static inline void _S_INIT (_S_NAME* _S_P_NAME)
{
	_S_P_NAME->cursor = MAXLENGTH - 1;
} 

static inline bool _S_EMPTY_NAME (_S_NAME* _S_P_NAME)
{
	return _S_P_NAME->cursor >= MAXLENGTH - 1;
} 

static inline element_t _S_TOP_NAME (_S_NAME* _S_P_NAME)
{
	return _S_P_NAME->elements[_S_P_NAME->cursor];
} 

static inline void _S_TOP (element_t _S_ADD_E, _S_NAME* _S_P_NAME)
{
	if (! _S_P_NAME->cursor) return;
	_S_P_NAME->elements[--(_S_P_NAME->cursor)] = _S_ADD_E;
} 

static inline void _S_POP (_S_NAME* _S_P_NAME)
{
	if (_S_EMPTY_NAME(_S_P_NAME)) return;
	_S_P_NAME->cursor++;
} 

#endif
#endif

Initial URL

                                

Initial Description

                                

Initial Title
Implementacija stoga pomocu polja

Initial Tags
array

Initial Language
C++