A apresentação está carregando. Por favor, espere

A apresentação está carregando. Por favor, espere

A.4. Trabalhando com elementos de biblioteca STL – Standard Template Libraby Disponibiliza um conjunto de classes templates, provendo algoritmos eficientes.

Apresentações semelhantes


Apresentação em tema: "A.4. Trabalhando com elementos de biblioteca STL – Standard Template Libraby Disponibiliza um conjunto de classes templates, provendo algoritmos eficientes."— Transcrição da apresentação:

1 A.4. Trabalhando com elementos de biblioteca STL – Standard Template Libraby Disponibiliza um conjunto de classes templates, provendo algoritmos eficientes e com uso facilitado

2 Composição da STL Divide-se em 6 categorias de elementos: Containers Iterators Algorithms Function Objects Utilities Allocators

3 Containers Consiste em um conjunto de estruturas de dados pré-definidas vector, list, deque, set, multiset, map, multimap, hash_set, hash_multiset, hash_map, and hash_multimap. vectorlistdequesetmultisetmap multimaphash_sethash_multiset hash_maphash_multimap

4 Iterators Espécie de ponteiros utilizados para manipular os elementos armazenados nos containers.

5 Algorithms Algoritmos pré-definidos para manipular as estruturas de dados

6 Function Objects

7 Utilities

8 Allocators

9 Classe Vector Utilizado para representar um array de elementos Oferece um conjunto de métodos para manipulação do array push_back: Add element to end of collection. push_front: Add an element to start of a collection. back: Get a reference to element at end of collection front: Get a reference to element at end of collection pop_back: Removeelement at end of collection pop_front: Remove element at end of collection

10 Métodos da Classe Vector push_back: adiciona um elemento no final do array. push_front: adiciona um elemento no início do array. backGet: retorna uma referência para o último elemento do array frontGet: retorna uma referência para o primeiro elemento do array pop_backRemove: remove um elemento do final do array. pop_frontRemove: remove um elemento do inicio do array.

11 STL Collections General Class Methods empty: Determines if the collection is empty size: Determines the number of elements in the collection begin: Returns a forward iterator pointing to the start of the collection. It is commonly used to iterate through a collection. end: Returns a forward iterator pointing to one past the end of the collection. It is commonly used to test if an iterator is valid or in looping over a collection. rbegin: Returns a backward iterator pointing to the end of the collection It is commonly used to iterate backward through a collection.

12 Operator [] Permite o acesso a uma posição específica de um elemento da coleção

13 STL Collections General Class Methods rend: Returns a backward iterator pointing to one before the start of the collection. It is commonly used to test if an iterator is valid or in looping over a collection. clear: Erases all elements in a collection. If your collection contains pointers the elements must be deleted manually. erase : Erase an element or range of elements from a collection. To erase simply call erase with an iterator pointing to the element or a pair of iterator show the range of elements to erase. Also, vector supports erasing based on array index.

14 Referências Schildt, H. STL Programming from the GROUND UP. Osborne, 1999. STL Programmer's Guide: http://www.sgi.com/tech/stl/ STL avançado: http://www.codeproject.com/cpp/#STL


Carregar ppt "A.4. Trabalhando com elementos de biblioteca STL – Standard Template Libraby Disponibiliza um conjunto de classes templates, provendo algoritmos eficientes."

Apresentações semelhantes


Anúncios Google