os/graphics/graphicscomposition/openwfcompositionengine/common/include/owflinkedlist.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 /* Copyright (c) 2009 The Khronos Group Inc.
     2  * Portions copyright (c) 2009-2010  Nokia Corporation and/or its subsidiary(-ies)
     3  *
     4  * Permission is hereby granted, free of charge, to any person obtaining a
     5  * copy of this software and/or associated documentation files (the
     6  * "Materials"), to deal in the Materials without restriction, including
     7  * without limitation the rights to use, copy, modify, merge, publish,
     8  * distribute, sublicense, and/or sell copies of the Materials, and to
     9  * permit persons to whom the Materials are furnished to do so, subject to
    10  * the following conditions:
    11  *
    12  * The above copyright notice and this permission notice shall be included
    13  * in all copies or substantial portions of the Materials.
    14  *
    15  * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
    16  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
    17  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
    18  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
    19  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
    20  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
    21  * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
    22  */
    23 
    24 #ifndef OWFLLIST_H_
    25 #define OWFLLIST_H_
    26 
    27 #include "owfpool.h"
    28 #include "owftypes.h"
    29 
    30 
    31 #ifdef __cplusplus
    32 extern "C"
    33 {
    34 #endif
    35 
    36 /*!
    37  *  Allocates new node from the node pool
    38  *
    39  *  \param pool Node pool
    40  *  \param data Data to store in the node
    41  *
    42  *  \return New node containing data or NULL
    43  */
    44 OWF_API_CALL OWF_NODE*
    45 OWF_Node_Create(OWF_POOL* pool, void* data);
    46 
    47 /*!
    48  *  Returns node to pool it was allocated from.
    49  *
    50  *  \param node Node to "destroy"
    51  */
    52 OWF_API_CALL void
    53 OWF_Node_Destroy(OWF_NODE* node);
    54 
    55 /*!
    56  *  Returns list's tail node.
    57  *
    58  *  \param root List root
    59  *
    60  *  \return List's tail (last) node
    61  */
    62 OWF_API_CALL OWF_NODE*
    63 OWF_List_Tail(OWF_NODE* root);
    64 
    65 /*!
    66  *  Append node to list.
    67  *
    68  *  \param root List root
    69  *
    70  *  \return New list root node
    71  */
    72 OWF_API_CALL OWF_NODE*
    73 OWF_List_Append(OWF_NODE* root, OWF_NODE* node);
    74 
    75 /*!
    76  *  Insert node to list front. I.e. current root becomes
    77  *  2nd in the list and so on.
    78  *
    79  *  \param root List root
    80  *  \param node Node to insert
    81  *
    82  *  \return New list root (inserted node)
    83  */
    84 OWF_API_CALL OWF_NODE*
    85 OWF_List_Insert(OWF_NODE* root, OWF_NODE* node);
    86 
    87 /*!
    88  *  Inserts node into list, immediately after node "pred".
    89  *
    90  *  \param pred Node after which the newcomer should be placed.
    91  *  \param node Node to add.
    92  */
    93 OWF_API_CALL void
    94 OWF_List_InsertAfter(OWF_NODE* pred, OWF_NODE* node);
    95 
    96 /*!
    97  *  Searches the list for data ptr. Returns the node
    98  *  that contains pointer to data, or NULL if no such node
    99  *  can be found from the list.
   100  *
   101  *  \param root List root
   102  *  \param data Data pointer
   103  *
   104  *  \return Node containing the data ptr or NULL.
   105  */
   106 OWF_API_CALL OWF_NODE*
   107 OWF_List_Contains(OWF_NODE* root, void* data);
   108 
   109 /*!
   110  *  Remove node from list. Obs! The node isn't freed,
   111  *  but only removed from the list. It's up to caller
   112  *  to take care of destroying the node i.e. returning
   113  *  it to pool or releasing the memory otherwise allocated
   114  *  to it.
   115  *
   116  *  \param root List root
   117  *  \param node Node to remove from list
   118  *
   119  *  \return New list root after removal
   120  */
   121 OWF_API_CALL OWF_NODE*
   122 OWF_List_Remove(OWF_NODE* root, OWF_NODE* node);
   123 
   124 /*!
   125  *  Remove all nodes from the list. Equals to
   126  *  while (list) list = OWF_List_Remove(list, list);
   127  *
   128  *  \param root List root
   129  *
   130  *  \return NULL.
   131  */
   132 OWF_API_CALL OWF_NODE*
   133 OWF_List_Clear(OWF_NODE* root);
   134 
   135 #ifdef __cplusplus
   136 }
   137 #endif
   138 
   139 
   140 #endif