00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef _RM_CORE_VECTOR_H_
00014 #define _RM_CORE_VECTOR_H_
00015
00016 #include <Core/RmTypes.h>
00017
00018
00019
00020
00021
00022
00023
00024
00025 #define RM_VECTOR_OK 0
00026 #define RM_VECTOR_REALLOCATE -1
00027 #define RM_VECTOR_MEMORY_ERROR -2
00028 #define RM_VECTOR_OUT_OF_RANGE -3
00029 #define RM_VECTOR_NOT_FOUND -4
00030 #define RM_VECTOR_INVALID_PARAM -5
00031
00032
00033
00034
00035 typedef int (*SortFunc)(const void*, const void*);
00036
00037 #define RM_VECTOR_STRUCT \
00038 int count; \
00039 int initAlloc; \
00040 int allocCount; \
00041 int elementSize; \
00042 int (*compare)(const void*, const void*); \
00043 void *data;
00044
00045 #define RM_VECTOR_TYPED_DATA(type) \
00046 int count; \
00047 int initAlloc; \
00048 int allocCount; \
00049 int elementSize; \
00050 int (*compare)(const type*, const type*); \
00051 type *data;
00052
00053 #define RM_VECTOR_NAMED_DATA(name) \
00054 int name##Count; \
00055 int name##InitAlloc; \
00056 int name##AllocCount; \
00057 int name##ElementSize; \
00058 int (*name##Compare)(const void*, const void*); \
00059 void *name##Data;
00060
00061 #define RM_VECTOR_TYPED_NAMED_DATA(type, name) \
00062 int name##Count; \
00063 int name##InitAlloc; \
00064 int name##AllocCount; \
00065 int name##ElementSize; \
00066 int (*name##Compare)(const type*, const type*); \
00067 type *name;
00068
00069
00070
00071
00072 typedef struct
00073 {
00074 int count;
00075 int initAlloc;
00076 int allocCount;
00077 int elementSize;
00078 int (*compare)(const void*, const void*);
00079 void *data;
00080 } RmVector;
00081
00082
00083
00084
00085 RM_API int RmVectorAddElement(RmVector* v, void* element, int nIndex, char append);
00086 RM_API int RmVectorAppend(RmVector* v, void* element, int nIndex);
00087 RM_API int RmVectorAppendBack(RmVector* v, void* element);
00088 RM_API int RmVectorCheckAlloc(RmVector* v);
00089 RM_API int RmVectorFind(RmVector* v, void* element, int* result);
00090 RM_API int RmVectorFree(RmVector* v);
00091 RM_API int RmVectorInsert(RmVector* v, void* element, int nIndex);
00092 RM_API int RmVectorRemoveIndex(RmVector* v, int nIndex);
00093 RM_API int RmVectorRemoveSortedElement(RmVector* v, void* element);
00094 RM_API int RmVectorSort(RmVector* v);
00095 RM_API int RmVectorSortedInsert(RmVector* v, void* element);
00096 RM_API int RmVectorSortedInsertAllowDuplicates(RmVector* v, void* element);
00097
00098 #endif