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
f2fac77d
Commit
f2fac77d
authored
Oct 18, 2017
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
queue/Queue: add methods MoveOrderBefore() and MoveOrderAfter()
parent
81b73736
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
0 deletions
+36
-0
Queue.cxx
src/queue/Queue.cxx
+18
-0
Queue.hxx
src/queue/Queue.hxx
+18
-0
No files found.
src/queue/Queue.cxx
View file @
f2fac77d
...
...
@@ -215,6 +215,24 @@ Queue::MoveOrder(unsigned from_order, unsigned to_order) noexcept
return
to_order
;
}
unsigned
Queue
::
MoveOrderBefore
(
unsigned
from_order
,
unsigned
to_order
)
noexcept
{
/* if "from_order" comes before "to_order", then the new
position is "to_order-1"; otherwise the "to_order" song is
moved one ahead */
return
MoveOrder
(
from_order
,
to_order
-
(
from_order
<
to_order
));
}
unsigned
Queue
::
MoveOrderAfter
(
unsigned
from_order
,
unsigned
to_order
)
noexcept
{
/* if "from_order" comes after "to_order", then the new
position is "to_order+1"; otherwise the "to_order" song is
moved one back */
return
MoveOrder
(
from_order
,
to_order
+
(
from_order
>
to_order
));
}
void
Queue
::
DeletePosition
(
unsigned
position
)
noexcept
{
...
...
src/queue/Queue.hxx
View file @
f2fac77d
...
...
@@ -290,6 +290,24 @@ struct Queue {
unsigned
MoveOrder
(
unsigned
from_order
,
unsigned
to_order
)
noexcept
;
/**
* Moves a song to a new position in the "order" list before
* the given one.
*
* @return the new order number of the given "from" song
*/
unsigned
MoveOrderBefore
(
unsigned
from_order
,
unsigned
to_order
)
noexcept
;
/**
* Moves a song to a new position in the "order" list after
* the given one.
*
* @return the new order number of the given "from" song
*/
unsigned
MoveOrderAfter
(
unsigned
from_order
,
unsigned
to_order
)
noexcept
;
/**
* Moves a song to a new position.
*/
void
MovePostion
(
unsigned
from
,
unsigned
to
)
noexcept
;
...
...
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