1 / 17

Standard Template Library

Standard Template Library. Batch 2 Pradeep Kumar Voorukonda (17039877) Vinay Gunreddy (17033050) Rangarao Ponugoti (17033049). Module : Object Orientated Methods. Introduction. The STL is a complex piece of software engineering that uses some of C++'s most sophisticated features

sbrase
Download Presentation

Standard Template Library

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. Standard Template Library Batch 2 Pradeep Kumar Voorukonda (17039877) Vinay Gunreddy (17033050) RangaraoPonugoti(17033049) Module : Object Orientated Methods

  2. Introduction • The STL is a complex piece of software engineering that uses some of C++'s most sophisticated features • STL provides an incredible amount of generic programming power • It provides general purpose, templatized classes and functions • The STL is mainly composed of generic container class templates and a set of many efficient template algorithms Standard Template Library

  3. Components of STL • Container Classes • Generic Algorithms • Iterators • Function Objects • Allocators • Adaptors Standard Template Library

  4. CONTAINERS Standard Template Library

  5. Introduction to Containers • Container is an object that holds another object • More powerful and flexible than arrays • It will grow or shrink dynamically and manage their own memory • keep track of how many objects they hold Standard Template Library

  6. Types of Containers Standard Template Library

  7. StandardSequenceContainers • Vectors, • Lists, • De-queue, and • Strings Syntax template <class T, class A= allocator<T> > Where • Tis the data type to use and • A is the storage allocator which defaults to the standard allocator for type T Standard Template Library

  8. Vectors • It is the type of sequence container that should be used by default • It can change size dynamically • It provides best random access performance • It permits insertions and deletions at the back Template Specification The template specification for vector is shown here: template <class T, class A=allocator<T>> class vector Here T is the type of the data stored, A is the storage allocator Standard Template Library

  9. Lists • The list container implements a doubly linked list • It supports a bidirectional, i.e. they may be accessed front to back or back to front • Unlike a vector, which supports random access, a list can be accessed sequentially only. • It provides insertions and deletions anywhere in the list Template Specification template <class T, class Allocator=allocator<T>> class list Here T is the type of the data stored in the list and Allocator provides default storage location Standard Template Library

  10. ITERATORS Standard Template Library

  11. Introduction • An iterator is an extension to the pointer • It implements the standard pointer operators • It gives you the ability to cycle through the contents of the container like a pointer to cycle through an array • Iterators used by the algorithms to move through the containers Syntax std::class_name<template_parameters>:: iterator name where name - name of the iterator, class_name - name of the STL container, template_parameters - parameters to the template, and finally, std- namespace having collection of STL classes Standard Template Library

  12. Basic Types of Iterators • Random Access Iterator • Bidirectional Iterator • Forward Iterator • Input Iterator • Output Iterator Standard Template Library

  13. ALGORITHMS Standard Template Library

  14. Introduction • Used generically across a variety of containers. • STL provides many algorithms to manipulate containers. • STL provides approximately 70 standard algorithms that operate on container elements only indirectly through iterators. • Many algorithms operate on sequence of elements defined by pairs of iterators • It is possible to create new algorithms that operate in a similar fashion so they can be used with the STL containers and iterators. Standard Template Library

  15. Basic Types of Algorithms • Mutating Sequence Algorithms likecopy(), remove(), replace(), fill(), swap(), etc., • Non Modifying sequence Algorithms like find(), count(),search(), mismatch(), and equal() • Numerical Algorithms accumulate(), partial_sum(), inner_product(), and adjacent_difference() Standard Template Library

  16. Thank You Standard Template Library

  17. Queries? Standard Template Library

More Related