cctools
Functions
mergesort.h File Reference

Mergesort implementation. More...

#include "list.h"

Go to the source code of this file.

Functions

void mergesort_list (struct list *lst, cmp_op_t cmp)
 Sort linked list using MergeSort. More...
 

Detailed Description

Mergesort implementation.

This provides an in-place iterative implementation of MergeSort that works on the linked lists defined in list.h.

Function Documentation

void mergesort_list ( struct list lst,
cmp_op_t  cmp 
)

Sort linked list using MergeSort.

This allows for a custom comparator that takes two data pointers and returns a number less than 0 if the first object is less than the second, 0 if the the objects are equal, and a number greater than 0 if the first object is greater than the second. An example of this is strcmp.

Parameters
lstLinked list.
cmpComparator function.