From 302830c3b46d571d80b378fe91060a4a29e87d63 Mon Sep 17 00:00:00 2001 From: Carl N Baldwin Date: Mon, 17 Oct 2005 20:18:29 -0600 Subject: [PATCH] Set differences now down --- main.cc | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/main.cc b/main.cc index e07c7ee..c930155 100644 --- a/main.cc +++ b/main.cc @@ -28,6 +28,7 @@ vector split( const string &line, char c, int limit = -1 ) { return out; } +// Callback function for getting files from the database int populate_set( void *files_v, int, char **vals, char ** ) { file_set *files = reinterpret_cast( files_v ); files->insert( new FileData( vals[0][0], @@ -89,4 +90,26 @@ int main() { for( file_set::iterator i = previous_files.begin(); i != previous_files.end(); ++i ) { cout << (*i)->getFileName() << endl; } + + // Now divide the two sets into three sets (union and set differences) + FileDataPtrCmp cmp; + + file_set new_set; + set_difference( current_files.begin(), current_files.end(), + previous_files.begin(), previous_files.end(), + inserter( new_set, new_set.begin() ), + cmp ); + + file_set deleted_set; + set_difference( previous_files.begin(), previous_files.end(), + current_files.begin(), current_files.end(), + inserter( deleted_set, deleted_set.begin() ), + cmp ); + + // previous_files *should* definitely be the first set here + file_set common_set; + set_difference( previous_files.begin(), previous_files.end(), + current_files.begin(), current_files.end(), + inserter( common_set, common_set.begin() ), + cmp ); } -- 2.34.1