summaryrefslogtreecommitdiff
path: root/vector.c
diff options
context:
space:
mode:
Diffstat (limited to 'vector.c')
-rw-r--r--vector.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/vector.c b/vector.c
index 57f62d7..8ff637c 100644
--- a/vector.c
+++ b/vector.c
@@ -35,3 +35,13 @@ void *vector_append(struct vector **vp)
return (char*)v + v->arrayoff + v->count++ * v->elemsize;
}
+void vector_sort(struct vector *v, int (*cmp)(const void *, const void *))
+{
+ qsort((char*)v + v->arrayoff, v->count, v->elemsize, cmp);
+}
+
+void *vector_search(struct vector *v, const void *key, int (*cmp)(const void *, const void *))
+{
+ return bsearch(key, (char*)v + v->arrayoff, v->count, v->elemsize, cmp);
+}
+