Standard Template Library Programmer's Guide

Здесь есть возможность читать онлайн «Standard Template Library Programmer's Guide» весь текст электронной книги совершенно бесплатно (целиком полную версию без сокращений). В некоторых случаях можно слушать аудио, скачать через торрент в формате fb2 и присутствует краткое содержание. Жанр: Программирование, Справочники, на английском языке. Описание произведения, (предисловие) а так же отзывы посетителей доступны на портале библиотеки ЛибКат.

Standard Template Library Programmer's Guide: краткое содержание, описание и аннотация

Предлагаем к чтению аннотацию, описание, краткое содержание или предисловие (зависит от того, что написал сам автор книги «Standard Template Library Programmer's Guide»). Если вы не нашли необходимую информацию о книге — напишите в комментариях, мы постараемся отыскать её.

This document contains reference on SGI STL implementation

Standard Template Library Programmer's Guide — читать онлайн бесплатно полную книгу (весь текст) целиком

Ниже представлен текст книги, разбитый по страницам. Система сохранения места последней прочитанной страницы, позволяет с удобством читать онлайн бесплатно книгу «Standard Template Library Programmer's Guide», без необходимости каждый раз заново искать на чём Вы остановились. Поставьте закладку, и сможете в любой момент перейти на страницу, на которой закончили чтение.

Тёмная тема
Сбросить

Интервал:

Закладка:

Сделать
Models

• hash_multiset

• hash_multimap

Notes

[1] At present (early 1998), not all compilers support "member templates". If your compiler supports member templates then i and j may be of any type that conforms to the Input Iterator requirements. If your compiler does not yet support member templates, however, then i and j must be of type const T* or of type X::const_iterator .

See also

Associative Container, Hashed Associative Container, Unique Hashed Associative Container, Sorted Associative Container

Container classes

Sequences

vector

Category: containers

Component type: type

Description

A vector is a Sequence that supports random access to elements, constant time insertion and removal of elements at the end, and linear time insertion and removal of elements at the beginning or in the middle. The number of elements in a vector may vary dynamically; memory management is automatic. Vector is the simplest of the STL container classes, and in many cases the most efficient.

Example

vector V;

V.insert(V.begin(), 3);

assert(V.size() == 1 && V.capacity() >= 1 && V[0] == 3);

Definition

Defined in the standard header vector, and in the nonstandard backward-compatibility header vector.h.

Template parameters
Parameter Description Default
T The vector's value type: the type of object that is stored in the vector.
Alloc The vector 's allocator, used for all internal memory management. alloc
Model of

Random Access Container, Back Insertion Sequence.

Type requirements

None, except for those imposed by the requirements of Random Access Container and Back Insertion Sequence.

Public base classes

None.

Members
Member Where defined Description
value_type Container The type of object, T , stored in the vector.
pointer Container Pointer to T .
reference Container Reference to T
const_reference Container Const reference to T
size_type Container An unsigned integral type.
difference_type Container A signed integral type.
iterator Container Iterator used to iterate through a vector .
const_iterator Container Const iterator used to iterate through a vector .
reverse_iterator Reversible Container Iterator used to iterate backwards through a vector .
const_reverse_iterator Reversible Container Const iterator used to iterate backwards through a vector .
iterator begin() Container Returns an iterator pointing to the beginning of the vector .
iterator end() Container Returns an iterator pointing to the end of the vector .
const_iterator begin() const Container Returns a const_iterator pointing to the beginning of the vector .
const_iterator end() const Container Returns a const_iterator pointing to the end of the vector .
reverse_iterator rbegin() Reversible Container Returns a reverse_iterator pointing to the beginning of the reversed vector.
reverse_iterator rend() Reversible Container Returns a reverse_iterator pointing to the end of the reversed vector.
const_reverse_iterator rbegin() const Reversible Container Returns a const_reverse_iterator pointing to the beginning of the reversed vector.
const_reverse_iterator rend() const Reversible Container Returns a const_reverse_iterator pointing to the end of the reversed vector.
size_type size() const Container Returns the size of the vector .
size_type max_size() const Container Returns the largest possible size of the vector .
size_type capacity() const vector See below.
bool empty() const Container true if the vector 's size is 0 .
reference operator[](size_type n) Random Access Container Returns the n 'th element.
const_reference operator[](size_type n) const Random Access Container Returns the n 'th element.
vector() Container Creates an empty vector.
vector(size_type n) Sequence Creates a vector with n elements.
vector(size_type n, const T& t) Sequence Creates a vector with n copies of t .
vector(const vector&) Container The copy constructor.
template vector(InputIterator, InputIterator)[1] Sequence Creates a vector with a copy of a range.
~vector() Container The destructor.
vector& operator=(const vector&) Container The assignment operator
void reserve(size_t) vector See below.
vector reference front() Sequence Returns the first element.
const_reference front() const Sequence Returns the first element.
reference back() Back Insertion Sequence Returns the last element.
const_reference back() const Back Insertion Sequence Returns the last element.
void push_back(const T&) Back Insertion Sequence Inserts a new element at the end.
void pop_back() Back Insertion Sequence Removes the last element.
void swap(vector&) Container Swaps the contents of two vectors.
iterator insert(iterator pos, const T& x) Sequence Inserts x before pos .
template void insert(iterator pos, InputIterator f, InputIterator l)[1] Sequence Inserts the range [first, last) before pos .
void insert(iterator pos, size_type n, const T& x) Sequence Inserts n copies of x before pos .
iterator erase(iterator pos) Sequence Erases the element at position pos .
iterator erase(iterator first, iterator last) Sequence Erases the range [first, last)
void clear() Sequence Erases all of the elements.
void resize(n, t = T()) Sequence Inserts or erases elements at the end such that the size becomes n .
bool operator==(const vector&, const vector&) Forward Container Tests two vectors for equality. This is a global function, not a member function.
bool operator<(const vector&, const vector&) Forward Container Lexicographical comparison. This is a global function, not a member function.
New members

These members are not defined in the Random Access Container and Back Insertion Sequence requirements, but are specific to vector .

Читать дальше
Тёмная тема
Сбросить

Интервал:

Закладка:

Сделать

Похожие книги на «Standard Template Library Programmer's Guide»

Представляем Вашему вниманию похожие книги на «Standard Template Library Programmer's Guide» списком для выбора. Мы отобрали схожую по названию и смыслу литературу в надежде предоставить читателям больше вариантов отыскать новые, интересные, ещё непрочитанные произведения.


Отзывы о книге «Standard Template Library Programmer's Guide»

Обсуждение, отзывы о книге «Standard Template Library Programmer's Guide» и просто собственные мнения читателей. Оставьте ваши комментарии, напишите, что Вы думаете о произведении, его смысле или главных героях. Укажите что конкретно понравилось, а что нет, и почему Вы так считаете.

x