feature: Added structure for ArrayListSlices
This commit is contained in:
@@ -7,15 +7,7 @@
|
|||||||
|
|
||||||
typedef struct ArrayList ArrayList;
|
typedef struct ArrayList ArrayList;
|
||||||
|
|
||||||
// FUCK, i forgot one of the main reasons i wanted to
|
typedef struct ArrayListSlice ArrayListSlice;
|
||||||
// implement arrays myself was because i needed
|
|
||||||
// array slices or something like this and i completely
|
|
||||||
// forgot, fuck, guess i will implement it once i get
|
|
||||||
// the tests done.
|
|
||||||
typedef struct {
|
|
||||||
ArrayList *array;
|
|
||||||
size_t offset;
|
|
||||||
} ArrayListSlice;
|
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
ARRLIST_OK = 0,
|
ARRLIST_OK = 0,
|
||||||
@@ -26,6 +18,7 @@ typedef enum {
|
|||||||
ARRLIST_NULL_ARG,
|
ARRLIST_NULL_ARG,
|
||||||
ARRLIST_INVALID_ELEM_SIZE,
|
ARRLIST_INVALID_ELEM_SIZE,
|
||||||
ARRLIST_INVALID_CAPACITY,
|
ARRLIST_INVALID_CAPACITY,
|
||||||
|
ARRLIST_IS_BORROWED,
|
||||||
} ArrayListErr;
|
} ArrayListErr;
|
||||||
|
|
||||||
ArrayList *arraylist_init(size_t capacity, size_t elem_size);
|
ArrayList *arraylist_init(size_t capacity, size_t elem_size);
|
||||||
|
|||||||
@@ -11,6 +11,14 @@ struct ArrayList{
|
|||||||
size_t elem_size;
|
size_t elem_size;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct ArrayListSlice {
|
||||||
|
ArrayList *arr;
|
||||||
|
size_t start;
|
||||||
|
size_t end;
|
||||||
|
size_t current;
|
||||||
|
bool is_safe;
|
||||||
|
};
|
||||||
|
|
||||||
// Grow and shrink factor is 2, 1.5 might give different results i guess
|
// Grow and shrink factor is 2, 1.5 might give different results i guess
|
||||||
// but i'm basing myself in that Rust implementation of array does use
|
// but i'm basing myself in that Rust implementation of array does use
|
||||||
// 2 as the factor so i guess is good :)
|
// 2 as the factor so i guess is good :)
|
||||||
|
|||||||
Reference in New Issue
Block a user