Initial OpenECOMP Demo commit
[demo.git] / vnfs / VES / code / evel_library / double_list.h
1 #ifndef DOUBLE_LIST_INCLUDED
2 #define DOUBLE_LIST_INCLUDED
3
4 /**************************************************************************//**
5  * @file
6  * A simple double-linked list.
7  *
8  * @note  No thread protection so you will need to use appropriate
9  * synchronization if use spans multiple threads.
10  *
11  * License
12  * -------
13  *
14  * Copyright(c) <2016>, AT&T Intellectual Property.  All other rights reserved.
15  *
16  * Redistribution and use in source and binary forms, with or without
17  * modification, are permitted provided that the following conditions are met:
18  *
19  * 1. Redistributions of source code must retain the above copyright notice,
20  *    this list of conditions and the following disclaimer.
21  * 2. Redistributions in binary form must reproduce the above copyright notice,
22  *    this list of conditions and the following disclaimer in the documentation
23  *    and/or other materials provided with the distribution.
24  * 3. All advertising materials mentioning features or use of this software
25  *    must display the following acknowledgement:  This product includes
26  *    software developed by the AT&T.
27  * 4. Neither the name of AT&T nor the names of its contributors may be used to
28  *    endorse or promote products derived from this software without specific
29  *    prior written permission.
30  *
31  * THIS SOFTWARE IS PROVIDED BY AT&T INTELLECTUAL PROPERTY ''AS IS'' AND ANY
32  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
33  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
34  * DISCLAIMED. IN NO EVENT SHALL AT&T INTELLECTUAL PROPERTY BE LIABLE FOR ANY
35  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
36  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
37  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
38  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
39  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
40  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41 *****************************************************************************/
42
43 typedef struct dlist_item
44 {
45   struct dlist_item * previous;
46   struct dlist_item * next;
47   void * item;
48 } DLIST_ITEM;
49
50 /**************************************************************************//**
51  * Double-linked list structure
52  *****************************************************************************/
53 typedef struct dlist
54 {
55   DLIST_ITEM * head;
56   DLIST_ITEM * tail;
57 } DLIST;
58
59
60 void dlist_initialize(DLIST * list);
61 void * dlist_pop_last(DLIST * list);
62 void dlist_push_first(DLIST * list, void * item);
63 void dlist_push_last(DLIST * list, void * item);
64 DLIST_ITEM * dlist_get_first(DLIST * list);
65 DLIST_ITEM * dlist_get_last(DLIST * list);
66 DLIST_ITEM * dlist_get_next(DLIST_ITEM * item);
67 int dlist_is_empty(DLIST * list);
68 int dlist_count(DLIST * list);
69
70 #endif