Presentation is loading. Please wait.

Presentation is loading. Please wait.

What is generic programming? The essence of the generic programming approach is concept development: systematic classification of computing components.

Similar presentations


Presentation on theme: "What is generic programming? The essence of the generic programming approach is concept development: systematic classification of computing components."— Presentation transcript:

1 What is generic programming? The essence of the generic programming approach is concept development: systematic classification of computing components according to their formal requirements But what is a concept? Generic Programming: Programming with Concepts

2 Concept= set of abstractions (e.g., types) Generic Programming= Programming with Concepts defined by a set of requirements {vector, deque, list, set, map hash_set, …} = 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))). generic algorithmsalgorithms that work correctly for every abstraction in a concept = e.g., generic container algorithms: copy, for_each, equal, transform, accumulate, … and efficiently Container Concept e.g., Container Concept in Standard Template Library (STL)

3 Container Forward Container Sequence Front Insertion Sequence Back Insertion Sequence Reversible Container Random Access Container Associative Container List Vector Deque Front & Back Insertion Sequence Sorted A. C. Unique A. C. Multiple A. C. Hashed A. C. Unique Sorted A. C. Multiple Sorted A. C. Unique Hashed A. C. Multiple Hashed A. C. Simple A. C. Paired A. C. SetMultisetH. Set H. Multiset H. Multi- map H. Map Multimap Slist STL Container Concepts See also http://www.sgi.com/tech/stl

4 Container Forward Container Sequence Front Insertion Sequence Back Insertion Sequence Reversible Container Random Access Container List Vector Deque Front & Back Insertion Sequence Slist STL Generic Algorithms on Forward Containers Requires input iterators Enables generic algorithms copy, for_each, equal, transform, … Requires forward iterators Enables find, merge, fill, replace, generate, remove, unique, rotate, … … Requires bidirectional iterators Enables reverse, partition, inplace_merge, … Requires random access iterators Enables sort, binary_search, random_shuffle, …

5 Container Forward Container Associative Container STL Concepts Input Iterator Output Iterator Forward Iterator Bidirectional Iterator Random Access Iterator AlgorithmFunctorAdaptor Input Algorithm Output Algorithm Forward Algorithm Bidirectional Algorithm Random Access Algorithm Unary Functor Binary Functor Binary Predicate Order Relation Iterator Adaptor

6 MTL Concepts STL Concepts ContainerIteratorAlgorithmFunctorAdaptor 2-D Iterator Matrix Sparse Matrix Dense Matrix Banded Matrix … Iterator Adaptor SparseDenseScaled … New Concepts in the Matrix Template Library http://www.lsc.nd.edu/research/mtl Matrix Algorithm Matrix Vector Algorithm Matrix Algorithm

7 BGL Concepts STL Concepts ContainerIteratorAlgorithmFunctorAdaptor Graph Iterator Graph Incidence Graph Adj. Graph EdgeList Graph … New Concepts in the Boost Graph Library http://www.boost.org/libs/graph/doc Graph Algorithms Visitor BFS Visitor DFS Visitor Uniform Cost Visitor …

8 Best to work upwards from experience with real problems Best to start with algorithms: what do they need for generality, correctness, and efficiency (as in STL, MTL, BGL, …) and, in advanced research, - reliability, - mobility, - real-time How Should We Attempt to Design and Implement Generic Computing Concepts?

9 Need advances in way we specify and organize performance properties, in addition to functionality Performance properties of components should be an integral part of concept requirements Raw material for performance descriptions: analytically derived bounds empirically observed performance data The Role of Performance


Download ppt "What is generic programming? The essence of the generic programming approach is concept development: systematic classification of computing components."

Similar presentations


Ads by Google