10 #ifndef K_API_ARRAY_LIST_H
11 #define K_API_ARRAY_LIST_H
14 #include <kApi/Data/kArrayList.x.h>
131 #define kArrayList_AttachT(kArrayList_list, TPtr_items, kType_itemType, kSize_capacity) \
132 xkArrayList_AttachT(kArrayList_list, TPtr_items, kType_itemType, kSize_capacity, sizeof(*(TPtr_items)))
163 #define kArrayList_ImportT(kArrayList_list, TPtr_items, kType_itemType, kSize_count) \
164 xkArrayList_ImportT(kArrayList_list, TPtr_items, kType_itemType, kSize_count, sizeof(*(TPtr_items)))
189 #define kArrayList_AppendT(kArrayList_list, TPtr_items, kSize_count) \
190 xkArrayList_AppendT(kArrayList_list, TPtr_items, kSize_count, sizeof(*(TPtr_items)))
260 #define kArrayList_AddT(kArrayList_list, TPtr_item) \
261 xkArrayList_AddT(kArrayList_list, TPtr_item, sizeof(*(TPtr_item)))
290 #define kArrayList_InsertT(kArrayList_list, kSize_before, TPtr_item) \
291 xkArrayList_InsertT(kArrayList_list, kSize_before, TPtr_item, sizeof(*(TPtr_item)))
316 #define kArrayList_RemoveT(kArrayList_list, kSize_index, TPtr_item) \
317 xkArrayList_RemoveT(kArrayList_list, kSize_index, TPtr_item, sizeof(*(TPtr_item)))
358 #define kArrayList_SetItemT(kArrayList_list, kSize_index, TPtr_item) \
359 xkArrayList_SetItemT(kArrayList_list, kSize_index, TPtr_item, sizeof(*(TPtr_item)))
384 #define kArrayList_ItemT(kArrayList_list, kSize_index, TPtr_item) \
385 xkArrayList_ItemT(kArrayList_list, kSize_index, TPtr_item, sizeof(*(TPtr_item)))
401 #define kArrayList_SetAsT(kArrayList_list, kSize_index, T_value, T) \
402 (kPointer_WriteAs(xkArrayList_AsT(kArrayList_list, kSize_index, sizeof(T)), T_value, T), (void)0)
417 #define kArrayList_AsT(kArrayList_list, kSize_index, T) \
418 kPointer_ReadAs(xkArrayList_AsT(kArrayList_list, kSize_index, sizeof(T)), T)
447 if ((obj->count + count) > obj->capacity)
469 if (count > obj->count)
516 #define kArrayList_DataT(kArrayList_list, T) \
517 kCast(T*, xkArrayList_DataT(kArrayList_list, sizeof(T)))
548 #define kArrayList_DataAtT(kArrayList_list, kSSize_index, T) \
549 kCast(T*, xkArrayList_DataAtT(kArrayList_list, kSSize_index, sizeof(T)))
562 return obj->count * obj->itemSize;
578 # if !defined(K_FSS_912_DISABLE_BOUNDS_CHECK)
600 #define kArrayList_AtT(kArrayList_list, kSize_index, T) \
601 kCast(T*, xkArrayList_AtT(kArrayList_list, kSize_index, sizeof(T)))
614 return obj->itemType;
628 return obj->itemSize;
656 return obj->capacity;
682 #define kArrayList_FirstT(kArrayList_list, T) \
683 kCast(T*, xkArrayList_FirstT(kArrayList_list, sizeof(T)))
708 #define kArrayList_LastT(kArrayList_list, T) \
709 kCast(T*, xkArrayList_LastT(kArrayList_list, sizeof(T)))
736 #define kArrayList_BeginT(kArrayList_list, T) \
737 kCast(T*, xkArrayList_BeginT(kArrayList_list, sizeof(T)))
764 #define kArrayList_EndT(kArrayList_list, T) \
765 kCast(T*, xkArrayList_EndT(kArrayList_list, sizeof(T)))
792 #define kArrayList_RBeginT(kArrayList_list, T) \
793 kCast(T*, xkArrayList_RBeginT(kArrayList_list, sizeof(T)))
820 #define kArrayList_REndT(kArrayList_list, T) \
821 kCast(T*, xkArrayList_REndT(kArrayList_list, sizeof(T)))
kStatus kArrayList_Resize(kArrayList list, kSize count)
Sets the current count of list items to the specified value.
kStatus kArrayList_Insert(kArrayList list, kSize before, const void *item)
Inserts an item into the list at the specified position.
kSize kArrayList_DataSize(kArrayList list)
Returns the total size of list data (Count x ItemSize), in bytes.
Definition: kArrayList.h:558
kStatus kArrayList_Attach(kArrayList list, void *items, kType itemType, kSize capacity)
Attaches the list object to an external buffer.
kStatus kArrayList_Purge(kArrayList list)
Disposes any elements in the list and sets the count of list items to zero.
kStatus kArrayList_Append(kArrayList list, const void *items, kSize count)
Appends the specified items to the list.
void * kArrayList_Data(kArrayList list)
Returns a pointer to the list item buffer.
Definition: kArrayList.h:498
kStatus kArrayList_Add(kArrayList list, const void *item)
Adds the specified item to the end of the list.
kStatus kArrayList_Reserve(kArrayList list, kSize capacity)
Ensures that capacity is reserved for at least the specified number of list items.
Represents an unsigned integer that can store a pointer address.
Abstract base class for memory allocator types.
kStatus kArrayList_Remove(kArrayList list, kSize index, void *item)
Removes an item from the list at the specified index, optionally returning the value.
kType kArrayList_ItemType(kArrayList list)
Returns the list element type.
Definition: kArrayList.h:610
void * kPointer_ItemOffset(const void *pointer, kSSize itemIndex, kSize itemSize)
Gets a pointer to the Nth element of an array.
Definition: kApiDef.h:294
#define kCheck(EXPRESSION)
Executes a return statement if the given expression is not kOK.
Definition: kApiDef.h:561
kStatus kArrayList_SetItem(kArrayList list, kSize index, const void *item)
Sets the value of an item.
void * kArrayList_Begin(kArrayList list)
Returns a pointer to the first item for forward iteration.
Definition: kArrayList.h:718
void * kArrayList_Last(kArrayList list)
Returns a pointer to the last item in the list.
Definition: kArrayList.h:692
#define kInlineFx(TYPE)
Inline method declaration helper.
Definition: kApiDef.h:26
Represents a signed integer that can store a pointer address.
kStatus kArrayList_Allocate(kArrayList list, kType itemType, kSize initialCapacity)
Reallocates the list item buffer.
void * kArrayList_RBegin(kArrayList list)
Returns a pointer to the first item for reverse iteration.
Definition: kArrayList.h:774
kStatus kArrayList_Construct(kArrayList *list, kType itemType, kSize initialCapacity, kAlloc allocator)
Constructs a kArrayList object.
#define kObj(TypeName_T, T_object)
Declares a local "obj" (this-pointer) variable and initializes it from a type-checked object handle...
Definition: kApiDef.h:3383
kSize kArrayList_Capacity(kArrayList list)
Returns the number of elements for which space has been allocated.
Definition: kArrayList.h:652
kSize kArrayList_ItemSize(kArrayList list)
Returns the list element size.
Definition: kArrayList.h:624
Core Zen type declarations.
kStatus kArrayList_AddCount(kArrayList list, kSize count)
Increases the list count by the specified amount.
Definition: kArrayList.h:443
kSize kArrayList_Count(kArrayList list)
Returns the current count of items in the list.
Definition: kArrayList.h:638
void * kArrayList_REnd(kArrayList list)
Returns a pointer to one past the last item for reverse iteration.
Definition: kArrayList.h:802
#define kERROR_STATE
Operation cannot be completed in the current state.
Definition: kApiDef.h:490
kStatus kArrayList_Clear(kArrayList list)
Sets the count of list items to zero.
Definition: kArrayList.h:212
kStatus kArrayList_Item(kArrayList list, kSize index, void *item)
Gets the value of an item.
kStatus kArrayList_Discard(kArrayList list, kSize index)
Removes an item from the list at the specified index.
Definition: kArrayList.h:330
Represents metadata about a type (class, interface, or value).
kStatus kArrayList_Zero(kArrayList list)
Sets the memory for all list elements to zero.
Represents a list implemented with a dynamic array.
#define kAssert(EXPRESSION)
Aborts execution if EXPRESSION is kFALSE.
Definition: kApiDef.h:751
kStatus kArrayList_Assign(kArrayList list, kArrayList source)
Performs a shallow copy of the source list.
#define kOK
Operation successful.
Definition: kApiDef.h:515
Represents an error code.
void * kArrayList_First(kArrayList list)
Returns a pointer to the first item in the list.
Definition: kArrayList.h:666
#define kNULL
Null pointer.
Definition: kApiDef.h:269
void * kArrayList_DataAt(kArrayList list, kSSize index)
Calculates an address relative to the start of the buffer.
Definition: kArrayList.h:529
kStatus kArrayList_Import(kArrayList list, const void *items, kType itemType, kSize count)
Copies the specified items into the list, replacing existing contents.
void * kArrayList_End(kArrayList list)
Returns a pointer to one past the last item for forward iteration.
Definition: kArrayList.h:746
kStatus kArrayList_RemoveCount(kArrayList list, kSize count)
Decreases the list count by the specified amount.
Definition: kArrayList.h:465
void * kArrayList_At(kArrayList list, kSize index)
Returns a pointer to the specified item in the list buffer.
Definition: kArrayList.h:576