1 / 7

What it means Slide 2 An example concept hierarchy: STL container concepts Slide 3

Programming with Concepts. What it means Slide 2 An example concept hierarchy: STL container concepts Slide 3 Concept refinement: stronger requirements enable more and better algorithms Slide 4 Extending STL concepts: the Matrix Template Library Slide 5

hvillarreal
Télécharger la présentation

What it means Slide 2 An example concept hierarchy: STL container concepts Slide 3

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. Programming with Concepts • What it means Slide 2 • An example concept hierarchy: STL container concepts Slide 3 • Concept refinement: stronger requirements enable more and better algorithms Slide 4 • Extending STL concepts: the Matrix Template Library Slide 5 • Extending STL concepts: the Boost Graph Library Slide 7

  2. {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) = algorithms that work correctly for every abstraction in a concept Back Generic Programming = Programming with Concepts Concept = set of abstractions (e.g., types) defined by a set of requirements generic algorithms and efficiently e.g., generic container algorithms: copy, for_each, equal, transform, accumulate, …

  3. 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. PairA. C. Front & BackInsertionSequence Set Multiset Map Multimap H. Set H. Multiset H. Map H. Multi-map Vector Slist Click on any node in the above concept hierarchy to see the corresponding requirements as specified in the SGI STL Programmer’s Guide List Deque See also http://www.sgi.com/tech/stl STL Container Concepts Container Back

  4. STL Generic Algorithms on Forward Containers Requires input iterators Enables generic algorithms copy, for_each, equal, transform, … Back 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

  5. Back STL Concepts Container Iterator Algorithm Functor Adaptor ForwardContainer AssociativeContainer Input Iterator Output Iterator Input Algorithm Output Algorithm Unary Functor BinaryFunctor Iterator Adaptor Forward Iterator Forward Algorithm BinaryPredicate Bidirectional Iterator Bidirectional Algorithm OrderRelation Random Access Iterator Random Access Algorithm

  6. New Concepts in the Matrix Template Library MTL Concepts Iterator Adaptor 2-D Iterator Matrix Algorithm Matrix Sparse Dense Scaled … DenseMatrix BandedMatrix Sparse Matrix … Matrix MatrixAlgorithm Matrix VectorAlgorithm Back STL Concepts Container Iterator Algorithm Functor Adaptor See also http://www.osl.iu.edu/research/mtl/

  7. New Concepts in the Boost Graph Library BGL Concepts Graph Iterator Graph Algorithms Visitor Graph Adj.Graph EdgeListGraph Incidence Graph … BFS Visitor DFSVisitor Uniform CostVisitor … Back STL Concepts Container Iterator Algorithm Functor Adaptor See also http://www.boost.org/libs/graph/doc

More Related