📄 list.h
字号:
/* * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Author: * NAME: James Stevenson * EMAIL: mistral@stev.org * WWW: http://www.stev.org */#ifndef _LIST_H#define _LIST_H/* Types */struct list_t { int length; /* this stores the number of items in the array */ int mlength; /* this stores the amount of LIST_BLK's alloced in the array */ void **array; /* this is the array of pointers */ int (*func_cmp) (const void *c1, const void *c2); /* compare function */ int sorted; /* wether the list is sorted or not */};/* Functions */extern int list_bsearch (struct list_t *p, void *data);extern int list_lsearch (struct list_t *p, void *data);extern int list_bsort (struct list_t *p);extern int list_insert (struct list_t *p, int n, void *data);extern int list_del (struct list_t *p, int n);extern void *list_get (struct list_t *p, int n);extern int list_add_lsort (struct list_t *p, void *data);extern int list_add (struct list_t *p, void *data);extern inline int list_realloc (struct list_t *p, int nlength);extern inline int list_length (struct list_t *p);extern void list_setcmp (struct list_t *p, int (*cmp) (const void *c1, const void *c2) );extern struct list_t *list_init ( void );extern int list_free (struct list_t *p);/* Macros */#define list_add_sort(x, y) list_add_lsort(x, y)#define list_search(x, y) list_bsearch(x, y)#define list_sort(x) list_bsort(x)#define list_len(x) x->length#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -