summaryrefslogtreecommitdiff
path: root/src/vector.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/vector.c')
-rw-r--r--src/vector.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/vector.c b/src/vector.c
index 8d09350fc..2fc051f0c 100644
--- a/src/vector.c
+++ b/src/vector.c
@@ -162,6 +162,26 @@ int git_vector_remove(git_vector *v, unsigned int idx)
return GIT_SUCCESS;
}
+void git_vector_uniq(git_vector *v)
+{
+ git_vector_cmp cmp;
+ unsigned int i, j;
+
+ if (v->length <= 1)
+ return;
+
+ git_vector_sort(v);
+ cmp = v->_cmp ? v->_cmp : strict_comparison;
+
+ for (i = 0, j = 1 ; j < v->length; ++j)
+ if (!cmp(v->contents + i, v->contents + j))
+ v->contents[i] = v->contents[j];
+ else
+ v->contents[++i] = v->contents[j];
+
+ v->length -= j - i - 1;
+}
+
void git_vector_clear(git_vector *v)
{
assert(v);