sl@0: /* Copyright (c) 2009 The Khronos Group Inc. sl@0: * Portions copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies) sl@0: * sl@0: * Permission is hereby granted, free of charge, to any person obtaining a sl@0: * copy of this software and/or associated documentation files (the sl@0: * "Materials"), to deal in the Materials without restriction, including sl@0: * without limitation the rights to use, copy, modify, merge, publish, sl@0: * distribute, sublicense, and/or sell copies of the Materials, and to sl@0: * permit persons to whom the Materials are furnished to do so, subject to sl@0: * the following conditions: sl@0: * sl@0: * The above copyright notice and this permission notice shall be included sl@0: * in all copies or substantial portions of the Materials. sl@0: * sl@0: * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, sl@0: * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF sl@0: * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. sl@0: * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY sl@0: * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, sl@0: * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE sl@0: * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. sl@0: */ sl@0: sl@0: #ifndef OWFLLIST_H_ sl@0: #define OWFLLIST_H_ sl@0: sl@0: #include "owfpool.h" sl@0: #include "owftypes.h" sl@0: sl@0: sl@0: #ifdef __cplusplus sl@0: extern "C" sl@0: { sl@0: #endif sl@0: sl@0: /*! sl@0: * Allocates new node from the node pool sl@0: * sl@0: * \param pool Node pool sl@0: * \param data Data to store in the node sl@0: * sl@0: * \return New node containing data or NULL sl@0: */ sl@0: OWF_API_CALL OWF_NODE* sl@0: OWF_Node_Create(OWF_POOL* pool, void* data); sl@0: sl@0: /*! sl@0: * Returns node to pool it was allocated from. sl@0: * sl@0: * \param node Node to "destroy" sl@0: */ sl@0: OWF_API_CALL void sl@0: OWF_Node_Destroy(OWF_NODE* node); sl@0: sl@0: /*! sl@0: * Returns list's tail node. sl@0: * sl@0: * \param root List root sl@0: * sl@0: * \return List's tail (last) node sl@0: */ sl@0: OWF_API_CALL OWF_NODE* sl@0: OWF_List_Tail(OWF_NODE* root); sl@0: sl@0: /*! sl@0: * Append node to list. sl@0: * sl@0: * \param root List root sl@0: * sl@0: * \return New list root node sl@0: */ sl@0: OWF_API_CALL OWF_NODE* sl@0: OWF_List_Append(OWF_NODE* root, OWF_NODE* node); sl@0: sl@0: /*! sl@0: * Insert node to list front. I.e. current root becomes sl@0: * 2nd in the list and so on. sl@0: * sl@0: * \param root List root sl@0: * \param node Node to insert sl@0: * sl@0: * \return New list root (inserted node) sl@0: */ sl@0: OWF_API_CALL OWF_NODE* sl@0: OWF_List_Insert(OWF_NODE* root, OWF_NODE* node); sl@0: sl@0: /*! sl@0: * Inserts node into list, immediately after node "pred". sl@0: * sl@0: * \param pred Node after which the newcomer should be placed. sl@0: * \param node Node to add. sl@0: */ sl@0: OWF_API_CALL void sl@0: OWF_List_InsertAfter(OWF_NODE* pred, OWF_NODE* node); sl@0: sl@0: /*! sl@0: * Searches the list for data ptr. Returns the node sl@0: * that contains pointer to data, or NULL if no such node sl@0: * can be found from the list. sl@0: * sl@0: * \param root List root sl@0: * \param data Data pointer sl@0: * sl@0: * \return Node containing the data ptr or NULL. sl@0: */ sl@0: OWF_API_CALL OWF_NODE* sl@0: OWF_List_Contains(OWF_NODE* root, void* data); sl@0: sl@0: /*! sl@0: * Remove node from list. Obs! The node isn't freed, sl@0: * but only removed from the list. It's up to caller sl@0: * to take care of destroying the node i.e. returning sl@0: * it to pool or releasing the memory otherwise allocated sl@0: * to it. sl@0: * sl@0: * \param root List root sl@0: * \param node Node to remove from list sl@0: * sl@0: * \return New list root after removal sl@0: */ sl@0: OWF_API_CALL OWF_NODE* sl@0: OWF_List_Remove(OWF_NODE* root, OWF_NODE* node); sl@0: sl@0: /*! sl@0: * Remove all nodes from the list. Equals to sl@0: * while (list) list = OWF_List_Remove(list, list); sl@0: * sl@0: * \param root List root sl@0: * sl@0: * \return NULL. sl@0: */ sl@0: OWF_API_CALL OWF_NODE* sl@0: OWF_List_Clear(OWF_NODE* root); sl@0: sl@0: #ifdef __cplusplus sl@0: } sl@0: #endif sl@0: sl@0: sl@0: #endif