1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
/* GLIB - Library of useful routines for C programming
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/*
* Modified by the GLib Team and others 1997-2000. See the AUTHORS
* file for a list of people on the GLib Team. See the ChangeLog
* files for a list of changes. These files are distributed with
* GLib at ftp://ftp.gtk.org/pub/gtk/.
*/
#ifndef __MW_ARRAY_H__
#define __MW_ARRAY_H__
MW_BEGIN_DECLS
#include <milkway/mw-object.h>
typedef struct _mw_array mw_array_t;
typedef struct _mw_array_type mw_array_type_t;
struct _mw_array
{
mw_object_t base;
mw_char_t *data;
mw_uint_t len;
mw_uint_t alloc;
mw_uint_t elt_size;
mw_uint_t zero_terminated : 1;
mw_uint_t clear : 1;
};
struct _mw_array_type {
mw_object_type_t base;
};
/* Resizable arrays. remove fills any cleared spot and shortens the
* array, while preserving the order. remove_fast will distort the
* order by moving the last element to the position of the removed.
*/
#define mw_array_append_val(a,v) mw_array_append_vals (a, &(v), 1)
#define mw_array_prepend_val(a,v) mw_array_prepend_vals (a, &(v), 1)
#define mw_array_insert_val(a,i,v) mw_array_insert_vals (a, i, &(v), 1)
#define mw_array_index(a,t,i) (((t*) (void *) (a)->data) [(i)])
#define MW_ARRAY_TYPE mw_array_get_type()
mw_public mw_array_type_t*
mw_array_get_type(void);
mw_public mw_array_t*
mw_array_new (mw_bool_t zero_terminated,
mw_bool_t clear_,
mw_uint_t element_size);
mw_public mw_array_t*
mw_array_sized_new (mw_bool_t zero_terminated,
mw_bool_t clear_,
mw_uint_t element_size,
mw_uint_t reserved_size);
mw_public char*
mw_array_take (mw_array_t *array);
mw_public mw_uint_t
mw_array_get_element_size (mw_array_t *array);
mw_public mw_array_t*
mw_array_append_vals (mw_array_t *array,
const mw_pointer_t data,
mw_uint_t len);
mw_public mw_array_t*
mw_array_prepend_vals (mw_array_t *array,
const mw_pointer_t data,
mw_uint_t len);
mw_public mw_array_t*
mw_array_insert_vals (mw_array_t *array,
mw_uint_t index_,
const mw_pointer_t data,
mw_uint_t len);
mw_public mw_array_t*
mw_array_set_size (mw_array_t *array,
mw_uint_t length);
mw_public mw_array_t*
mw_array_remove_index (mw_array_t *array,
mw_uint_t index_);
mw_public mw_array_t*
mw_array_remove_index_fast (mw_array_t *array,
mw_uint_t index_);
mw_public mw_array_t*
mw_array_remove_range (mw_array_t *array,
mw_uint_t index_,
mw_uint_t length);
mw_public void
mw_array_sort (mw_array_t *array,
mw_compare_func_t compare_func);
mw_public void
mw_array_sort_with_data (mw_array_t *array,
mw_compare_data_func_t compare_func,
mw_pointer_t user_data);
MW_END_DECLS
#endif /* __MW_ARRAY_H__ */
|