-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlibex_array.h
More file actions
executable file
·88 lines (64 loc) · 4.63 KB
/
Copy pathlibex_array.h
File metadata and controls
executable file
·88 lines (64 loc) · 4.63 KB
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
/* -------------------------------------------------------------------------- */
/* (c) ali@balarabe.com [libex_array.h] */
/* -------------------------------------------------------------------------- */
#if !defined INCLUDED_LIBEX_ARRAY_H
#define INCLUDED_LIBEX_ARRAY_H
#include "libex.h"
/* -------------------------------------------------------------------------- */
LX_NAMESPACE(lx_c)
typedef struct lx_array_t {
uint8_t* ob;
}
lx_array_t, lx_new_array_t;
static lx_array_t lx_null_array = { NULL };
/* -------------------------------------------------------------------------- */
/* Constructor: */
/* Constructor: Creates an array with the given pre-allocated capacity. */
/* (See lx_Array_reserve() for an explanation of capacity_ and grow_by_.) */
LX_PUBLIC lx_new_array_t lx_Array_init( /*C*/
const size_t item_size_in_bytes_, /*-*/
const size_t capacity_, /*-*/
const size_t grow_by_ ); /*-*/
/* -------------------------------------------------------------------------- */
/* Destructor: */
LX_PUBLIC void lx_Array_free( lx_array_t* object_ ); /*M*/
/* -------------------------------------------------------------------------- */
/* Methods: Informative */
/* returns the number of items added to the array. */
/* (Not to be confused with the array's capacity.) */
LX_PUBLIC size_t lx_Array_count( const lx_array_t object_ ); /*M*/
LX_PUBLIC size_t lx_Array_getKeyIndex( /*M*/
const lx_array_t object_, /*-*/
lx_chars_t key_ ); /*-*/
LX_PUBLIC lx_bool lx_Array_keyExists( /*M*/
const lx_array_t object_, /*-*/
lx_chars_t key_ ); /*-*/
/* -------------------------------------------------------------------------- */
/* Methods: Manipulative */
LX_PUBLIC void lx_Array_addItem( /*M*/
lx_array_t* object_, /*-*/
const void* item_data_, /*-*/
const size_t item_size_in_bytes_, /*-*/
lx_chars_t key_ ); /*-*/
LX_PUBLIC uint8_t* lx_Array_getItemAt( /*M*/
lx_array_t* object_, /*-*/
const size_t index_ ); /*-*/
LX_PUBLIC uint8_t* lx_Array_getItemByKey( /*M*/
lx_array_t* object_, /*-*/
lx_chars_t key_ ); /*-*/
LX_PUBLIC uint8_t* lx_Array_getLastItem( lx_array_t* object_ ); /*M*/
/* Removes all items from the array. */
/* You have to call the destructor of each item before calling this. */
LX_PUBLIC void lx_Array_removeItems( lx_array_t* object_ ); /*M*/
LX_PUBLIC void lx_Array_removeAt( /*M*/
lx_array_t* object_, /*-*/
const size_t index_ ); /*-*/
LX_PUBLIC void lx_Array_removeItemByKey( /*M*/
lx_array_t* object_, /*-*/
lx_chars_t key_ ); /*-*/
LX_PUBLIC void lx_Array_removeLast( lx_array_t* object_ ); /*M*/
LX_PUBLIC void lx_Array_resize( /*M*/
lx_array_t* object_, /*-*/
const size_t new_count_ ); /*-*/
LX_END_NAMESPACE /*lx_c*/
#endif /*eof*/