axle OS
x86_32 UNIX-like hobby OS
array_o.h
1 #ifndef STD_ARRAY_O_H
2 #define STD_ARRAY_O_H
3 
4 #include "std_base.h"
5 #include "array_m.h"
6 
7 __BEGIN_DECLS
8 
9 //this array is insertion sorted
10 //it always remains in a sorted state between calls
11 
12 //predicate should return non-zero if first argument is less than the second
13 //else return zero
14 typedef int8_t (*lessthan_predicate_t)(type_t, type_t);
15 typedef struct {
16  array_m* array;
17  uint16_t size;
18  lessthan_predicate_t less_than;
19 } array_o;
20 
21 //standard less than predicate
22 STDAPI int8_t standard_lessthan_predicate(type_t a, type_t b);
23 
24 //create ordered array
25 STDAPI array_o* array_o_create(uint32_t max_size, lessthan_predicate_t less_than);
26 STDAPI array_o* array_o_place(void* addr, uint32_t max_size, lessthan_predicate_t less_than);
27 
28 //destroy ordered array
29 STDAPI void array_o_destroy(array_o* array);
30 
31 //add item to array
32 STDAPI void array_o_insert(array_o* array, type_t item);
33 
34 //lookup item at index i
35 STDAPI type_t array_o_lookup(array_o* array, uint32_t i);
36 
37 //return index of item
38 STDAPI uint16_t array_o_index(array_o* array, type_t item);
39 
40 //deletes item at location i from the array
41 STDAPI void array_o_remove(array_o* array, uint32_t i);
42 
43 __END_DECLS
44 
45 #endif // STD_ARRAY_O_H
Definition: size.h:4
Definition: array_o.h:15
Definition: array_m.h:14