User Tools

Site Tools


cpp:stl:container_common_functions

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revisionBoth sides next revision
cpp:stl:container_common_functions [2022/06/01 04:23] gthanoscpp:stl:container_common_functions [2023/05/29 16:03] – [Β. Ένθεση σε set, unordered set] gthanos
Line 53: Line 53:
   Student students[] = { Student("Peter_Pan", 1234), Student("Tinker_Bell", 1235) };   Student students[] = { Student("Peter_Pan", 1234), Student("Tinker_Bell", 1235) };
                                                      
-  std::cerr << "----- Init list -----" << std::endl; +  std::cerr << "----- Init set -----" << std::endl; 
-  std::set<Student> mylist;+  std::set<Student> myset;
   for(int i=0; i<2; i++) {   for(int i=0; i<2; i++) {
-    mylist.insert(students[i]);  // copy-constructor, insert first +    myset.insert(students[i]);  // copy-constructor, insert first 
-    mylist.insert(students[i]);    // copy-constructor, insert last+    myset.insert(students[i]);    // copy-constructor, insert last
   }   }
      
-  mylist.emplace("Mickey_Mouse", 1237);  // argument construct, insert last+  myset.emplace("Mickey_Mouse", 1237);  // argument construct, insert last
      
   std::cerr << "-------------------------\n";   std::cerr << "-------------------------\n";
-  std::cerr << "mylist contains:"; +  std::cerr << "myset contains:"; 
-  for (std::set<Student>::iterator it = mylist.begin(); it!=mylist.end(); ++it)+  for (std::set<Student>::iterator it = myset.begin(); it!=myset.end(); ++it)
     std::cerr << ' ' << *it;     std::cerr << ' ' << *it;
   std::cerr << std::endl;   std::cerr << std::endl;
cpp/stl/container_common_functions.txt · Last modified: 2023/05/30 19:18 by gthanos