I have a dictionary of arrays that contain one kind of objects : database records. Each array is like a table associated to a key (table name) in the dictionary.
My issue is: How do I update a table (delete a record, add a record, etc) without making any temporary copy of the table, like I would do with an NSDictionary of NSArrays ?
Currently, I do :
func addRecord(theRecord: DatabaseRecord, inTable tableName: String)
{
if var table = self.database[tableName]
{
table.append(theRecord)
self.database[tableName] = table
}
else
{
self.database[tableName] = [theRecord];
}
}
The issue is: a temporary copy of the table is made twice. This is pretty inefficient.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire