1
Fork 0
mirror of https://github.com/naehrwert/scetool.git synced 2025-04-22 04:37:48 +00:00
scetool/list.h

38 lines
781 B
C
Raw Normal View History

2013-05-10 13:02:25 +02:00
/*
* Copyright (c) 2011-2013 by naehrwert
* This file is released under the GPLv2.
*/
#ifndef _LIST_H_
#define _LIST_H_
#include "types.h"
#define LIST_FOREACH(iter, list) for(lnode_t *iter = list->head; iter != NULL; iter = iter->next)
typedef struct _lnode
{
void *value;
struct _lnode *next;
} lnode_t;
typedef struct _list
{
lnode_t *head;
u32 count;
} list_t;
list_t *list_create();
void list_destroy(list_t *l);
BOOL list_isempty(list_t *l);
u32 list_count(list_t *l);
BOOL list_push(list_t *l, void *value);
void *list_pop(list_t *l);
BOOL list_add_back(list_t *l, void *value);
void *list_get(list_t *l, u32 idx);
lnode_t *list_get_node(list_t *l, u32 idx);
BOOL list_remove_node(list_t *l, lnode_t *node);
BOOL list_remove_value(list_t *l, void *value);
#endif