TutPtrAryInsertBefore insert a new item in a pointer array before the specified item
T_BOOL TutPtrAryInsertBefore(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 before 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 the ptr_ary
is invalid.
None
TutPtrAryInsertBefore inserts the new item in the array before the first occurrence of the specified index item. index_item
must be part of the array for the insertion to work. During this operation, the array may be resized as necessary to accommodate the new element.
TutPtrAryInsertBefore calls the pointer array change callbacks with the reason T_PA_ITEM_INSERTED.
None
TutPtrAryAppend, TutPtrAryInsertAfter
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 before the marked one */
T_MALLOC(int_ptr, sizeof(T_INT4), T_INT4 *); *int_ptr = 169; TutPtrAryInsertBefore(ptr_ary, mark_ptr, int_ptr);/ * after the call to TutPtrAryInsertBefore, the array will have
the following elements:
0 1 2 3 4 5 6 7 8 9 10 11 12 169 13 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 |