From 619c5cc4ab4bd94f9b270a9868bb5f08ffd76acb Mon Sep 17 00:00:00 2001 From: Bobby Bingham Date: Wed, 18 Jan 2017 18:55:22 -0600 Subject: nqasm: allow specifying labels for operands --- vector.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'vector.c') 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); +} + -- cgit v1.2.3