aboutsummaryrefslogtreecommitdiffstats
path: root/src/Queue.hxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-01-08 15:31:39 +0100
committerMax Kellermann <max@duempel.org>2013-01-08 15:38:10 +0100
commitd81a9029dbf49f880f0a8d2a89b37d0d53d7cc6f (patch)
tree0cbbd007b3ead70cef341de4ca5cf721caf942e5 /src/Queue.hxx
parent620ae7790b43db80dddfca1312cd8441dc45dfa1 (diff)
downloadmpd-d81a9029dbf49f880f0a8d2a89b37d0d53d7cc6f.tar.gz
mpd-d81a9029dbf49f880f0a8d2a89b37d0d53d7cc6f.tar.xz
mpd-d81a9029dbf49f880f0a8d2a89b37d0d53d7cc6f.zip
Queue: move GenerateId() and others into the class
Diffstat (limited to 'src/Queue.hxx')
-rw-r--r--src/Queue.hxx38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/Queue.hxx b/src/Queue.hxx
index 3865aa86e..dcf431bc5 100644
--- a/src/Queue.hxx
+++ b/src/Queue.hxx
@@ -192,6 +192,16 @@ struct queue {
return items[position].priority;
}
+ const queue_item &GetOrderItem(unsigned i) const {
+ assert(IsValidOrder(i));
+
+ return items[OrderToPosition(i)];
+ }
+
+ uint8_t GetOrderPriority(unsigned i) const {
+ return GetOrderItem(i).priority;
+ }
+
/**
* Returns the song at the specified position.
*/
@@ -334,6 +344,34 @@ struct queue {
bool SetPriorityRange(unsigned start_position, unsigned end_position,
uint8_t priority, int after_order);
+
+private:
+ unsigned GenerateId() const;
+
+ /**
+ * Moves a song to a new position in the "order" list.
+ */
+ void MoveOrder(unsigned from_order, unsigned to_order);
+
+ void MoveItemTo(unsigned from, unsigned to) {
+ unsigned from_id = items[from].id;
+
+ items[to] = items[from];
+ items[to].version = version;
+ id_to_position[from_id] = to;
+ }
+
+ /**
+ * Find the first item that has this specified priority or
+ * higher.
+ */
+ gcc_pure
+ unsigned FindPriorityOrder(unsigned start_order, uint8_t priority,
+ unsigned exclude_order) const;
+
+ gcc_pure
+ unsigned CountSamePriority(unsigned start_order,
+ uint8_t priority) const;
};
#endif