Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVicent Marti <tanoku@gmail.com>2010-12-02 05:31:54 +0300
committerVicent Marti <tanoku@gmail.com>2010-12-02 05:31:54 +0300
commitc4034e63f358cfed6bd851a831c50dbcd5006ffe (patch)
tree2417969470e0b1e8a65b928c711ab5dab34eb9c8 /src/vector.h
parent1e35f929ef0df0e28c14655fa47406732f30cc73 (diff)
Refactor all 'vector' functions into common code
All the operations on the 'git_index_entry' array and the 'git_tree_entry' array have been refactored into common code in the src/vector.c file. The new vector methods support: - insertion: O(1) (avg) - deletion: O(n) - searching: O(logn) - sorting: O(logn) - r. access: O(1) Signed-off-by: Vicent Marti <tanoku@gmail.com>
Diffstat (limited to 'src/vector.h')
-rw-r--r--src/vector.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/vector.h b/src/vector.h
new file mode 100644
index 000000000..8239abade
--- /dev/null
+++ b/src/vector.h
@@ -0,0 +1,32 @@
+#ifndef INCLUDE_vector_h__
+#define INCLUDE_vector_h__
+
+#include "git/common.h"
+
+
+typedef int (*git_vector_cmp)(const void *, const void *);
+typedef int (*git_vector_srch)(const void *, const void *);
+
+typedef struct git_vector {
+ unsigned int _alloc_size;
+ git_vector_cmp _cmp;
+ git_vector_srch _srch;
+
+ void **contents;
+ unsigned int length;
+} git_vector;
+
+
+int git_vector_init(git_vector *v, unsigned int initial_size, git_vector_cmp cmp, git_vector_srch srch);
+void git_vector_free(git_vector *v);
+void git_vector_clear(git_vector *v);
+
+int git_vector_search(git_vector *v, const void *key);
+void git_vector_sort(git_vector *v);
+
+void *git_vector_get(git_vector *v, unsigned int position);
+
+int git_vector_insert(git_vector *v, void *element);
+int git_vector_remove(git_vector *v, unsigned int idx);
+
+#endif