Download presentation
Presentation is loading. Please wait.
Published byAlfred Magnus Griffith Modified over 8 years ago
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
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.