TutPtrAryInsertAfter insert a new item in a pointer array after the specified item
T_BOOL TutPtrAryInsertAfter(ptr_ary, index_item, new_item
) T_PTR_ARYptr_ary
; T_PTRindex_item
; T_PTRnew_item
;
ptr_ary
pointer array to operate on
index_item
item in the array after which the new item is inserted
new_item
new item that is inserted in the array
TRUE
if the operation is a success, FALSE
if index_item
is not an element in the array, or if ptr_ary
is invalid.
None
TutPtrAryInsertAfter inserts new_item
in ptr_ary
after the first occurrence of index_item
. index_item
must be part of the array for the insertion to work. During this operation, ptr_ary
may be resized as necessary to accommodate the new element.
TutPtrAryInsertAfter calls the pointer array change callbacks with the reason T_PA_ITEM_INSERTED.
None
TutPtrAryAppend, TutPtrAryInsertBefore
This example inserts a new item in the pointer array:
T_PTR_ARY ptr_ary; T_INT4 i, *int_ptr, *mark_ptr;/* create the pointer array with initial size of 30 */
ptr_ary = TutPtrAryCreate(30);/* fill it up with 25 entries */
for (i = 0; i < 25; i++) {/* allocate the space for the next element */
T_MALLOC(int_ptr, sizeof(T_INT4), T_INT4 *); *int_ptr = i;/* append the item to the array, ignore the index */
TutPtrAryAppend(ptr_ary, int_ptr, NULL); if (i == 13) { mark_ptr = int_ptr; } }/* now create and insert a new item after the marked one */
T_MALLOC(int_ptr, sizeof(T_INT4, T_INT4 *); *int_ptr = 169; TutPtrAryInsertAfter(ptr_ary, mark_ptr, int_ptr);/* after the call to TutPtrAryInsertAfter, the array will have
the following elements:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 169 14 ... 24
TutPtrAryGetItemCount returns 26 as the number of items in
the array */
TIBCO SmartSockets™ Utilities Software Release 6.8, July 2006 Copyright © TIBCO Software Inc. All rights reserved www.tibco.com |