Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
2b8ce83c
Commit
2b8ce83c
authored
Jan 07, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Queue: move queue_shuffle_order_range() into the class
parent
52638c68
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
12 deletions
+13
-12
Queue.cxx
src/Queue.cxx
+7
-12
Queue.hxx
src/Queue.hxx
+6
-0
No files found.
src/Queue.cxx
View file @
2b8ce83c
...
...
@@ -368,20 +368,15 @@ queue_sort_order_by_priority(struct queue *queue, unsigned start, unsigned end)
queue
);
}
/**
* Shuffle the order of items in the specified range, ignoring their
* priorities.
*/
static
void
queue_shuffle_order_range
(
struct
queue
*
queue
,
unsigned
start
,
unsigned
end
)
void
queue
::
ShuffleOrderRange
(
unsigned
start
,
unsigned
end
)
{
assert
(
queue
!=
NULL
);
assert
(
queue
->
random
);
assert
(
random
);
assert
(
start
<=
end
);
assert
(
end
<=
queue
->
length
);
assert
(
end
<=
length
);
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
)
{
/* start of a new group - shuffle the one that
has just ended */
queue_shuffle_order_range
(
this
,
group_start
,
i
);
ShuffleOrderRange
(
group_start
,
i
);
group_start
=
i
;
group_priority
=
priority
;
}
}
/* shuffle the last group */
queue_shuffle_order_range
(
this
,
group_start
,
end
);
ShuffleOrderRange
(
group_start
,
end
);
}
void
...
...
src/Queue.hxx
View file @
2b8ce83c
...
...
@@ -299,6 +299,12 @@ struct queue {
}
/**
* 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
* priorities into account.
*/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment