diff options
| author | Russell Belfer <arrbee@arrbee.com> | 2012-02-21 14:46:24 -0800 |
|---|---|---|
| committer | Russell Belfer <arrbee@arrbee.com> | 2012-02-21 14:46:24 -0800 |
| commit | b6c93aef4276051f9c4536ecbed48f4cd093bd1b (patch) | |
| tree | a15962c672890c0c8cc021dafa7d29487f81c75a /src/vector.h | |
| parent | 9c94a356cc61daa85e17c6342db9b3d62f788802 (diff) | |
| download | libgit2-b6c93aef4276051f9c4536ecbed48f4cd093bd1b.tar.gz | |
Uniform iterators for trees, index, and workdir
This create a new git_iterator type of object that provides a
uniform interface for iterating over the index, an arbitrary
tree, or the working directory of a repository.
As part of this, git ignore support was extended to support
push and pop of directory-based ignore files as the working
directory is being traversed (so the array of ignores does
not have to be recreated at each directory during traveral).
There are a number of other small utility functions in buffer,
path, vector, and fileops that are included in this patch
that made the iterator implementation cleaner.
Diffstat (limited to 'src/vector.h')
| -rw-r--r-- | src/vector.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/vector.h b/src/vector.h index ae3882558..c11e801cc 100644 --- a/src/vector.h +++ b/src/vector.h @@ -22,6 +22,7 @@ typedef struct git_vector { #define GIT_VECTOR_INIT {0} int git_vector_init(git_vector *v, unsigned int initial_size, git_vector_cmp cmp); +int git_vector_alloc(git_vector **v, unsigned int initial_size, git_vector_cmp cmp); void git_vector_free(git_vector *v); void git_vector_clear(git_vector *v); @@ -38,6 +39,11 @@ GIT_INLINE(void *) git_vector_get(git_vector *v, unsigned int position) return (position < v->length) ? v->contents[position] : NULL; } +GIT_INLINE(void *) git_vector_last(git_vector *v) +{ + return (v->length > 0) ? git_vector_get(v, v->length - 1) : NULL; +} + #define git_vector_foreach(v, iter, elem) \ for ((iter) = 0; (iter) < (v)->length && ((elem) = (v)->contents[(iter)], 1); (iter)++ ) @@ -48,6 +54,7 @@ int git_vector_insert(git_vector *v, void *element); int git_vector_insert_sorted(git_vector *v, void *element, int (*on_dup)(void **old, void *new)); int git_vector_remove(git_vector *v, unsigned int idx); +int git_vector_pop(git_vector *v, void **element); void git_vector_uniq(git_vector *v); #endif |
