source: XIOS/dev/dev_olga/extern/src_netcdf4/nclist.h @ 1620

Last change on this file since 1620 was 409, checked in by ymipsl, 11 years ago

Add improved nectdf internal library src

YM

  • Property svn:eol-style set to native
File size: 1.8 KB
Line 
1/* Copyright 2009, UCAR/Unidata and OPeNDAP, Inc.
2   See the COPYRIGHT file for more information. */
3#ifndef NCLIST_H
4#define NCLIST_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
14typedef unsigned long ncelem;
15
16EXTERNC int nclistnull(ncelem);
17
18typedef struct NClist {
19  unsigned int alloc;
20  unsigned int length;
21  ncelem* content;
22} NClist;
23
24EXTERNC NClist* nclistnew(void);
25EXTERNC int nclistfree(NClist*);
26EXTERNC int nclistsetalloc(NClist*,unsigned int);
27EXTERNC int nclistsetlength(NClist*,unsigned int);
28
29/* Set the ith element */
30EXTERNC int nclistset(NClist*,unsigned int,ncelem);
31/* Get value at position i */
32EXTERNC ncelem nclistget(NClist*,unsigned int);/* Return the ith element of l */
33/* Insert at position i; will push up elements i..|seq|. */
34EXTERNC int nclistinsert(NClist*,unsigned int,ncelem);
35/* Remove element at position i; will move higher elements down */
36EXTERNC ncelem nclistremove(NClist* l, unsigned int i);
37
38/* Tail operations */
39EXTERNC int nclistpush(NClist*,ncelem); /* Add at Tail */
40EXTERNC ncelem nclistpop(NClist*);
41EXTERNC ncelem nclisttop(NClist*);
42
43/* Duplicate and return the content (null terminate) */
44EXTERNC ncelem* nclistdup(NClist*);
45
46/* Look for value match */
47EXTERNC int nclistcontains(NClist*, ncelem);
48
49/* Remove element by value; only removes first encountered */
50EXTERNC int nclistelemremove(NClist* l, ncelem elem);
51
52
53/* remove duplicates */
54EXTERNC int nclistunique(NClist*);
55
56/* Create a clone of a list */
57EXTERNC NClist* nclistclone(NClist*);
58
59/* Following are always "in-lined"*/
60#define nclistclear(l) nclistsetlength((l),0U)
61#define nclistextend(l,len) nclistsetalloc((l),(len)+(l->alloc))
62#define nclistcontents(l) ((l)->content)
63#define nclistlength(l)  ((l)?(l)->length:0U)
64
65#endif /*NCLIST_H*/
66
67
Note: See TracBrowser for help on using the repository browser.