diff options
| author | Russell Belfer <rb@github.com> | 2013-08-20 15:18:48 -0700 |
|---|---|---|
| committer | Russell Belfer <rb@github.com> | 2013-08-20 16:14:24 -0700 |
| commit | 0b7cdc02637bcc8491153a476460c9feab33f8ee (patch) | |
| tree | f04954a8421e2f30c72ae2354267490ba1a2666c /src/vector.h | |
| parent | 0f0f565507565520759bffc22976c583497ec01f (diff) | |
| download | libgit2-0b7cdc02637bcc8491153a476460c9feab33f8ee.tar.gz | |
Add sorted cache data type
This adds a convenient new data type for caching the contents of
file in memory when each item in that file corresponds to a name
and you need to both be able to lookup items by name and iterate
over them in some sorted order. The new data type has locks in
place to manage usage in a threaded environment.
Diffstat (limited to 'src/vector.h')
| -rw-r--r-- | src/vector.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/vector.h b/src/vector.h index 1bda9c93d..ad1c34ea1 100644 --- a/src/vector.h +++ b/src/vector.h @@ -55,6 +55,11 @@ GIT_INLINE(void *) git_vector_get(const git_vector *v, size_t position) #define GIT_VECTOR_GET(V,I) ((I) < (V)->length ? (V)->contents[(I)] : NULL) +GIT_INLINE(size_t) git_vector_length(const git_vector *v) +{ + return v->length; +} + GIT_INLINE(void *) git_vector_last(const git_vector *v) { return (v->length > 0) ? git_vector_get(v, v->length - 1) : NULL; |
