libsaria: Change the path_list to a vector
For easier lookups. Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
This commit is contained in:
parent
8f7a610d6d
commit
592a924881
|
@ -11,12 +11,12 @@
|
||||||
#include <fs.h>
|
#include <fs.h>
|
||||||
#include "library.h"
|
#include "library.h"
|
||||||
|
|
||||||
#include <list>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
static unsigned int next_id = 0;
|
static unsigned int next_id = 0;
|
||||||
static list<struct libsaria::library::Path> path_list;
|
static vector<struct libsaria::library::Path> path_list;
|
||||||
libsaria::Playlist lib_playlist(PL_STATIC | PL_NO_DRAIN | PL_SORTED);
|
libsaria::Playlist lib_playlist(PL_STATIC | PL_NO_DRAIN | PL_SORTED);
|
||||||
|
|
||||||
libsaria::library::Path *push_path(libsaria::library::Path &path)
|
libsaria::library::Path *push_path(libsaria::library::Path &path)
|
||||||
|
@ -69,11 +69,10 @@ static bool check_trackid(libsaria::Track &track, void *data)
|
||||||
|
|
||||||
void pop_path(libsaria::library::Path *path)
|
void pop_path(libsaria::library::Path *path)
|
||||||
{
|
{
|
||||||
list<libsaria::library::Path>::iterator it;
|
for (unsigned int i = 0; i < path_list.size(); i++) {
|
||||||
for (it = path_list.begin(); it != path_list.end(); it++) {
|
if (&path_list[i] == path) {
|
||||||
if ((*it).id == path->id) {
|
|
||||||
libsaria::notify(PATH_DELETED, path);
|
libsaria::notify(PATH_DELETED, path);
|
||||||
path_list.erase(it);
|
path_list.erase(path_list.begin() + i);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -122,9 +121,8 @@ namespace libsaria
|
||||||
|
|
||||||
void library::update_all()
|
void library::update_all()
|
||||||
{
|
{
|
||||||
list<Path>::iterator it;
|
for (unsigned int i = 0; i < path_list.size(); i++)
|
||||||
for (it = path_list.begin(); it != path_list.end(); it++)
|
do_update_path(&path_list[i]);
|
||||||
do_update_path(&(*it));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void library::hide_path(Path *path)
|
void library::hide_path(Path *path)
|
||||||
|
@ -150,17 +148,12 @@ namespace libsaria
|
||||||
|
|
||||||
Track *library::lookup(unsigned int libid, unsigned int trackid)
|
Track *library::lookup(unsigned int libid, unsigned int trackid)
|
||||||
{
|
{
|
||||||
list<Path>::iterator p_it;
|
|
||||||
ListItem<Track> *track;
|
ListItem<Track> *track;
|
||||||
|
|
||||||
for (p_it = path_list.begin(); p_it != path_list.end(); p_it++) {
|
if (libid >= path_list.size())
|
||||||
if (p_it->id == libid)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (p_it == path_list.end())
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
track = p_it->tracks.find_item(check_trackid, &trackid);
|
track = path_list[libid].tracks.find_item(check_trackid, &trackid);
|
||||||
if (track == NULL)
|
if (track == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
return &track->get_value();
|
return &track->get_value();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user