1 /* Copyright 2009, UCAR/Unidata and OPeNDAP, Inc. 2 See the COPYRIGHT file for more information. */ 3 #ifndef OCLIST_H 4 #define OCLIST_H 1 5 6 /* Define the type of the elements in the list*/ 7 8 #if defined(_CPLUSPLUS_) || defined(__CPLUSPLUS__) 9 #define EXTERNC extern "C" 10 #else 11 #define EXTERNC extern 12 #endif 13 14 EXTERNC int oclistnull(void*); 15 16 typedef struct OClist { 17 size_t alloc; 18 size_t length; 19 void** content; 20 } OClist; 21 22 EXTERNC OClist* oclistnew(void); 23 EXTERNC int oclistfree(OClist*); 24 EXTERNC int oclistsetalloc(OClist*,size_t); 25 EXTERNC int oclistsetlength(OClist*,size_t); 26 27 /* Set the ith element */ 28 EXTERNC int oclistset(OClist*,size_t,void*); 29 /* Get value at position i */ 30 EXTERNC void* oclistget(OClist*,size_t);/* Return the ith element of l */ 31 /* Insert at position i; will push up elements i..|seq|. */ 32 EXTERNC int oclistinsert(OClist*,size_t,void*); 33 /* Remove element at position i; will move higher elements down */ 34 EXTERNC void* oclistremove(OClist* l, size_t i); 35 36 /* Tail operations */ 37 EXTERNC int oclistpush(OClist*,void*); /* Add at Tail */ 38 EXTERNC void* oclistpop(OClist*); 39 EXTERNC void* oclisttop(OClist*); 40 41 /* Duplicate and return the content (null terminate) */ 42 EXTERNC void** oclistdup(OClist*); 43 44 /* Look for value match */ 45 EXTERNC int oclistcontains(OClist*, void*); 46 47 /* Remove element by value; only removes first encountered */ 48 EXTERNC int oclistelemremove(OClist* l, void* elem); 49 50 /* remove duplicates */ 51 EXTERNC int oclistunique(OClist*); 52 53 /* Create a clone of a list */ 54 EXTERNC OClist* oclistclone(OClist*); 55 56 /* Following are always "in-lined"*/ 57 #define oclistclear(l) oclistsetlength((l),0) 58 #define oclistextend(l,len) oclistsetalloc((l),(len)+(l->alloc)) 59 #define oclistcontents(l) ((l)==NULL?NULL:(l)->content) 60 #define oclistlength(l) ((l)==NULL?0:(l)->length) 61 62 #endif /*OCLIST_H*/
HyperKWIC - Version 7.20DA executed at 11:37 on 27 Oct 2017 | Polyhedron Solutions - INTERNAL USE | COMMERCIAL (Any O/S) SN 4AKIed