Skip to content

Latest commit

 

History

History
15 lines (14 loc) · 506 Bytes

File metadata and controls

15 lines (14 loc) · 506 Bytes

cpp_notes

  1. sorting
bool myfunction (int i,int j) { return (i<j); }

 // using default comparison (operator <):
  std::sort (myvector.begin(), myvector.end());           //(12 32 45 71)
  // using function as comp
  std::sort (myvector.begin(), myvector.end(), myfunction); // (26 33 53 80)
  1. Add element at the end
    Adds a new element at the end of the vector, after its current last element. The content of val is copied (or moved) to the new element.
myvector.push_back (i);