core/index: Remove Index class
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
025f13ffeb
commit
58f704cdd2
|
@ -11,7 +11,7 @@ extern "C" {
|
|||
|
||||
#include <algorithm>
|
||||
|
||||
static Index filter_index;
|
||||
static database<index_entry> filter_index;
|
||||
|
||||
void filter_init() { index_init(&filter_index, "", false); }
|
||||
void filter_deinit() { db_deinit(&filter_index); }
|
||||
|
|
|
@ -54,12 +54,14 @@ void index_entry :: read(file &file)
|
|||
|
||||
|
||||
|
||||
void index_init(Index *index, const gchar *filepath, bool autosave)
|
||||
void index_init(database<index_entry> *index, const gchar *filepath,
|
||||
bool autosave)
|
||||
{
|
||||
db_init(index, filepath, autosave);
|
||||
}
|
||||
|
||||
index_entry *index_insert(Index *index, const gchar *key, unsigned int value)
|
||||
index_entry *index_insert(database<index_entry> *index, const gchar *key,
|
||||
unsigned int value)
|
||||
{
|
||||
index_entry *it = db_find(index, key);
|
||||
|
||||
|
@ -68,7 +70,8 @@ index_entry *index_insert(Index *index, const gchar *key, unsigned int value)
|
|||
return it;
|
||||
}
|
||||
|
||||
void index_remove(Index *index, const gchar *key, unsigned int value)
|
||||
void index_remove(database<index_entry> *index, const gchar *key,
|
||||
unsigned int value)
|
||||
{
|
||||
index_entry *it = db_get(index, key);
|
||||
if (it) {
|
||||
|
@ -77,7 +80,7 @@ void index_remove(Index *index, const gchar *key, unsigned int value)
|
|||
}
|
||||
}
|
||||
|
||||
bool index_has(Index *index, const gchar *key, unsigned int value)
|
||||
bool index_has(database<index_entry> *index, const gchar *key, unsigned int value)
|
||||
{
|
||||
index_entry *it = db_get(index, key);
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ public:
|
|||
};
|
||||
|
||||
|
||||
static Index playlist_db;
|
||||
static database<index_entry> playlist_db;
|
||||
static PlaylistQueue playlist_q;
|
||||
static std::string cur_plist;
|
||||
|
||||
|
|
|
@ -74,22 +74,16 @@ struct index_entry : public DatabaseEntry {
|
|||
};
|
||||
|
||||
|
||||
/**
|
||||
* An Index is a special Database for mapping std::strings to a std::set of
|
||||
* integer identifiers.
|
||||
*/
|
||||
class Index : public database<index_entry> {};
|
||||
|
||||
/* Initialize an Index. */
|
||||
void index_init(Index *, const gchar *, bool);
|
||||
/* Initialize a database for use as an index. */
|
||||
void index_init(database<index_entry> *, const gchar *, bool);
|
||||
|
||||
/* Add a value to an index item with the specified key. */
|
||||
index_entry *index_insert(Index *, const gchar *, unsigned int);
|
||||
index_entry *index_insert(database<index_entry> *, const gchar *, unsigned int);
|
||||
|
||||
/* Remove a value from an index item with the specified key. */
|
||||
void index_remove(Index *, const gchar *, unsigned int);
|
||||
void index_remove(database<index_entry> *, const gchar *, unsigned int);
|
||||
|
||||
/* Called to check if the index has the specified (key, value) pair. */
|
||||
bool index_has(Index *, const gchar *, unsigned int);
|
||||
bool index_has(database<index_entry> *, const gchar *, unsigned int);
|
||||
|
||||
#endif /* OCARINA_CORE_DATABASE_H */
|
||||
|
|
|
@ -44,10 +44,10 @@ static void test_entry()
|
|||
|
||||
static void test_stress(unsigned int N)
|
||||
{
|
||||
database<index_entry> index;
|
||||
index_entry *ie, *ie2;
|
||||
std::string key;
|
||||
unsigned int i;
|
||||
Index index;
|
||||
char c;
|
||||
|
||||
index_init(&index, "stress.idx", false);
|
||||
|
|
Loading…
Reference in New Issue