digraph/linked_list.c
/*
 * The linked_list_swap function swaps the elements in two specific indexes within the linkedlist struct.
 */
The linked_list_swap function swaps the elements in two specific indexes within the linkedlist struct.
The linked_list_swap function swaps the elements in two specific indexes within the linkedlist struct .
void linked_list_swap(LinkedList* list, int index1, int index2)
{
	if(list == NULL || index1 > list->size - 1 || index2 > list->size - 1)
		return;
	void* temp1 = linked_list_remove(list,index1);
	void* temp2 = linked_list_remove(list, index2 - 1);
	linked_list_add_at(list, index1, temp2);
	linked_list_add_at(list, index2, temp1);
}
void linked_list_swap ( LinkedList * list , int index1 , int index2 ) { if ( list == NULL || index1 > list -> size - 1 || index2 > list -> size - 1 ) return ; void * temp1 = linked_list_remove ( list , index1 ) ; void * temp2 = linked_list_remove ( list , index2 - 1 ) ; linked_list_add_at ( list , index1 , temp2 ) ; linked_list_add_at ( list , index2 , temp1 ) ; }
The linked_list_swap function swaps the elements in two specific indexes within the linkedlist struct.
The linked_list_swap function swaps the elements in two specific indexes within the linkedlist struct .
// If the list variable is NULL, or if either index references are out of bounds, return immediately.