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