Add git_vector_foreach

You can use it just as you'd use a for-loop

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
This commit is contained in:
Carlos Martín Nieto 2011-07-28 23:59:53 +02:00
parent b5b474dd0d
commit bcf21c556c

View File

@ -30,6 +30,9 @@ GIT_INLINE(void *) git_vector_get(git_vector *v, unsigned int position)
return (position < v->length) ? v->contents[position] : NULL; return (position < v->length) ? v->contents[position] : NULL;
} }
#define git_vector_foreach(v, iter, elem) \
for ((iter) = 0; (iter) < (v)->length && ((elem) = (v)->contents[(iter)], 1); (iter)++ )
int git_vector_insert(git_vector *v, void *element); int git_vector_insert(git_vector *v, void *element);
int git_vector_remove(git_vector *v, unsigned int idx); int git_vector_remove(git_vector *v, unsigned int idx);
void git_vector_uniq(git_vector *v); void git_vector_uniq(git_vector *v);