1 / 15

COP 3530 Data Structures & Algorithms

COP 3530 Data Structures & Algorithms. Discussion Session 6 by Eyup. Outline. Linear lists - Array representation linearList arrayList iterator STL in C++ An example of bidirectional iterator Usage in STL algorithms Operator overloading. The abstract class linearList.

pierce
Download Presentation

COP 3530 Data Structures & Algorithms

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. COP 3530Data Structures & Algorithms Discussion Session 6 by Eyup

  2. Outline • Linear lists - Array representation • linearList • arrayList • iterator STL in C++ • An example of bidirectional iterator • Usage in STL algorithms • Operator overloading

  3. The abstract class linearList

  4. Array representation • List = {5, 2, 4, 8, 1} • Insertion and removal

  5. The class arrayList

  6. Iterators in C++ • Points to an element of an object • Defined in STL • Five categories. All support ==, !=, *, ++ • Input : Read access • Output: Write access • Forward: Read and write • Bidirectional: -- • Random access: +=, -=, +, -, <, >, <=, >=, []

  7. A bidirectional iterator for arrayList

  8. A bidirectional iterator for arrayList(cont.)

  9. A bidirectional iterator for arrayList(cont.)

  10. Using iterators • To be added into arrayList • Initialization • STL algorithms

  11. STL algorithms • Reverse • Sort

  12. Operator overloading • Arithmetic operators • Relational operators • I/O operators • Constructors and conversions

  13. Example

  14. References • http://www.cplusplus.com/reference/std/iterator/ • http://www.cplusplus.com/reference/algorithm/ • http://www.cplusplus.com/reference/stl/ • Data structures, algorithms, and applications in C++, SartajSahni. 2nd ed. • http://www.cs.duke.edu/csed/tapestry/howtoe.pdf • http://www.cplusplus.com/doc/tutorial/classes2/

  15. Questions

More Related