فهرست منبع

structure/Vector: Add _Count.

Ambroz Bizjak 11 سال پیش
والد
کامیت
4e2829dc53
4فایلهای تغییر یافته به همراه8 افزوده شده و 0 حذف شده
  1. 1 0
      structure/Vector_decl.h
  2. 1 0
      structure/Vector_footer.h
  3. 1 0
      structure/Vector_header.h
  4. 5 0
      structure/Vector_impl.h

+ 1 - 0
structure/Vector_decl.h

@@ -37,6 +37,7 @@ typedef struct {
 
 static int Vector_Init (Vector *o, size_t capacity) WARN_UNUSED;
 static void Vector_Free (Vector *o);
+static size_t Vector_Count (Vector *o);
 static VectorElem * Vector_Get (Vector *o, size_t index);
 static int Vector_AllocAppend (Vector *o, size_t count, VectorElem **out_ptr) WARN_UNUSED;
 static void Vector_DoAppend (Vector *o, size_t count);

+ 1 - 0
structure/Vector_footer.h

@@ -34,6 +34,7 @@
 #undef VectorElem
 #undef Vector_Init
 #undef Vector_Free
+#undef Vector_Count
 #undef Vector_Get
 #undef Vector_AllocAppend
 #undef Vector_DoAppend

+ 1 - 0
structure/Vector_header.h

@@ -35,6 +35,7 @@
 #define VectorElem VECTOR_ELEM_TYPE
 #define Vector_Init MERGE(VECTOR_NAME, _Init)
 #define Vector_Free MERGE(VECTOR_NAME, _Free)
+#define Vector_Count MERGE(VECTOR_NAME, _Count)
 #define Vector_Get MERGE(VECTOR_NAME, _Get)
 #define Vector_AllocAppend MERGE(VECTOR_NAME, _AllocAppend)
 #define Vector_DoAppend MERGE(VECTOR_NAME, _DoAppend)

+ 5 - 0
structure/Vector_impl.h

@@ -49,6 +49,11 @@ static void Vector_Free (Vector *o)
     BFree(o->elems);
 }
 
+static size_t Vector_Count (Vector *o)
+{
+    return o->count;
+}
+
 static VectorElem * Vector_Get (Vector *o, size_t index)
 {
     ASSERT(index < o->capacity)