aboutsummaryrefslogtreecommitdiff
path: root/src/kernel/memory/ordered_array.h
blob: cf753e379abf00ee9ccf3552def09058485ffd73 (plain) (blame)
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
#ifndef MELVIX_ORDERED_ARRAY_H
#define MELVIX_ORDERED_ARRAY_H

#include <stdint.h>

typedef void *type_t;

typedef int8_t (*lessthan_predicate_t)(type_t, type_t);

typedef struct {
    type_t *array;
    uint32_t size;
    uint32_t max_size;
    lessthan_predicate_t less_than;
} ordered_array_t;

int8_t standard_lessthan_predicate(type_t a, type_t b);

ordered_array_t create_ordered_array(uint32_t max_size, lessthan_predicate_t less_than);

ordered_array_t place_ordered_array(void *addr, uint32_t max_size, lessthan_predicate_t less_than);

void destroy_ordered_array(ordered_array_t *array);

void insert_ordered_array(type_t item, ordered_array_t *array);

type_t lookup_ordered_array(uint32_t i, ordered_array_t *array);

void remove_ordered_array(uint32_t i, ordered_array_t *array);

#endif