source: XIOS/trunk/extern/src_netcdf4/oclist.h @ 409

Last change on this file since 409 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.6 KB
Line 
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
14typedef unsigned long ocelem;
15
16EXTERNC int oclistnull(ocelem);
17
18typedef struct OClist {
19  unsigned int alloc;
20  unsigned int length;
21  ocelem* content;
22} OClist;
23
24EXTERNC OClist* oclistnewn(int);
25EXTERNC int oclistfree(OClist*);
26EXTERNC int oclistsetalloc(OClist*,unsigned int);
27EXTERNC int oclistsetlength(OClist*,unsigned int);
28
29/* Set the ith element */
30EXTERNC int oclistset(OClist*,unsigned int,ocelem);
31/* Get value at position i */
32EXTERNC ocelem oclistget(OClist*,unsigned int);/* Return the ith element of l */
33/* Insert at position i; will push up elements i..|seq|. */
34EXTERNC int oclistinsert(OClist*,unsigned int,ocelem);
35/* Remove element at position i; will move higher elements down */
36EXTERNC ocelem oclistremove(OClist* l, unsigned int i);
37
38/* Tail operations */
39EXTERNC int oclistpush(OClist*,ocelem); /* Add at Tail */
40EXTERNC ocelem oclistpop(OClist*);
41EXTERNC ocelem oclisttop(OClist*);
42
43/* Duplicate and return the content (null terminate) */
44EXTERNC ocelem* oclistdup(OClist*);
45
46/* Look for value match */
47EXTERNC int oclistcontains(OClist*, ocelem);
48
49/* Following are always "in-lined"*/
50#define oclistnew() oclistnewn(0)
51#define oclistclear(l) oclistsetlength((l),0U)
52#define oclistextend(l,len) oclistsetalloc((l),(len)+(l->alloc))
53#define oclistcontents(l) ((l)->content)
54#define oclistlength(l)  ((l)?(l)->length:0U)
55
56#endif /*OCLIST_H*/
57
Note: See TracBrowser for help on using the repository browser.