Home | History | Annotate | Download | only in include
      1 /*---------------------------------------------------------------------------*
      2  *  linklist.h  *
      3  *                                                                           *
      4  *  Copyright 2007, 2008 Nuance Communciations, Inc.                               *
      5  *                                                                           *
      6  *  Licensed under the Apache License, Version 2.0 (the 'License');          *
      7  *  you may not use this file except in compliance with the License.         *
      8  *                                                                           *
      9  *  You may obtain a copy of the License at                                  *
     10  *      http://www.apache.org/licenses/LICENSE-2.0                           *
     11  *                                                                           *
     12  *  Unless required by applicable law or agreed to in writing, software      *
     13  *  distributed under the License is distributed on an 'AS IS' BASIS,        *
     14  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
     15  *  See the License for the specific language governing permissions and      *
     16  *  limitations under the License.                                           *
     17  *                                                                           *
     18  *---------------------------------------------------------------------------*/
     19 
     20 
     21 
     22 /* each node stores pointer to data, and pointer to next node */
     23 typedef struct LNode {
     24   void *data;
     25   struct LNode *next;
     26   struct LNode *prev;
     27 }LNode;
     28 
     29 typedef struct LList {
     30   struct LNode *head;
     31   struct LNode *curr;
     32   struct LNode *tail;
     33 }LList;
     34 
     35 typedef enum{
     36   LListSuccess = 1,
     37   LListResourceAllocError,
     38   LListEmpty,
     39   LListInternalError
     40 }LListResult;
     41 
     42 /* Inserts after current element
     43    At return, current element will be point to newly created node
     44 
     45    handle static allocation later - possibly using a pool of nodes?
     46    For now, dynamically allocate a new list node with the data
     47 */
     48 LListResult Insert(LList *list, void *data);
     49 
     50 
     51 /* Deletes at current element
     52    At return, current element will point to previous node
     53 
     54    handle static deallocation later - possibly using a pool of nodes?
     55    For now, dynamically free a new list node
     56 */
     57 
     58 LListResult Delete(LList *list);
     59 
     60 /* If dynamic allocation is not allowed, provide small pool of nodes */
     61 #ifdef USE_STATIC_SLTS
     62 void ClearLNodeArray();
     63 #endif
     64 
     65