Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSCI-383 Object-Oriented Programming & Design Lecture 30.

Similar presentations


Presentation on theme: "CSCI-383 Object-Oriented Programming & Design Lecture 30."— Presentation transcript:

1 CSCI-383 Object-Oriented Programming & Design Lecture 30

2 Adaptor Containers  They are not first-class containers Do not provide the actual data structure implementation in which elements can be stored Provide restricted subset of container functionality, do not support iterators  A benefit of an adaptor class is that you can choose an appropriate underlying data structure (e.g., by default, a stack is implemented with a deque, but this can be changed by second argument in constructor, e.g., vector instead of deque )

3 Adaptor Containers  The STL provides three adaptor containers stack queue priority_queue  All three adaptor classes provide member functions push and pop that properly insert an element into each adaptor  Handout #26 Handout #26  Handout #27 Handout #27  Handout #28 Handout #28

4 bitset  A special container designed to store bits (i.e., elements with only two possible values: 0 or 1, true or false,...)  Very useful for representing a set of bit flags  Very similar to a regular array, but optimizing for space allocation Each element occupies only one bit, which is eight times less than the smallest elemental type in C++ (i.e., char )  bitset s are fixed in size at compile time (i.e., unlike vector which allows for dynamic resizing)

5 Sieve of Eratosthenes  A simple and ancient algorithm for finding all prime numbers up to a specified integer Created by Eratosthenes, an ancient Greek mathematician  ALGORITHM (Done in class)

6 Sieve of Eratosthenes with bitset  Handout #29 Handout #29


Download ppt "CSCI-383 Object-Oriented Programming & Design Lecture 30."

Similar presentations


Ads by Google