Standard Template Library - STL C++

<vector>

Overview

Description

The <vector> include file defines the vector class, which is a resizable array. Unlike built-in arrays, vectors grow or shrink to approximately the size of the number of elements in the vector. The file also holds a specialiation of the vector class for bool-type variables, which stores entries as single bits for efficiency. Additionally, the file defines six relational operators that are friend functions of the vector class.

Classes


class vector<X, A>



Description

The vector class is a template class that can be instantiated to create a resizable array. Each vector instance actually contains an array of entries of the template parameter type X. The size of the array depends on the number of entries and the allocator that is used as the parameter A. Generally, the default allocator is used, allocator<X>, but it is important to understand that the array is reallocated as entries are added or removed from the vector. This means that a pointer to an entry in the vector can become unknowingly invalid, while the index does not.

Members
Constructors

vector()

Typedefs

allocator_type

const_iterator

const_pointer

const_reference

const_reverse_iterator

difference_type

iterator

pointer

reference

reverse_iterator

size_type

value_type

Functions

assign()

at()

back()

begin()

capacity()

cbegin()

cend()

clear()

crbegin()

crend()

data()

emplace()

emplace_back()

empty()

end()

erase()

front()

get_allocator()

insert()

max_size()

operator[]()

operator=()

pop_back()

push_back()

rbegin()

rend()

reserve()

resize()

shrink_to_fit()

size()

swap()

Friends

operator==()

operator!=()

operator<()

operator>=()

operator>()

operator<=()

swap()

Specializations

class vector<bool, A>


Description

This is a specialization of the vector class to the bool type. When we declare a vector of bool-type variables, thie class is used to store that bools and single bits, rather than bool variables that can be up to 32 bits long. This class contains an additional nested reference class for accessing single bits and a flip function to perform the equivalent of a logical not operator on all of the bits.

Members
Constructors

vector()

Functions

flip()

swap()



 

© 2007–2024 XoaX.net LLC. All rights reserved.