Files
Ink-Shader-Language/static_array.jai

30 lines
707 B
Plaintext

Static_Array :: struct ($T : Type, $N : s64) {
array : [N] T;
capacity : s64 = N;
count : s64;
}
// operator [] :: (array : Static_Array($T, $N), index : int) -> T {
// assert(index < array.count);
// return array.array[index];
// }
// operator []= :: (array : *Static_Array($T, $N), index : int, value : T) {
// assert(index < array.count);
// array.array[index] = value;
// }
operator *[] :: (array : *Static_Array($T, $N), index : int) -> *T {
assert(index < array.count);
return *(array.array[index]);
}
array_add :: (array : *Static_Array($T, $N), item : T) {
assert(array.count + 1 < array.capacity);
print("%\n", array[array.count]);
array[array.count] = item;
array.count += 1;
}