00001 #ifndef _MQARRAY_FINDER_H_
00002 #define _MQARRAY_FINDER_H_
00003
00004
00005
00006
00007
00008
00019 extern int MQARRAY_FINDER_CMP_MODE;
00020
00021 enum {MQARRAY_FINDER_CMP_RIGHT_BIAS,
00022 MQARRAY_FINDER_CMP_LEFT_BIAS};
00023
00030 struct MQArrayFinder
00031 {
00032 const void* data_array;
00033 unsigned int size_of_element;
00034
00035 int curr_left_index;
00036 int curr_right_index;
00037
00038 void* temp1;
00039 void* temp2;
00040
00041
00042 void*(*getElement) (const void* array, unsigned int index);
00043
00044 void (*addElements)(const void* sum, const void* p1, const void* p2);
00045 int (*cmpElements)(const void* p1, const void* p2);
00046 };
00047
00048 typedef struct MQArrayFinder MQArrayFinder;
00049
00050 void MQArrayFinder_init(MQArrayFinder* finder, const void* data, size_t size_of_element,
00051 void*(*getElement) (const void*, unsigned int),
00052 void (*addElements)(const void*, const void*, const void*),
00053 int (*cmpElements)(const void*, const void*));
00054
00055 void MQArrayFinder_destroy(MQArrayFinder* finder);
00056
00057 int MQArrayFinder_getIndexClosestToValue(MQArrayFinder* finder, int start, int stop, const void* p);
00058 int MQArrayFinder_getIndicesWithinInterval(MQArrayFinder* finder, int start, int stop, int *i, int *j, const void* p, const void* q);
00059
00060 #endif
00061