#ifndef __GESORT_H
#define __GESORT_H

#include "ge_math.h"
#include "c4d_misc.h"

class GeSortAndSearchEx
{
	private:
		void Bsort(void *start, LONG count, LONG msize);
		void Wsort(void *start, LONG count, LONG msize);
		void Lsort(void *start, LONG count, LONG msize);

		inline void Bswap(CHAR *a, CHAR *b, LONG i);
		inline void Wswap(SWORD *a, SWORD *b, LONG i);
		inline void Lswap(LONG *a, LONG *b, LONG i);

	protected:
		virtual LONG Compare(void *a, void *b) = 0;
		// if(a==b) return 0;
		// if(a<b) return -1;
		// if(a>b) return 1;

	public:
		void Sort(void *start, LONG count, LONG msize);
		void *Search(void *Key, void *Start, LONG count, LONG msize);
		void *SearchOrInsert(void *Key,void *Start,LONG count,LONG msize, LONG &insertidx);
};

#endif