50 likes | 169 Views
{ vector<T>, deque<T>, list<T>, set<K>, map<K,T> hash_set<K>, …}.
E N D
{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, …
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
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
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
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