add feature for sorting list.
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
// Copyright (c) 2010 TJ Holowaychuk <[email protected]>
|
||||
//
|
||||
|
||||
#include <stdint.h>
|
||||
#include "list.h"
|
||||
|
||||
/*
|
||||
@@ -41,7 +42,7 @@ list_new(void) {
|
||||
self->head = NULL;
|
||||
self->tail = NULL;
|
||||
self->free = NULL;
|
||||
self->match = NULL;
|
||||
self->compare = NULL;
|
||||
self->len = 0;
|
||||
return self;
|
||||
}
|
||||
@@ -181,8 +182,8 @@ list_find(list_t *self, void *val) {
|
||||
list_node_t *node;
|
||||
|
||||
while ((node = list_iterator_next(it))) {
|
||||
if (self->match) {
|
||||
if (self->match(val, node->val)) {
|
||||
if (self->compare) {
|
||||
if (self->compare(val, node->val) == 0) {
|
||||
list_iterator_destroy(it);
|
||||
return node;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user