core/queue: Move queue_remove() out of the queue struct
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
d5e34b76d4
commit
ea00b406e5
|
@ -38,7 +38,7 @@ void TempQueue :: del(struct track *track)
|
|||
|
||||
void TempQueue :: del(unsigned int id)
|
||||
{
|
||||
queue :: del(id);
|
||||
queue_remove(this, id);
|
||||
deck :: write();
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ public:
|
|||
void clear()
|
||||
{
|
||||
while (queue_size(this) > 0)
|
||||
del((unsigned)0);
|
||||
queue_remove(this, (unsigned)0);
|
||||
}
|
||||
|
||||
void fill(index_entry *ent)
|
||||
|
|
|
@ -131,21 +131,21 @@ unsigned int queue_add(struct queue *queue, struct track *track)
|
|||
return pos;
|
||||
}
|
||||
|
||||
void queue :: del(unsigned int index)
|
||||
void queue_remove(struct queue *queue, unsigned int index)
|
||||
{
|
||||
q_length -= q_tracks[index]->tr_length;
|
||||
q_tracks.erase(q_tracks.begin() + index);
|
||||
q_notify->on_track_removed(index);
|
||||
queue->q_length -= queue->q_tracks[index]->tr_length;
|
||||
queue->q_tracks.erase(queue->q_tracks.begin() + index);
|
||||
queue->q_notify->on_track_removed(index);
|
||||
|
||||
if (q_cur == index)
|
||||
q_cur--;
|
||||
if (queue->q_cur == index)
|
||||
queue->q_cur--;
|
||||
}
|
||||
|
||||
void queue :: del(struct track *track)
|
||||
{
|
||||
for (unsigned int i = 0; i < q_tracks.size(); i++) {
|
||||
while ((i < q_tracks.size()) && (q_tracks[i] == track))
|
||||
del(i);
|
||||
queue_remove(this, i);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -161,7 +161,7 @@ void queue_selected(struct queue *queue, unsigned int index)
|
|||
{
|
||||
queue->q_cur = index;
|
||||
if (queue_has_flag(queue, Q_REPEAT) == false)
|
||||
queue->del(index);
|
||||
queue_remove(queue, index);
|
||||
}
|
||||
|
||||
struct track *queue_next(struct queue *queue)
|
||||
|
|
|
@ -141,7 +141,7 @@ bool QueueTab :: on_key_press_event(const std::string &key)
|
|||
}
|
||||
|
||||
for (unsigned int i = ids.size(); i > 0; i--)
|
||||
tab_pq->del(ids[i-1]);
|
||||
queue_remove(tab_pq, ids[i-1]);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -110,13 +110,6 @@ struct queue {
|
|||
void read(file &);
|
||||
|
||||
|
||||
/**
|
||||
* Remove a track based on its queue index.
|
||||
*
|
||||
* @param index Track index to remove from the queue.
|
||||
*/
|
||||
virtual void del(unsigned int);
|
||||
|
||||
/**
|
||||
* Remove all instances of a track from the queue.
|
||||
*
|
||||
|
@ -158,6 +151,9 @@ static inline struct track *queue_at(struct queue *queue, unsigned int index)
|
|||
/* Called to add a track to the queue. */
|
||||
unsigned int queue_add(struct queue *, struct track *);
|
||||
|
||||
/* Called to remove a track from the queue by index. */
|
||||
void queue_remove(struct queue *, unsigned int);
|
||||
|
||||
/* Called to tell the queue that a track has been updated. */
|
||||
void queue_updated(struct queue *, struct track *);
|
||||
|
||||
|
|
|
@ -176,13 +176,13 @@ static void test_stress(unsigned int N)
|
|||
test_equal(q.q_length, ex_length);
|
||||
test_equal(queue_size(&q), ex_size);
|
||||
|
||||
/* Queue :: del(unsigned int) */
|
||||
/* queue_remove() */
|
||||
track = track_get(1);
|
||||
ex_length -= track->tr_length * (N / 13);
|
||||
ex_size -= (N / 13);
|
||||
for (i = 0; i < ex_size; i += 11) {
|
||||
test_loop_equal(queue_at(&q, i), track, i);
|
||||
q.del(i);
|
||||
queue_remove(&q, i);
|
||||
} test_loop_passed();
|
||||
test_equal(q.q_length, ex_length);
|
||||
test_equal(queue_size(&q), ex_size);
|
||||
|
|
Loading…
Reference in New Issue