jdk/src/solaris/native/sun/awt/list.h
changeset 2 90ce3da70b43
child 5506 202f599c92aa
equal deleted inserted replaced
0:fd16c54261b3 2:90ce3da70b43
       
     1 /*
       
     2  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       
     3  *
       
     4  * This code is free software; you can redistribute it and/or modify it
       
     5  * under the terms of the GNU General Public License version 2 only, as
       
     6  * published by the Free Software Foundation.  Sun designates this
       
     7  * particular file as subject to the "Classpath" exception as provided
       
     8  * by Sun in the LICENSE file that accompanied this code.
       
     9  *
       
    10  * This code is distributed in the hope that it will be useful, but WITHOUT
       
    11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       
    12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
       
    13  * version 2 for more details (a copy is included in the LICENSE file that
       
    14  * accompanied this code).
       
    15  *
       
    16  * You should have received a copy of the GNU General Public License version
       
    17  * 2 along with this work; if not, write to the Free Software Foundation,
       
    18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
       
    19  *
       
    20  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
       
    21  * CA 95054 USA or visit www.sun.com if you need additional information or
       
    22  * have any questions.
       
    23  */
       
    24 /* $XConsortium: list.h /main/4 1996/10/14 15:04:04 swick $ */
       
    25 /** ------------------------------------------------------------------------
       
    26         This file contains routines for manipulating generic lists.
       
    27         Lists are implemented with a "harness".  In other words, each
       
    28         node in the list consists of two pointers, one to the data item
       
    29         and one to the next node in the list.  The head of the list is
       
    30         the same struct as each node, but the "item" ptr is used to point
       
    31         to the current member of the list (used by the first_in_list and
       
    32         next_in_list functions).
       
    33 
       
    34  This file is available under and governed by the GNU General Public
       
    35  License version 2 only, as published by the Free Software Foundation.
       
    36  However, the following notice accompanied the original version of this
       
    37  file:
       
    38 
       
    39 Copyright (c) 1994 Hewlett-Packard Co.
       
    40 Copyright (c) 1996  X Consortium
       
    41 
       
    42 Permission is hereby granted, free of charge, to any person obtaining
       
    43 a copy of this software and associated documentation files (the
       
    44 "Software"), to deal in the Software without restriction, including
       
    45 without limitation the rights to use, copy, modify, merge, publish,
       
    46 distribute, sublicense, and sell copies of the Software, and to
       
    47 permit persons to whom the Software is furnished to do so, subject to
       
    48 the following conditions:
       
    49 
       
    50 The above copyright notice and this permission notice shall be included
       
    51 in all copies or substantial portions of the Software.
       
    52 
       
    53 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
       
    54 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
       
    55 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
       
    56 IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
       
    57 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
       
    58 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
       
    59 OTHER DEALINGS IN THE SOFTWARE.
       
    60 
       
    61 Except as contained in this notice, the name of the X Consortium shall
       
    62 not be used in advertising or otherwise to promote the sale, use or
       
    63 other dealings in this Software without prior written authorization
       
    64 from the X Consortium.
       
    65 
       
    66     -------------------------------------------------------------------- **/
       
    67 
       
    68 #include "gdefs.h"
       
    69 
       
    70 #ifndef LIST_DEF
       
    71 #define LIST_DEF
       
    72 
       
    73 #define LESS    -1
       
    74 #define EQUAL   0
       
    75 #define GREATER 1
       
    76 #define DUP_WHOLE_LIST  0
       
    77 #define START_AT_CURR   1
       
    78 
       
    79 typedef struct _list_item {
       
    80     struct _list_item *next;
       
    81     union {
       
    82         void *item;              /* in normal list node, pts to data */
       
    83         struct _list_item *curr; /* in list head, pts to curr for 1st, next */
       
    84     } ptr;
       
    85 } list, list_item, *list_ptr;
       
    86 
       
    87 typedef void (*DESTRUCT_FUNC_PTR)(
       
    88 #if NeedFunctionPrototypes
       
    89 void *
       
    90 #endif
       
    91 );
       
    92 
       
    93 void zero_list(
       
    94 #if NeedFunctionPrototypes
       
    95           list_ptr
       
    96 #endif
       
    97     );
       
    98 int32_t add_to_list (
       
    99 #if NeedFunctionPrototypes
       
   100           list_ptr , void *
       
   101 #endif
       
   102     );
       
   103 list_ptr new_list (
       
   104 #if NeedFunctionPrototypes
       
   105           void
       
   106 #endif
       
   107     );
       
   108 list_ptr dup_list_head (
       
   109 #if NeedFunctionPrototypes
       
   110           list_ptr , int32_t
       
   111 #endif
       
   112     );
       
   113 uint32_t list_length(
       
   114 #if NeedFunctionPrototypes
       
   115           list_ptr
       
   116 #endif
       
   117     );
       
   118 void *delete_from_list (
       
   119 #if NeedFunctionPrototypes
       
   120           list_ptr , void *
       
   121 #endif
       
   122     );
       
   123 void delete_list(
       
   124 #if NeedFunctionPrototypes
       
   125           list_ptr , int32_t
       
   126 #endif
       
   127     );
       
   128 void delete_list_destroying (
       
   129 #if NeedFunctionPrototypes
       
   130           list_ptr , DESTRUCT_FUNC_PTR
       
   131 #endif
       
   132     );
       
   133 void *first_in_list (
       
   134 #if NeedFunctionPrototypes
       
   135           list_ptr
       
   136 #endif
       
   137     );
       
   138 void *next_in_list (
       
   139 #if NeedFunctionPrototypes
       
   140           list_ptr
       
   141 #endif
       
   142     );
       
   143 int32_t list_is_empty (
       
   144 #if NeedFunctionPrototypes
       
   145           list_ptr
       
   146 #endif
       
   147     );
       
   148 
       
   149 #endif