(MOD) Implemented Array_Create, Array_CopyOf and Array_Delete
(MOD) Replaced project compiler from "gcc" with "clang" due to out-of-order execution keep happening after running with Array. (MOD) Removed certain functions from Utils due to insufficiencies of usage. (MOD) Defined 1 more macro "fail". (MOD) Fixed 1 bug from "var.c": Struct member "alive" was not under supervision from the entire programme cycle. (MOD) Removed 1 useless usage for "Utils_LiteraliseInteger". (MOD) Removed 1 useless block of commented code.
This commit is contained in:
@@ -6,51 +6,28 @@
|
||||
typedef struct {
|
||||
int len;
|
||||
Var *members;
|
||||
bool alive;
|
||||
} Array;
|
||||
|
||||
# define ArrayIndexOutOfBound = (Status){\
|
||||
.identity = nameof(ArrayIndexOutOfBound),\
|
||||
.value = 1,\
|
||||
.description = "Given index was accessing illegal address.",\
|
||||
.characteristic = STATUS_ERROR,\
|
||||
.prev = &MemoryViolation\
|
||||
}
|
||||
DEFSTATUS(ArrayIndexOutOfBound, 1, "Given index was accessing illegal address.", STATUS_ERROR, &MemoryViolation);
|
||||
DEFSTATUS(InvalidArrayLength, 1, "Given length is invalid.", STATUS_ERROR, &ErrorStatus);
|
||||
|
||||
# define InvalidArrayLength (Status){\
|
||||
.value = 1,\
|
||||
.description = "Given length is invalid.",\
|
||||
.characteristic = STATUS_ERROR,\
|
||||
.prev = &ErrorStatus\
|
||||
}
|
||||
|
||||
/* Elementary. */
|
||||
Status Array_Create(Array *inst, int len, size_t size)
|
||||
throws(InsufficientMemory InvalidArrayLength);
|
||||
Status Array_Create(Array *inst, int len, size_t size);
|
||||
Status Array_CopyOf(Array *inst, Array *other);
|
||||
Status Array_Delete(Array *inst);
|
||||
void Array_Delete(Array *inst);
|
||||
Status Array_GetIdx(Array *inst, Var *store, int index);
|
||||
throws(ArrayIndexOutOfBound);
|
||||
Status Array_SetIdx(Array *inst, Var *source, int index);
|
||||
throws(ArrayIndexOutOfBound);
|
||||
bool Array_Equals(Array *arr1, Array *arr2);
|
||||
|
||||
/* Extensional. */
|
||||
Status ArrayUtils_Insert(Array *inst, Var *item, int index);
|
||||
throws(ArrayIndexOutOfBound);
|
||||
Status ArrayUtils_InsertArray(Array *inst, Array *items, int index);
|
||||
throws(ArrayIndexOutOfBound);
|
||||
Status ArrayUtils_Remove(Array *inst, int index);
|
||||
throws(ArrayIndexOutOfBound);
|
||||
Status ArrayUtils_RemoveArray(Array *inst, int off, int len);
|
||||
throws(ArrayIndexOutOfBound InvalidArrayLength);
|
||||
Status ArrayUtils_Subarray(Array *inst, Array *store, int off, int len);
|
||||
throws(ArrayIndexOutOfBound InvalidArrayLength);
|
||||
Status ArrayUtils_Fill(Array *inst, Var *elem, int off, int len);
|
||||
throws(ArrayIndexOutOfBound InvalidArrayLength);
|
||||
Status ArrayUtils_Search(Array *inst, Var *item, int *store);
|
||||
Status ArrayUtils_SearchArray(Array *inst, Array *items, int *store);
|
||||
Status ArrayUtils_Split(Array *inst, Array *fore, Array *rear, int index);
|
||||
throws(ArrayIndexOutOfBound);
|
||||
Status ArrayUtils_Revert(Array *inst);
|
||||
bool ArrayUtils_IsEmpty(Array *inst);
|
||||
bool ArrayUtils_IsBlank(Array *inst);
|
||||
|
Reference in New Issue
Block a user