Lecture overview -- Keyboard shortcut: 'u'  Previous page: Overview of Algorithms -- Keyboard shortcut: 'p'  Next page: The for-each algorithm -- Keyboard shortcut: 'n'  Lecture notes - all slides and notes together  slide -- Keyboard shortcut: 't'  Help page about these notes  Alphabetic index  Course home  Lecture 5 - Page 33 : 39
Notes about C++
Templates and The Standard Library
Principles used for algorithms

We list a number of principles (ideas and concepts) which are typically used for a number of standard algorithms

  • Generalization by function parameters

    • Insight from higher-order functions

    • Spawns some work on C++ function objects §18.4

      • Due to the lack of lambda expressions - until C++ 2011

  • A sequence is defined by two iterators

    • Beginning at the first element

    • Ended by the one-beyond-the-last element

  • Failure to find an element in a sequence

    • Return the (off by one) end of sequence iterator

  • Algorithms that use a pair of iterators as input

    • Bundle these in pairs: input sequences, §18.3.1

    • Provide factory methods that produce such a pair of sequences

      • iseq(Container c) returns such a pair from c.begin() to c.end()