database: Mark rows valid when inserted
It doesn't make sense to need to set this value outside of the database code like I had been doing. So when a new row is inserted mark it as valid right away. Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
This commit is contained in:
parent
6d94e78d23
commit
8ccbad20cc
|
@ -100,9 +100,9 @@ Database: (lib/database.cpp)
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
unsigned int Database :: insert(T &);
|
unsigned int Database :: insert(T &);
|
||||||
Adds a new item to the db, returns the id of the item.
|
Adds a new item to the db, marks it as valid, and returns the
|
||||||
if DB_UNIQUE is set, check if the item already exists in the
|
id of the item. if DB_UNIQUE is set, check if the item already
|
||||||
DB and return it's ID instead of adding a new item.
|
exists in the DB and return it's ID instead of adding a new item.
|
||||||
|
|
||||||
void Database :: delete(unsigned int index);
|
void Database :: delete(unsigned int index);
|
||||||
Mark db[index] as invalid (quick deletion).
|
Mark db[index] as invalid (quick deletion).
|
||||||
|
|
|
@ -88,6 +88,7 @@ unsigned int Database<T> :: insert(T val)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
db.push_back(val);
|
db.push_back(val);
|
||||||
|
db[_size].valid = true;
|
||||||
_size++;
|
_size++;
|
||||||
return db.size() - 1;
|
return db.size() - 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,6 @@ DBTest :: DBTest()
|
||||||
DBTest :: DBTest(unsigned int val)
|
DBTest :: DBTest(unsigned int val)
|
||||||
{
|
{
|
||||||
value = val;
|
value = val;
|
||||||
valid = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DBTest :: write(File &file)
|
void DBTest :: write(File &file)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user