3 #if defined(_M_IX86) || defined(_M_IX64) 12 unsigned char * ptr1 = (
unsigned char*)item1, * ptr2 = (
unsigned char*)item2;
32 for(n=0;n<p_count;n++)
42 PFC_ASSERT(n<p_count);
43 p_callback.
swap(prev,next);
55 unsigned char * base = (
unsigned char *) data;
72 swapfunc(base+width*prev,base+width*next,width);
87 sort_callback_impl_legacy(
88 void * p_base,
t_size p_width,
89 int (*p_comp)(
const void *,
const void *),
90 void (*p_swap)(
void *,
void *,
t_size)
92 m_base((
char*)p_base), m_width(p_width),
93 m_comp(p_comp), m_swap(p_swap)
100 return m_comp(m_base + p_index1 * m_width, m_base + p_index2 * m_width);
105 m_swap(m_base + p_index1 * m_width, m_base + p_index2 * m_width, m_width);
111 int (*m_comp)(
const void *,
const void *);
112 void (*m_swap)(
void *,
void *,
t_size);
120 int (*comp)(
const void *,
const void *),
121 void (*swap)(
void *,
void *,
t_size) )
123 sort_callback_impl_legacy cb(base,width,comp,swap);
128 const t_size max = p_base + p_count;
129 for(
t_size walk = p_base + 1; walk < max; ++walk) {
130 for(
t_size prev = p_base; prev < walk; ++prev) {
142 #ifdef PFC_HAVE_RDTSC 152 const uint64_t rm = (uint64_t)RAND_MAX + 1;
158 if (m >= count)
break;
161 return (
t_size)(v % count);
165 PFC_ASSERT(p_count > 2);
170 if (val2 >= val1) val2++;
171 if (val3 >= val1) val3++;
172 if (val3 >= val2) val3++;
174 val1 += p_base; val2 += p_base; val3 += p_base;
192 const t_size target = p_base + p_count - 1;
193 if (pivot != target) {
194 p_callback.
swap(pivot,target); pivot = target;
199 t_size partition = p_base;
202 for(
t_size walk = p_base; walk < pivot; ++walk) {
203 const int comp = p_callback.
compare(walk,pivot);
204 bool trigger =
false;
208 }
else if (comp < 0) {
212 if (partition != walk) p_callback.
swap(partition,walk);
217 if (pivot != partition) {
218 p_callback.
swap(pivot,partition); pivot = partition;
221 newsort(p_callback,p_base,pivot-p_base);
222 newsort(p_callback,pivot+1,p_count-(pivot+1-p_base));
226 srand((
unsigned int)(
uniqueVal() ^ p_num));
244 for(n=0;n<p_count;n++)
m_order[n] = n;
static t_uint64 uniqueVal()
static counter uniqueValCounter
void sort(pfc::sort_callback &p_callback, t_size p_num)
static void squaresort(pfc::sort_callback &p_callback, t_size const p_base, t_size const p_count)
int sgn_t(const T &p_val)
void reorder(reorder_callback &p_callback, const t_size *p_order, t_size p_count)
static t_size myrand(t_size count)
virtual void swap(t_size p_index1, t_size p_index2)
static t_size __pivot_helper(pfc::sort_callback &p_callback, t_size const p_base, t_size const p_count)
static bool g_get(const t_array &p_array, t_size idx)
virtual int compare(t_size p_index1, t_size p_index2) const
int compare(t1 const &p1, t2 const &p2)
virtual int compare(t_size p_index1, t_size p_index2) const =0
void sort_stable(sort_callback &p_callback, t_size p_count)
static void g_set(t_array &p_array, t_size idx, bool val)
virtual void swap(t_size p_index1, t_size p_index2)=0
void swap_check(t_size p_index1, t_size p_index2)
void set_size(t_size p_size)
pfc::sized_int_t< sizeof(size_t) >::t_signed t_ssize
virtual void swap(t_size p_index1, t_size p_index2)=0
static void newsort(pfc::sort_callback &p_callback, t_size const p_base, t_size const p_count)
void swap_void(void *item1, void *item2, t_size width)
void reorder_void(void *data, t_size width, const t_size *order, t_size num, void(*swapfunc)(void *item1, void *item2, t_size width))
void swap_t(T &p_item1, T &p_item2)
static void __sort_2elem_helper(pfc::sort_callback &p_callback, t_size &p_elem1, t_size &p_elem2)
void memset_t(T *p_buffer, const t_val &p_val, t_size p_count)
array_t< t_size > m_order
static t_size g_estimate_size(t_size p_count)
sort_callback_stabilizer(sort_callback &p_chain, t_size p_count)
void sort_void(void *base, t_size num, t_size width, int(*comp)(const void *, const void *))
void sort_void_ex(void *base, t_size num, t_size width, int(*comp)(const void *, const void *), void(*swap)(void *, void *, t_size))