epoc32/include/stdapis/glib-2.0/glib/garray.h
branchSymbian2
changeset 2 2fe1408b6811
parent 0 061f57f2323e
equal deleted inserted replaced
1:666f914201fb 2:2fe1408b6811
     1 garray.h
     1 /* GLIB - Library of useful routines for C programming
       
     2  * Copyright (C) 1995-1997  Peter Mattis, Spencer Kimball and Josh MacDonald
       
     3  * Portions copyright (c) 2006 Nokia Corporation.  All rights reserved.
       
     4  *
       
     5  * This library is free software; you can redistribute it and/or
       
     6  * modify it under the terms of the GNU Lesser General Public
       
     7  * License as published by the Free Software Foundation; either
       
     8  * version 2 of the License, or (at your option) any later version.
       
     9  *
       
    10  * This library is distributed in the hope that it will be useful,
       
    11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
       
    13  * Lesser General Public License for more details.
       
    14  *
       
    15  * You should have received a copy of the GNU Lesser General Public
       
    16  * License along with this library; if not, write to the
       
    17  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
       
    18  * Boston, MA 02111-1307, USA.
       
    19  */
       
    20 
       
    21 /*
       
    22  * Modified by the GLib Team and others 1997-2000.  See the AUTHORS
       
    23  * file for a list of people on the GLib Team.  See the ChangeLog
       
    24  * files for a list of changes.  These files are distributed with
       
    25  * GLib at ftp://ftp.gtk.org/pub/gtk/. 
       
    26  */
       
    27 
       
    28 #ifndef __G_ARRAY_H__
       
    29 #define __G_ARRAY_H__
       
    30 
       
    31 #include <_ansi.h>
       
    32 #include <glib/gtypes.h>
       
    33 
       
    34 G_BEGIN_DECLS
       
    35 
       
    36 typedef struct _GArray		GArray;
       
    37 typedef struct _GByteArray	GByteArray;
       
    38 typedef struct _GPtrArray	GPtrArray;
       
    39 
       
    40 struct _GArray
       
    41 {
       
    42   gchar *data;
       
    43   guint len;
       
    44 };
       
    45 
       
    46 struct _GByteArray
       
    47 {
       
    48   guint8 *data;
       
    49   guint	  len;
       
    50 };
       
    51 
       
    52 struct _GPtrArray
       
    53 {
       
    54   gpointer *pdata;
       
    55   guint	    len;
       
    56 };
       
    57 
       
    58 /* Resizable arrays. remove fills any cleared spot and shortens the
       
    59  * array, while preserving the order. remove_fast will distort the
       
    60  * order by moving the last element to the position of the removed.
       
    61  */
       
    62 
       
    63 #define g_array_append_val(a,v)	  g_array_append_vals (a, &(v), 1)
       
    64 #define g_array_prepend_val(a,v)  g_array_prepend_vals (a, &(v), 1)
       
    65 #define g_array_insert_val(a,i,v) g_array_insert_vals (a, i, &(v), 1)
       
    66 #define g_array_index(a,t,i)      (((t*) (a)->data) [(i)])
       
    67 
       
    68 IMPORT_C GArray* g_array_new               (gboolean          zero_terminated,
       
    69 				   gboolean          clear_,
       
    70 				   guint             element_size);
       
    71 IMPORT_C GArray* g_array_sized_new         (gboolean          zero_terminated,
       
    72 				   gboolean          clear_,
       
    73 				   guint             element_size,
       
    74 				   guint             reserved_size);
       
    75 IMPORT_C gchar*  g_array_free              (GArray           *array,
       
    76 				   gboolean          free_segment);
       
    77 IMPORT_C GArray* g_array_append_vals       (GArray           *array,
       
    78 				   gconstpointer     data,
       
    79 				   guint             len);
       
    80 IMPORT_C GArray* g_array_prepend_vals      (GArray           *array,
       
    81 				   gconstpointer     data,
       
    82 				   guint             len);
       
    83 IMPORT_C GArray* g_array_insert_vals       (GArray           *array,
       
    84 				   guint             index_,
       
    85 				   gconstpointer     data,
       
    86 				   guint             len);
       
    87 IMPORT_C GArray* g_array_set_size          (GArray           *array,
       
    88 				   guint             length);
       
    89 IMPORT_C GArray* g_array_remove_index      (GArray           *array,
       
    90 				   guint             index_);
       
    91 IMPORT_C GArray* g_array_remove_index_fast (GArray           *array,
       
    92 				   guint             index_);
       
    93 IMPORT_C GArray* g_array_remove_range      (GArray           *array,
       
    94 				   guint             index_,
       
    95 				   guint             length);
       
    96 IMPORT_C void    g_array_sort              (GArray           *array,
       
    97 				   GCompareFunc      compare_func);
       
    98 IMPORT_C void    g_array_sort_with_data    (GArray           *array,
       
    99 				   GCompareDataFunc  compare_func,
       
   100 				   gpointer          user_data);
       
   101 
       
   102 /* Resizable pointer array.  This interface is much less complicated
       
   103  * than the above.  Add appends a pointer.  Remove fills any cleared 
       
   104  * spot and shortens the array. remove_fast will again distort order.  
       
   105  */
       
   106 #define    g_ptr_array_index(array,index_) ((array)->pdata)[index_]
       
   107 IMPORT_C GPtrArray* g_ptr_array_new                (void);
       
   108 IMPORT_C GPtrArray* g_ptr_array_sized_new          (guint             reserved_size);
       
   109 IMPORT_C gpointer*  g_ptr_array_free               (GPtrArray        *array,
       
   110 					   gboolean          free_seg);
       
   111 IMPORT_C void       g_ptr_array_set_size           (GPtrArray        *array,
       
   112 					   gint              length);
       
   113 IMPORT_C gpointer   g_ptr_array_remove_index       (GPtrArray        *array,
       
   114 					   guint             index_);
       
   115 IMPORT_C gpointer   g_ptr_array_remove_index_fast  (GPtrArray        *array,
       
   116 					   guint             index_);
       
   117 IMPORT_C gboolean   g_ptr_array_remove             (GPtrArray        *array,
       
   118 					   gpointer          data);
       
   119 IMPORT_C gboolean   g_ptr_array_remove_fast        (GPtrArray        *array,
       
   120 					   gpointer          data);
       
   121 IMPORT_C void       g_ptr_array_remove_range       (GPtrArray        *array,
       
   122 					   guint             index_,
       
   123 					   guint             length);
       
   124 IMPORT_C void       g_ptr_array_add                (GPtrArray        *array,
       
   125 					   gpointer          data);
       
   126 IMPORT_C void       g_ptr_array_sort               (GPtrArray        *array,
       
   127 					   GCompareFunc      compare_func);
       
   128 IMPORT_C void       g_ptr_array_sort_with_data     (GPtrArray        *array,
       
   129 					   GCompareDataFunc  compare_func,
       
   130 					   gpointer          user_data);
       
   131 IMPORT_C void       g_ptr_array_foreach            (GPtrArray        *array,
       
   132 					   GFunc             func,
       
   133 					   gpointer          user_data);
       
   134 
       
   135 
       
   136 /* Byte arrays, an array of guint8.  Implemented as a GArray,
       
   137  * but type-safe.
       
   138  */
       
   139 
       
   140 IMPORT_C GByteArray* g_byte_array_new               (void);
       
   141 IMPORT_C GByteArray* g_byte_array_sized_new         (guint             reserved_size);
       
   142 IMPORT_C guint8*     g_byte_array_free              (GByteArray       *array,
       
   143 					    gboolean          free_segment);
       
   144 IMPORT_C GByteArray* g_byte_array_append            (GByteArray       *array,
       
   145 					    const guint8     *data,
       
   146 					    guint             len);
       
   147 IMPORT_C GByteArray* g_byte_array_prepend           (GByteArray       *array,
       
   148 					    const guint8     *data,
       
   149 					    guint             len);
       
   150 IMPORT_C GByteArray* g_byte_array_set_size          (GByteArray       *array,
       
   151 					    guint             length);
       
   152 IMPORT_C GByteArray* g_byte_array_remove_index      (GByteArray       *array,
       
   153 					    guint             index_);
       
   154 IMPORT_C GByteArray* g_byte_array_remove_index_fast (GByteArray       *array,
       
   155 					    guint             index_);
       
   156 IMPORT_C GByteArray* g_byte_array_remove_range      (GByteArray       *array,
       
   157 					    guint             index_,
       
   158 					    guint             length);
       
   159 IMPORT_C void        g_byte_array_sort              (GByteArray       *array,
       
   160 					    GCompareFunc      compare_func);
       
   161 IMPORT_C void        g_byte_array_sort_with_data    (GByteArray       *array,
       
   162 					    GCompareDataFunc  compare_func,
       
   163 					    gpointer          user_data);
       
   164 
       
   165 
       
   166 G_END_DECLS
       
   167 
       
   168 #endif /* __G_ARRAY_H__ */
       
   169