Skip to content

Commit

Permalink
Added some comments regarding the current algorithmic complexity of t…
Browse files Browse the repository at this point in the history
…he various linked list methods. Improvement can be made when needed.
  • Loading branch information
danij committed Aug 23, 2007
1 parent 62f5d96 commit 12b8fdf
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions doomsday/engine/portable/src/m_linkedlist.c
Expand Up @@ -464,8 +464,7 @@ static listnode_t *splitList(listnode_t *list)
return listb;
}

static listnode_t *doMergeSort(listnode_t *list,
comparefunc funcCompare)
static listnode_t *doMergeSort(listnode_t *list, comparefunc funcCompare)
{
listnode_t *p;

Expand Down Expand Up @@ -673,6 +672,7 @@ void *List_ExtractBack(linklist_t *llist)

/**
* Extract an element from the list at the given position.
* \note An O(n) opperation.
*
* @param llist Ptr to the list to extract an element from.
* @param position Position of the element to be extracted.
Expand Down Expand Up @@ -726,6 +726,7 @@ void *List_GetBack(const linklist_t *llist)

/**
* Retrieve a ptr to an element at the given position in a linked list.
* \note An O(n) opperation.
*
* @param llist Ptr to the list to retrieve the element from.
* @param position Position of the element to be retrieved.
Expand All @@ -744,6 +745,7 @@ void *List_GetAt(const linklist_t *llist, listindex_t position)

/**
* Exchange two elements in the linked list.
* \note An O(n+n) opperation!
*
* @param llist Ptr to the list to exchange the elements of.
* @param positionA Position of the first element being exchanged.
Expand All @@ -764,6 +766,7 @@ int List_Exchange(linklist_t *llist, listindex_t positionA,

/**
* Search the link list for a specific element.
* \note An O(n) opperation.
*
* @param llist Ptr to the list to be searched.
* @return Index of the element in the list if found, else @c <0.
Expand Down

0 comments on commit 12b8fdf

Please sign in to comment.