mirror of
https://gitee.com/apaki/unicstl.git
synced 2025-05-18 11:51:36 +08:00
43 lines
742 B
C
43 lines
742 B
C
#ifndef _STACK_H_
|
|
#define _STACK_H_
|
|
|
|
#include "common.h"
|
|
|
|
#if STACK == 1
|
|
|
|
struct _stack_node
|
|
{
|
|
void * obj;
|
|
struct _stack_node * next;
|
|
};
|
|
|
|
struct _stack
|
|
{
|
|
struct _stack_node * _head;
|
|
uint32_t _capacity; // ×ÜÈÝÁ¿
|
|
uint32_t _size; // Õ»´óС
|
|
uint32_t _obj_size; // ÔªËØ´óС
|
|
|
|
// base
|
|
uint32_t(*size)(struct _stack* s);
|
|
bool (*empty)(struct _stack* s);
|
|
|
|
// kernel
|
|
bool (*peek)(struct _stack* s, void *obj);
|
|
bool (*push)(struct _stack* s, void* obj);
|
|
bool (*pop)(struct _stack* s, void* obj);
|
|
|
|
// others
|
|
bool (*clear)(struct _stack* s);
|
|
void (*destory)(struct _stack* s);
|
|
void (*print_obj)(void* obj);
|
|
void (*print)(struct _stack* s);
|
|
};
|
|
|
|
bool stack_init(struct _stack* s, uint32_t type_size);
|
|
|
|
#endif
|
|
|
|
#endif // _STACK_H_
|
|
|