Queue: move queue_shuffle_order_range() into the class
This commit is contained in:
parent
52638c68f5
commit
2b8ce83c9b
@ -368,20 +368,15 @@ queue_sort_order_by_priority(struct queue *queue, unsigned start, unsigned end)
|
|||||||
queue);
|
queue);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
void
|
||||||
* Shuffle the order of items in the specified range, ignoring their
|
queue::ShuffleOrderRange(unsigned start, unsigned end)
|
||||||
* priorities.
|
|
||||||
*/
|
|
||||||
static void
|
|
||||||
queue_shuffle_order_range(struct queue *queue, unsigned start, unsigned end)
|
|
||||||
{
|
{
|
||||||
assert(queue != NULL);
|
assert(random);
|
||||||
assert(queue->random);
|
|
||||||
assert(start <= end);
|
assert(start <= end);
|
||||||
assert(end <= queue->length);
|
assert(end <= length);
|
||||||
|
|
||||||
for (unsigned i = start; i < end; ++i)
|
for (unsigned i = start; i < end; ++i)
|
||||||
queue->SwapOrders(i, g_rand_int_range(queue->rand, i, end));
|
SwapOrders(i, g_rand_int_range(rand, i, end));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -412,14 +407,14 @@ queue::ShuffleOrderRangeWithPriority(unsigned start, unsigned end)
|
|||||||
if (priority != group_priority) {
|
if (priority != group_priority) {
|
||||||
/* start of a new group - shuffle the one that
|
/* start of a new group - shuffle the one that
|
||||||
has just ended */
|
has just ended */
|
||||||
queue_shuffle_order_range(this, group_start, i);
|
ShuffleOrderRange(group_start, i);
|
||||||
group_start = i;
|
group_start = i;
|
||||||
group_priority = priority;
|
group_priority = priority;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* shuffle the last group */
|
/* shuffle the last group */
|
||||||
queue_shuffle_order_range(this, group_start, end);
|
ShuffleOrderRange(group_start, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -298,6 +298,12 @@ struct queue {
|
|||||||
order[i] = i;
|
order[i] = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shuffle the order of items in the specified range, ignoring
|
||||||
|
* their priorities.
|
||||||
|
*/
|
||||||
|
void ShuffleOrderRange(unsigned start, unsigned end);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shuffle the order of items in the specified range, taking their
|
* Shuffle the order of items in the specified range, taking their
|
||||||
* priorities into account.
|
* priorities into account.
|
||||||
|
Loading…
Reference in New Issue
Block a user