1 / 5

Concept

{ vector<T>, deque<T>, list<T>, set<K>, map<K,T> hash_set<K>, …}.

halen
Download Presentation

Concept

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. {vector<T>, deque<T>, list<T>, set<K>, map<K,T> hash_set<K>,…} Definition: Container refines Basic-container;uses Input-iterator;introduces begin(containers) -> iterators, end(containers) -> iterators, size(containers) -> naturals, empty(containers) -> bool;requires (for c: containers) size(c) = size(range(c, begin(c), end(c))), empty(c) = (size(c) = 0), valid(range(c, begin(c), end(c))). e.g., = Container Concept Container Concept In Standard Template Library (STL) generic algorithms = algorithms that work correctly and efficientlyfor every abstraction in a concept Programming with Concepts (Generic Programming) Concept = a set of abstractions (e.g., types) defined by a set of requirements e.g., generic container algorithms: copy, for_each, transform, accumulate, …

  2. STL Container Concepts Container AssociativeContainer ForwardContainer Sequence ReversibleContainer SortedA. C. UniqueA. C. MultipleA. C. HashedA. C. Front InsertionSequence BackInsertionSequence UniqueSortedA. C. MultipleSortedA. C. UniqueHashedA. C. MultipleHashedA. C. Random AccessContainer SimpleA. C. PairedA. C. Front & BackInsertionSequence Set Multiset Map Multimap H. Set H. Multiset H. Map H. Multi-map Vector Slist List Deque See also http://www.sgi.com/tech/stl

  3. STL Generic Algorithms on Refinements of Container Concept Requires input iterators Enables generic algorithms copy, for_each, transform, accumulate,… Container Requiresforward iterators … ForwardContainer Enables find, merge, fill, replace, generate, remove, unique, rotate, … Requiresbidirectional iterators Enables reverse, partition, inplace_merge, … Sequence ReversibleContainer Front InsertionSequence BackInsertionSequence Requiresrandom access iterators Enables sort, binary_search, random_shuffle, … Random AccessContainer Front & BackInsertionSequence Vector Slist List Deque

  4. STL Concepts Container Iterator Algorithm Functor Adaptor ForwardContainer AssociativeContainer Input Iterator Output Iterator MutatingAlgorithm Non-mutatingAlgorithm Unary Functor BinaryFunctor Iterator Adaptor Forward Iterator BinaryPredicate Bidirectional Iterator OrderRelation Random Access Iterator

  5. New Concepts in the Boost Graph Library BGL Concepts Visitor Graph Adj.Graph EdgeListGraph Incidence Graph … BFS Visitor DFSVisitor Uniform CostVisitor … (J. Siek, L.-Q. Lee, A. Lumsdaine) STL Concepts Container Iterator Algorithm Functor Adaptor Graph Iterator VertexIterator Edge Iterator … See also http://www.boost.org/libs/graph/doc

More Related