void ListSuite_TestPrepend( ListSuiteData* data ) {
   Index idx;

   for( idx = 0; idx < NUM_ITEMS; idx++ ) {
      List_Prepend( data->list, &data->arrayData[idx] );
   }

   pcu_check_true( data->list->nItems == NUM_ITEMS );
   for( idx = 0; idx < NUM_ITEMS; idx++ ) {
      pcu_check_true( *(int*)List_GetItem( data->list, idx ) == ((NUM_ITEMS-1) - idx) );
   }
}
Exemple #2
0
List* List_InsertAtIndex(List* list, int index, void* value)
{
    if (index == 0) // If index is first element
    {
        return List_Prepend(list, value);
    }
    else if (index < list->count) // If index out of range, or index is last element.
    {
        return List_Append(list, value);
    }
    else
    {
        return List_UnsafeInsertAtIndex(list, index, value);
    }
}
void StringList_Prepend(StringList *sl, char *s){
  List_Prepend((List *)sl,(void *)s);
}