Set differences now down
authorCarl N Baldwin <cnb@plane.(none)>
Tue, 18 Oct 2005 02:18:29 +0000 (20:18 -0600)
committerCarl N Baldwin <cnb@plane.(none)>
Tue, 18 Oct 2005 02:18:29 +0000 (20:18 -0600)
main.cc

diff --git a/main.cc b/main.cc
index e07c7ee28c3c70fa0cb9fa1d151fda7c43a05a45..c930155cae77a6ec538d9f90511da1efd0ee3b1d 100644 (file)
--- a/main.cc
+++ b/main.cc
@@ -28,6 +28,7 @@ vector<string> 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<file_set*>( 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 );
 }