Modified the UGetCursor() routine to return a valid response if the
[xcircuit.git] / spiceparser / list_search.h
blob28d7d869436d195ff185412fa9ef3e651862f615
1 /********************
2 This file is part of the software library CADLIB written by Conrad Ziesler
3 Copyright 2003, Conrad Ziesler, all rights reserved.
5 *************************
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 ******************/
21 /* list_search.h, list container that supports arbitary (binary) search
22 Conrad Ziesler
26 #ifndef __LIST_SEARCH_H__
27 #define __LIST_SEARCH_H__
29 #ifndef __LIST_H__
30 #include "list.h"
31 #endif
33 typedef struct list_psearch_st
35 void *user;
36 int (*cmpf)(const void *user, const void *a, const void *b);
37 int *isearchdata;
38 int is_sorted;
39 int len;
40 }list_psearch_t;
42 typedef struct list_search_st
44 list_t list;
45 list_t psearch;
46 }list_search_t;
48 typedef struct list_search_iterator_st
50 list_search_t *sp;
51 int which;
52 int last_id;
53 }list_search_iterator_t;
55 #define list_search(lp) (&((lp)->list))
57 #define list_search_data(a,b) list_data(list_search((a)),(b))
58 #define list_search_vdata(a,b) list_vdata(list_search((a)),(b))
59 #define list_search_iterate(l,i,p) for((p)=list_search_data((l),(i)=0);(p)!=NULL;(p)=list_search_data((l),++(i)))
60 #define list_search_add(a,b) list_add(list_search((a)),(b))
61 #define list_search_qty(a) list_qty(list_search((a)))
62 #define list_search_index(a,b) list_index(list_search((a)),(b))
63 #define list_search_reset(a) list_reset(list_search((a)))
64 #define list_search_iterate_backwards(l,i,p) for((p)=list_search_data((l),(i)=(list_search((l))->q-1));(p)!=NULL;(p)=list_search_data((l),--(i)))
67 void list_search_init(list_search_t *lp, int size, int mode);
68 int list_search_addrule(list_search_t *lp, int (*cmpf)(const void *user, const void *a, const void *b),void *user);
69 void list_search_resort(list_search_t *lp);
70 int list_search_find(list_search_t *lp, int which, void *key, list_search_iterator_t *sip);
71 int list_search_findnext(list_search_iterator_t *sip);
72 void list_search_empty(list_search_t *lp);
75 /* private */
76 void list_search_qsort (list_search_t *lsp, list_psearch_t *psp);
83 #endif