Zen API

- Home
- Topics
- Types
- Files

All Classes Files Functions Variables Typedefs Friends Macros Modules Pages
kList.h
Go to the documentation of this file.
1
10 #ifndef K_API_LIST_H
11 #define K_API_LIST_H
12
13 #include <kApi/kApiDef.h>
14
79 //typedef kObject kList; --forward-declared in kApiDef.x.h
80
87 typedef kPointer kListItem;
88
89 #include <kApi/Data/kList.x.h>
90
101 kFx(kStatus) kList_Construct(kList* list, kType itemType, kSize initialCapacity, kAlloc allocator);
102
114 kFx(kStatus) kList_Allocate(kList list, kType itemType, kSize initialCapacity);
115
127 kFx(kStatus) kList_Assign(kList list, kList source);
128
136 kInlineFx(kType) kList_ItemType(kList list)
137 {
138 kObj(kList, list);
139
140 return obj->contentField.type;
141 }
142
150 kInlineFx(kSize) kList_Count(kList list)
151 {
152 kObj(kList, list);
153
154 return obj->count;
155 }
156
164 kInlineFx(kSize) kList_Capacity(kList list)
165 {
166 kObj(kList, list);
167
168 return obj->capacity;
169 }
170
182 kFx(kStatus) kList_Add(kList list, const void* itemContent, kListItem* item);
183
198 #define kList_AddT(kList_list, TPtr_itemContent, kListItemPtr_item) \
199 xkList_AddT(kList_list, TPtr_itemContent, kListItemPtr_item, sizeof(*TPtr_itemContent))
200
213 kFx(kStatus) kList_Insert(kList list, kListItem before, const void* itemContent, kListItem* item);
214
230 #define kList_InsertT(kList_list, kListItem_before, TPtr_itemContent, kListItemPtr_item) \
231 xkList_InsertT(kList_list, kListItem_before, TPtr_itemContent, kListItemPtr_item, sizeof(*TPtr_itemContent))
232
241 kFx(kStatus) kList_Remove(kList list, kListItem item);
242
252 kFx(kStatus) kList_SetItem(kList list, kListItem item, const void* content);
253
266 #define kList_SetItemT(kList_list, kListItem_item, TPtr_content) \
267 xkList_SetItemT(kList_list, kListItem_item, TPtr_content, sizeof(*TPtr_content))
268
278 kFx(kStatus) kList_Item(kList list, kListItem item, void* content);
279
292 #define kList_ItemT(kList_list, kListItem_item, TPtr_content) \
293 xkList_ItemT(kList_list, kListItem_item, TPtr_content, sizeof(*TPtr_content))
294
307 #define kList_SetAsT(kList_list, kListItem_item, T_value, T) \
308 (kPointer_WriteAs(xkList_AsT(kList_list, kListItem_item, sizeof(T)), T_value, T), (void)0)
309
321 #define kList_AsT(kList_list, kListItem_item, T) \
322 kPointer_ReadAs(xkList_AsT(kList_list, kListItem_item, sizeof(T)), T)
323
332 kFx(kStatus) kList_Reserve(kList list, kSize capacity);
333
341 kFx(kStatus) kList_Clear(kList list);
342
350 kFx(kStatus) kList_Purge(kList list);
351
359 kInlineFx(kListItem) kList_First(kList list)
360 {
361 kObj(kList, list);
362
363 return obj->first;
364 }
365
373 kInlineFx(kListItem) kList_Last(kList list)
374 {
375 kObj(kList, list);
376
377 return obj->last;
378 }
379
388 kInlineFx(kListItem) kList_Next(kList list, kListItem item)
389 {
390 return xkList_ItemCast(list, item)->next;
391 }
392
401 kInlineFx(kListItem) kList_Previous(kList list, kListItem item)
402 {
403 return xkList_ItemCast(list, item)->previous;
404 }
405
416 kFx(kListItem) kList_FindIndex(kList list, kSize index);
417
426 kInlineFx(void*) kList_At(kList list, kListItem item)
427 {
428 return xkList_ItemContent(list, item);
429 }
430
443 #define kList_AtT(kList_list, kListItem_item, T) \
444 kCast(T*, xkList_AtT(kList_list, kListItem_item, sizeof(T)))
445
456 kFx(void*) kList_AtIndex(kList list, kSize index);
457
472 #define kList_AtIndexT(kList_list, kSize_index, T) \
473 kCast(T*, xkList_AtIndexT(kList_list, kSize_index, sizeof(T)))
474
475 #endif
kList::kList_Previous
kListItem kList_Previous(kList list, kListItem item)
Given a list item, gets a reference to the previous list item.
Definition: kList.h:401
kList::kList_AtIndex
void * kList_AtIndex(kList list, kSize index)
Returns a pointer to the content associated with a list item at the specified index.
kPointer
Represents a void pointer.
kList::kList_Count
kSize kList_Count(kList list)
Returns the count of list elements.
Definition: kList.h:150
kSize
Represents an unsigned integer that can store a pointer address.
kList::kList_Last
kListItem kList_Last(kList list)
Gets a reference to the last list item.
Definition: kList.h:373
kAlloc
Abstract base class for memory allocator types.
kList::kList_Capacity
kSize kList_Capacity(kList list)
Returns the number of elements for which space has been allocated.
Definition: kList.h:164
kList::kList_Clear
kStatus kList_Clear(kList list)
Sets the count of list items to zero.
kList::kList_First
kListItem kList_First(kList list)
Gets a reference to the first list item.
Definition: kList.h:359
kList::kList_Insert
kStatus kList_Insert(kList list, kListItem before, const void *itemContent, kListItem *item)
Inserts an item into the list before the specified list item.
kInlineFx
#define kInlineFx(TYPE)
Inline method declaration helper.
Definition: kApiDef.h:26
kList::kList_At
void * kList_At(kList list, kListItem item)
Returns a pointer to the content associated with a list item.
Definition: kList.h:426
kList::kList_ItemType
kType kList_ItemType(kList list)
Returns the item type.
Definition: kList.h:136
kList::kList_Assign
kStatus kList_Assign(kList list, kList source)
Performs a shallow copy of the source list.
kList::kList_Reserve
kStatus kList_Reserve(kList list, kSize capacity)
Ensures that capacity is reserved for at least the specified number of list items.
kObj
#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:2858
kList::kListItem
kPointer kListItem
Represents a node within a kList object.
kApiDef.h
Core Zen type declarations.
kList::kList_FindIndex
kListItem kList_FindIndex(kList list, kSize index)
Finds a reference to the list item at the specified index.
kList::kList_Next
kListItem kList_Next(kList list, kListItem item)
Given a list item, gets a reference to the next list item.
Definition: kList.h:388
kList::kList_Allocate
kStatus kList_Allocate(kList list, kType itemType, kSize initialCapacity)
Reallocates the list.
kList::kList_Purge
kStatus kList_Purge(kList list)
Disposes any elements in the list and sets the count of list items to zero.
kType
Represents metadata about a type (class, interface, or value).
kList::kList_Construct
kStatus kList_Construct(kList *list, kType itemType, kSize initialCapacity, kAlloc allocator)
Constructs a kList object.
kList
Represents a doubly-linked list.
kList::kList_Remove
kStatus kList_Remove(kList list, kListItem item)
Removes the specified item from the list.
kStatus
Represents an error code.
kList::kList_Add
kStatus kList_Add(kList list, const void *itemContent, kListItem *item)
Adds a new item to the end of the list.
kList::kList_SetItem
kStatus kList_SetItem(kList list, kListItem item, const void *content)
Sets the content associated with a list item.
kList::kList_Item
kStatus kList_Item(kList list, kListItem item, void *content)
Gets the content associated with a list item.