Lista completa de funções C++ STD e STL. (All C++ Standard Library and Standard Template Library’s functions)

Diferentemente da linguagem C (nativamente procedural), a linguagem C++ permite nativamente o paradigma de Programação Orientada a Objetos.

A linguagem C é orientada para trabalhar com variáveis e funções. Já a linguagem C++ também trabalha com modelos chamados Templates, que organizam dados e métodos. Métodos são exatamente essas funções usadas ”dentro” do objeto, que são chamadas a partir dos Templates usados. 

A lista a seguir apresenta as funções herdadas da linguagem C e em seguida os métodos para cada Template da linguagem C++.

Índice:
1ª Parte: Fundamentos de linguagem / 1st Part: Language Fundamentals
Pre-processor commands
Operator Precedence
Escape Sequences
ASCII Chart
Data Types
Keywords

2ª Parte: Herança da Linguagem C / 2nd Part: C Language Heritage
Standard C I/O
Standard C String and Character
Standard C Math
Standard C Time and Date
Standard C Memory
Other standard C functions

3ª Parte: Inovações da linguagem C++ / 3rd Part: C++ Inovations
C++ I/O
C++ Strings
C++ String Flags
C++ String Streams
Miscellaneous C++

4ª Parte: Biblioteca de Modelos Padrão / 4th Part: Standard Template Library
C++ Standard Template Library
C++ Algorithms
C++ Vectors
C++ Double-Ended Queues
C++ Lists
C++ Priority Queues
C++ Queues
C++ Stacks
C++ Sets
C++ Multisets
C++ Maps
C++ Multimaps
C++ Bitsets
Iterators


1ª Parte: Fundamentos de linguagem / 1st Part: Language Fundamentals

C/C++ Pre-processor Commands

#, ## manipulate strings
#define define variables
#error display an error message
#if, #ifdef, #ifndef, #else, #elif, #endif conditional operators
#include insert the contents of another file
#line set line and file information
#pragma implementation specific command
#undef used to undefine variables
Predefined preprocessor variables miscellaneous preprocessor variables

 

C++ Operator Precedence

The operators at the top of this list are evaluated first.

Precedence Operator Description Example Associativity
1 :: Scoping operator Class::age = 2; none
2 ()
[]
->
.
++
Grouping operator
Array access
Member access from a pointer
Member access from an object
Post-increment
Post-decrement
(a + b) / 4;
array[4] = 2;
ptr->age = 34;
obj.age = 34;
for( i = 0; i < 10; i++ ) …
for( i = 10; i > 0; i– ) …
left to right
3 !
~
++


+
*
&
(type)
sizeof
Logical negation
Bitwise complement
Pre-increment
Pre-decrement
Unary minus
Unary plus
Dereference
Address of
Cast to a given type
Return size in bytes
if( !done ) …
flags = ~flags;
for( i = 0; i < 10; ++i ) …
for( i = 10; i > 0; –i ) …
int i = -1;
int i = +1;
data = *ptr;
address = &obj;
int i = (int) floatNum;
int size = sizeof(floatNum);
right to left
4 ->*
.*
Member pointer selector
Member pointer selector
ptr->*var = 24;
obj.*var = 24;
left to right
5 *
/
%
Multiplication
Division
Modulus
int i = 2 * 4;
float f = 10 / 3;
int rem = 4 % 3;
left to right
6 +
Addition
Subtraction
int i = 2 + 3;
int i = 5 – 1;
left to right
7 <<
>>
Bitwise shift left
Bitwise shift right
int flags = 33 << 1;
int flags = 33 >> 1;
left to right
8 <
<=
>
>=
Comparison less-than
Comparison less-than-or-equal-to
Comparison greater-than
Comparison geater-than-or-equal-to
if( i < 42 ) …
if( i <= 42 ) …
if( i > 42 ) …
if( i >= 42 ) …
left to right
9 ==
!=
Comparison equal-to
Comparison not-equal-to
if( i == 42 ) …
if( i != 42 ) …
left to right
10 & Bitwise AND flags = flags & 42; left to right
11 ^ Bitwise exclusive OR flags = flags ^ 42; left to right
12 | Bitwise inclusive (normal) OR flags = flags | 42; left to right
13 && Logical AND if( conditionA && conditionB ) … left to right
14 || Logical OR if( conditionA || conditionB ) … left to right
15 ? : Ternary conditional (if-then-else) int i = (a > b) ? a : b; right to left
16 =
+=
-=
*=
/=
%=
&=
^=
|=
<<=
>>=
Assignment operator
Increment and assign
Decrement and assign
Multiply and assign
Divide and assign
Modulo and assign
Bitwise AND and assign
Bitwise exclusive OR and assign
Bitwise inclusive (normal) OR and assign
Bitwise shift left and assign
Bitwise shift right and assign
int a = b;
a += 3;
b -= 4;
a *= 5;
a /= 2;
a %= 3;
flags &= new_flags;
flags ^= new_flags;
flags |= new_flags;
flags <<= 2;
flags >>= 2;
right to left
17 , Sequential evaluation operator for( i = 0, j = 0; i < 10; i++, j++ ) … left to right

It is important to note that there is no specified precedence for the operation of changing a variable into a value. For example, consider the following code:

float x, result;  x = 1;  result = x / ++x;

The value of result is not guaranteed to be consistent across different compilers, because it is not clear whether the computer should change the variable x (the one that occurs on the left side of the division operator) before using it. Depending on which compiler you are using, the variable result can either be 1.0 or 0.5. The bottom line is that you should not use the same variable multiple times in a single expression when using operators with side effects.

 

Constant Escape Sequences

The following escape sequences can be used to print out special characters.

Escape Sequence Description
\’ Single quote
\” Double quote
\\ Backslash
\nnn Octal number (nnn)
\0 Null character (really just the octal number zero)
\a Audible bell
\b Backspace
\f Formfeed
\n Newline
\r Carriage return
\t Horizontal tab
\v Vertical tab
\xnnn Hexadecimal number (nnn)

 

ASCII Chart

The following chart contains ASCII decimal, octal, hexadecimal and character codes for values from 0 to 127.

Decimal Octal Hex Character Description Decimal Octal Hex Character Description
0 0 00 NUL 64 100 40 @
1 1 01 SOH start of header 65 101 41 A
2 2 02 STX start of text 66 102 42 B
3 3 03 ETX end of text 67 103 43 C
4 4 04 EOT end of transmission 68 104 44 D
5 5 05 ENQ enquiry 69 105 45 E
6 6 06 ACK acknowledge 70 106 46 F
7 7 07 BEL bell 71 107 47 G
8 10 08 BS backspace 72 110 48 H
9 11 09 HT horizontal tab 73 111 49 I
10 12 0A LF line feed 74 112 4A J
11 13 0B VT vertical tab 75 113 4B K
12 14 0C FF form feed 76 114 4C L
13 15 0D CR carriage return 77 115 4D M
14 16 0E SO shift out 78 116 4E N
15 17 0F SI shift in 79 117 4F O
16 20 10 DLE data link escape 80 120 50 P
17 21 11 DC1 no assignment, but usually XON 81 121 51 Q
18 22 12 DC2 82 122 52 R
19 23 13 DC3 no assignment, but usually XOFF 83 123 53 S
20 24 14 DC4 84 124 54 T
21 25 15 NAK negative acknowledge 85 125 55 U
22 26 16 SYN synchronous idle 86 126 56 V
23 27 17 ETB end of transmission block 87 127 57 W
24 30 18 CAN cancel 88 130 58 X
25 31 19 EM end of medium 89 131 59 Y
26 32 1A SUB substitute 90 132 5A Z
27 33 1B ESC escape 91 133 5B [
28 34 1C FS file seperator 92 134 5C \
29 35 1D GS group seperator 93 135 5D ]
30 36 1E RS record seperator 94 136 5E ^
31 37 1F US unit seperator 95 137 5F _
32 40 20 SPC space 96 140 60 `
33 41 21 ! 97 141 61 a
34 42 22 98 142 62 b
35 43 23 # 99 143 63 c
36 44 24 $ 100 144 64 d
37 45 25 % 101 145 65 e
38 46 26 & 102 146 66 f
39 47 27 103 147 67 g
40 50 28 ( 104 150 68 h
41 51 29 ) 105 151 69 i
42 52 2A * 106 152 6A j
43 53 2B + 107 153 6B k
44 54 2C , 108 154 6C l
45 55 2D 109 155 6D m
46 56 2E . 110 156 6E n
47 57 2F / 111 157 6F o
48 60 30 0 112 160 70 p
49 61 31 1 113 161 71 q
50 62 32 2 114 162 72 r
51 63 33 3 115 163 73 s
52 64 34 4 116 164 74 t
53 65 35 5 117 165 75 u
54 66 36 6 118 166 76 v
55 67 37 7 119 167 77 w
56 70 38 8 120 170 78 x
57 71 39 9 121 171 79 y
58 72 3A : 122 172 7A z
59 73 3B ; 123 173 7B {
60 74 3C < 124 174 7C |
61 75 3D = 125 175 7D }
62 76 3E > 126 176 7E ~
63 77 3F ? 127 177 7F DEL delete

 

C/C++ Data Types

There are five data types for C: voidintfloatdouble, and char.

Type Description
void associated with no data type
int integer
float floating-point number
double double precision floating-point number
char character

C++ defines two more: bool and wchar_t.

Type Description
bool Boolean value, true or false
wchar_t wide character

 

Type Modifiers

Several of these types can be modified using signedunsignedshort, and long. When one of these type modifiers is used by itself, a data type of int is assumed. A complete list of possible data types follows:

bool int long int
char unsigned int signed long int
unsigned char signed int unsigned long int
signed char short int float
wchar_t unsigned short int double
signed short int long double

The size and range of any data type is compiler and architecture dependent. The “cfloat” (or “float.h”) header file often defines minimum and maximum values for the various data types. You can use the sizeof operator to determine the size of any data type, in bytes. However, many architectures implement data types of a standard size. ints and floats are often 32-bit, chars 8-bit, and doubles are usually 64-bit. bools are often implemented as 8-bit data types.Type Sizes and Ranges

 

C/C++ Keywords

asm insert an assembly instruction
auto declare a local variable
bool declare a boolean variable
break break out of a loop
case a block of code in a switch statement
catch handles exceptions from throw
char declare a character variable
class declare a class
const declare immutable data or functions that do not change data
const_cast cast from const variables
continue bypass iterations of a loop
default default handler in a case statement
delete make memory available
do looping construct
double declare a double precision floating-point variable
dynamic_cast perform runtime casts
else alternate case for an if statement
enum create enumeration types
explicit only use constructors when they exactly match
export allows template definitions to be separated from their declarations
extern tell the compiler about variables defined elsewhere
false the boolean value of false
float declare a floating-point variable
for looping construct
friend grant non-member function access to private data
goto jump to a different part of the program
if execute code based off of the result of a test
inline optimize calls to short functions
int declare a integer variable
long declare a long integer variable
mutable override a const variable
namespace partition the global namespace by defining a scope
new allocate dynamic memory for a new variable
operator create overloaded operator functions
private declare private members of a class
protected declare protected members of a class
public declare public members of a class
register request that a variable be optimized for speed
reinterpret_cast change the type of a variable
return return from a function
short declare a short integer variable
signed modify variable type declarations
sizeof return the size of a variable or type
static create permanent storage for a variable
static_cast perform a nonpolymorphic cast
struct define a new structure
switch execute code based off of different possible values for a variable
template create generic functions
this a pointer to the current object
throw throws an exception
true the boolean value of true
try execute code that can throw an exception
typedef create a new type name from an existing type
typeid describes an object
typename declare a class or undefined type
union a structure that assigns multiple variables to the same memory location
unsigned declare an unsigned integer variable
using import complete or partial namespaces into the current scope
virtual create a function that can be overridden by a derived class
void declare functions or data with no associated data type
volatile warn the compiler about variables that can be modified unexpectedly
wchar_t declare a wide-character variable
while looping construct

 


 

2ª Parte: Herança da Linguagem C / 2nd Part: C Language Heritage

 

Standard C I/O

clearerr clears errors
fclose close a file
feof true if at the end-of-file
ferror checks for a file error
fflush writes the contents of the output buffer
fgetc get a character from a stream
fgetpos get the file position indicator
fgets get a string of characters from a stream
fopen open a file
fprintf print formatted output to a file
fputc write a character to a file
fputs write a string to a file
fread read from a file
freopen open an existing stream with a different name
fscanf read formatted input from a file
fseek move to a specific location in a file
fsetpos move to a specific location in a file
ftell returns the current file position indicator
fwrite write to a file
getc read a character from a file
getchar read a character from STDIN
gets read a string from STDIN
perror displays a string version of the current error to STDERR
printf write formatted output to STDOUT
putc write a character to a stream
putchar write a character to STDOUT
puts write a string to STDOUT
remove erase a file
rename rename a file
rewind move the file position indicator to the beginning of a file
scanf read formatted input from STDIN
setbuf set the buffer for a specific stream
setvbuf set the buffer and size for a specific stream
sprintf write formatted output to a buffer
sscanf read formatted input from a buffer
tmpfile return a pointer to a temporary file
tmpnam return a unique filename
ungetc puts a character back into a stream
vprintf, vfprintf, and vsprintf write formatted output with variable argument lists

 

 

Standard C String and Character

atof converts a string to a double
atoi converts a string to an integer
atol converts a string to a long
isalnum true if a character is alphanumeric
isalpha true if a character is alphabetic
iscntrl true if a character is a control character
isdigit true if a character is a digit
isgraph true if a character is a graphical character
islower true if a character is lowercase
isprint true if a character is a printing character
ispunct true if a character is punctuation
isspace true if a character is a space character
isupper true if a character is an uppercase character
isxdigit true if a character is a hexidecimal character
memchr searches an array for the first occurance of a character
memcmp compares two buffers
memcpy copies one buffer to another
memmove moves one buffer to another
memset fills a buffer with a character
strcat concatenates two strings
strchr finds the first occurance of a character in a string
strcmp compares two strings
strcoll compares two strings in accordance to the current locale
strcpy copies one string to another
strcspn searches one string for any characters in another
strerror returns a text version of a given error code
strlen returns the length of a given string
strncat concatenates a certain amount of characters of two strings
strncmp compares a certain amount of characters of two strings
strncpy copies a certain amount of characters from one string to another
strpbrk finds the first location of any character in one string, in another string
strrchr finds the last occurance of a character in a string
strspn returns the length of a substring of characters of a string
strstr finds the first occurance of a substring of characters
strtod converts a string to a double
strtok finds the next token in a string
strtol converts a string to a long
strtoul converts a string to an unsigned long
strxfrm converts a substring so that it can be used by string comparison functions
tolower converts a character to lowercase
toupper converts a character to uppercase

 

 

Standard C Math

abs absolute value
acos arc cosine
asin arc sine
atan arc tangent
atan2 arc tangent, using signs to determine quadrants
ceil the smallest integer not less than a certain value
cos cosine
cosh hyperbolic cosine
div returns the quotient and remainder of a division
exp returns “e” raised to a given power
fabs absolute value for floating-point numbers
floor returns the largest integer not greater than a given value
fmod returns the remainder of a division
frexp decomposes a number into scientific notation
labs absolute value for long integers
ldexp computes a number in scientific notation
ldiv returns the quotient and remainder of a division, in long integer form
log natural logarithm (to base e)
log10 common logarithm (to base 10)
modf decomposes a number into integer and fractional parts
pow returns a given number raised to another number
sin sine
sinh hyperbolic sine
sqrt square root
tan tangent
tanh hyperbolic tangent

 

 

Standard C Time and Date

asctime a textual version of the time
clock returns the amount of time that the program has been running
ctime returns a specifically formatted version of the time
difftime the difference between two times
gmtime returns a pointer to the current Greenwich Mean Time
localtime returns a pointer to the current time
mktime returns the calendar version of a given time
setlocale sets the current locale
strftime returns individual elements of the date and time
time returns the current calendar time of the system

 

 

Standard C Memory

calloc allocates and clears a two-dimensional chunk of memory
free returns previously allocated memory to the operating system
malloc allocates memory
realloc changes the size of previously allocated memory

 

 

Other Standard C Functions

abort stops the program
assert stops the program if an expression isn’t true
atexit sets a function to be called when the program exits
bsearch perform a binary search
exit stop the program
getenv get enviornment information about a variable
longjmp start execution at a certain point in the program
qsort perform a quicksort
raise send a signal to the program
rand returns a pseudorandom number
setjmp set execution to start at a certain point
signal register a function as a signal handler
srand initialize the random number generator
system perform a system call
va_arg use variable length parameter lists

 


 

3ª Parte: Inovações da linguagem C++ / 3rd Part: C++ Inovations

 

C++ I/O

The <iostream> library automatically defines a few standard objects:

  • cout, an object of the ostream class, which displays data to the standard output device.
  • cerr, another object of the ostream class that writes unbuffered output to the standard error device.
  • clog, like cerr, but uses buffered output.
  • cin, an object of the istream class that reads data from the standard input device.

The <fstream> library allows programmers to do file input and output with the ifstream and ofstream classes.

C++ programmers can also do input and output from strings by using the String Stream class.

Some of the behavior of the C++ I/O streams (precision, justification, etc) may be modified by manipulating various io stream format flags.

I/O Constructors constructors
bad true if an error occurred
clear clear and set status flags
close close a stream
eof true if at the end-of-file
fail true if an error occurred
fill manipulate the default fill character
flags access or manipulate io stream format flags
flush empty the buffer
gcount number of characters read during last input
get read characters
getline read a line of characters
good true if no errors have occurred
ignore read and discard characters
open create an input stream
peek check the next input character
precision manipulate the precision of a stream
put write characters
putback return characters to a stream
rdstate returns the state flags of the stream
read read data into a buffer
seekg perform random access on an input stream
seekp perform random access on output streams
setf set format flags
sync_with_stdio synchronize with standard I/O
tellg read input stream pointers
tellp read output stream pointers
unsetf clear io stream format flags
width access and manipulate the minimum field width
write write characters

 

C++ I/O Flags

Format flags

C++ defines some format flags for standard input and output, which can be manipulated with the flags()setf(), and unsetf() functions. For example,

cout.setf(ios::left);

turns on left justification for all output directed to cout.

Flag Meaning
boolalpha Boolean values can be input/output using the words “true” and “false”.
dec Numeric values are displayed in decimal.
fixed Display floating point values using normal notation (as opposed to scientific).
hex Numeric values are displayed in hexidecimal.
internal If a numeric value is padded to fill a field, spaces are inserted between the sign and base character.
left Output is left justified.
oct Numeric values are displayed in octal.
right Output is right justified.
scientific Display floating point values using scientific notation.
showbase Display the base of all numeric values.
showpoint Display a decimal and extra zeros, even when not needed.
showpos Display a leading plus sign before positive numeric values.
skipws Discard whitespace characters (spaces, tabs, newlines) when reading from a stream.
unitbuf Flush the buffer after each insertion.
uppercase Display the “e” of scientific notation and the “x” of hexidecimal notation as capital letters.

Manipulators

You can also manipulate flags indirectly, using the following manipulators. Most programmers are familiar with the endl manipulator, which might give you an idea of how manipulators are used. For example, to set the dec flag, you might use the following command:

cout << dec;

Manipulators defined in <iostream>
Manipulator Description Input Output
boolalpha Turns on the boolalpha flag

X

X

dec Turns on the dec flag

X

X

endl Output a newline character, flush the stream

X

ends Output a null character

X

fixed Turns on the fixed flag

X

flush Flushes the stream

X

hex Turns on the hex flag

X

X

internal Turns on the internal flag

X

left Turns on the left flag

X

noboolalpha Turns off the boolalpha flag

X

X

noshowbase Turns off the showbase flag

X

noshowpoint Turns off the showpoint flag

X

noshowpos Turns off the showpos flag

X

noskipws Turns off the skipws flag

X

nounitbuf Turns off the unitbuf flag

X

nouppercase Turns off the uppercase flag

X

oct Turns on the oct flag

X

X

right Turns on the right flag

X

scientific Turns on the scientific flag

X

showbase Turns on the showbase flag

X

showpoint Turns on the showpoint flag

X

showpos Turns on the showpos flag

X

skipws Turns on the skipws flag

X

unitbuf Turns on the unitbuf flag

X

uppercase Turns on the uppercase flag

X

ws Skip any leading whitespace

X

Manipulators defined in <iomanip>
Manipulator Description Input Output
resetiosflags( long f ) Turn off the flags specified by f

X

X

setbase( int base ) Sets the number base to base

X

setfill( int ch ) Sets the fill character to ch

X

setiosflags( long f ) Turn on the flags specified by f

X

X

setprecision( int p ) Sets the number of digits of precision

X

setw( int w ) Sets the field width to w

X

State flags

The I/O stream state flags tell you the current state of an I/O stream. The flags are:

Flag Meaning
badbit a fatal error has occurred
eofbit EOF has been found
failbit a nonfatal error has occurred
goodbit no errors have occurred

Mode flags

The I/O stream mode flags allow you to access files in different ways. The flags are:

Mode Meaning
ios::app append output
ios::ate seek to EOF when opened
ios::binary open the file in binary mode
ios::in open the file for reading
ios::out open the file for writing
ios::trunc overwrite the existing file

 

C++ Strings

String operators concatenate strings, assign strings, use strings for I/O, compare strings
append append characters and strings onto a string
assign give a string values from strings of characters and other C++ strings
at returns an element at a specific location
begin returns an iterator to the beginning of the string
c_str returns a standard C character array version of the string
capacity returns the number of elements that the string can hold
clear removes all elements from the string
compare compares two strings
copy copies characters from a string into an array
data returns a pointer to the first character of a string
empty true if the string has no elements
end returns an iterator just past the last element of a string
erase removes elements from a string
find find characters in the string
find_first_not_of find first absence of characters
find_first_of find first occurrence of characters
find_last_not_of find last absence of characters
find_last_of find last occurrence of characters
getline read data from an I/O stream into a string
insert insert characters into a string
length returns the length of the string
max_size returns the maximum number of elements that the string can hold
push_back add an element to the end of the string
rbegin returns a reverse_iterator to the end of the string
rend returns a reverse_iterator to the beginning of the string
replace replace characters in the string
reserve sets the minimum capacity of the string
resize change the size of the string
rfind find the last occurrence of a substring
size returns the number of items in the string
substr returns a certain substring
swap swap the contents of this string with another

 

C++ String Streams

String streams are similar to the <iostream> and <fstream> libraries, except that string streams allow you to perform I/O on strings instead of streams. The <sstream> library provides functionality similar to sscanf() and sprintf() in the standard C library. Three main classes are available in <sstream>:

  • stringstream – allows input and output
  • istringstream – allows input only
  • ostringstream – allows output only

String streams are actually subclasses of iostreams, so all of the functions available for iostreams are also available for stringstream. See the C++ I/O functions for more information.

Constructors create new string streams
Operators read from and write to string streams
rdbuf get the buffer for a string stream
str get or set the stream’s string

 

Miscellaneous C++

auto_ptr create pointers that automatically destroy objects

 


 

4ª Parte: Biblioteca de Modelos Padrão / 4th Part: Standard Template Library

 

C++ Standard Template Library

The C++ STL (Standard Template Library) is a generic collection of class templates and algorithms that allow programmers to easily implement standard data structures like queueslists, and stacks.

The C++ STL provides programmers with the following constructs, grouped into three categories:

  • Sequences
    • C++ Vectors
    • C++ Lists
    • C++ Double-Ended Queues
  • Container Adapters
    • C++ Stacks
    • C++ Queues
    • C++ Priority Queues
  • Associative Containers
    • C++ Bitsets
    • C++ Maps
    • C++ Multimaps
    • C++ Sets
    • C++ Multisets

The idea behind the C++ STL is that the hard part of using complex data structures has already been completed. If a programmer would like to use a stack of integers, all that she has to do is use this code:

stack<int> myStack;

With minimal effort, she can now push() and pop() integers onto this stack. Through the magic of C++ Templates, she could specify any data type, not just integers. The STL Stack class will provide generic functionality of a stack, regardless of the data in the stack.

C++ Algorithms

accumulate sum up a range of elements
adjacent_difference compute the differences between adjacent elements in a range
adjacent_find finds two items that are adjacent to eachother
binary_search determine if an element exists in a certain range
copy copy some range of elements to a new location
copy_backward copy a range of elements in backwards order
copy_n copy N elements
count return the number of elements matching a given value
count_if return the number of elements for which a predicate is true
equal determine if two sets of elements are the same
equal_range search for a range of elements that are all equal to a certain element
fill assign a range of elements a certain value
fill_n assign a value to some number of elements
find find a value in a given range
find_end find the last sequence of elements in a certain range
find_first_of search for any one of a set of elements
find_if find the first element for which a certain predicate is true
for_each apply a function to a range of elements
generate saves the result of a function in a range
generate_n saves the result of N applications of a function
includes returns true if one set is a subset of another
inner_product compute the inner product of two ranges of elements
inplace_merge merge two ordered ranges in-place
is_heap returns true if a given range is a heap
is_sorted returns true if a range is sorted in ascending order
iter_swap swaps the elements pointed to by two iterators
lexicographical_compare returns true if one range is lexicographically less than another
lexicographical_compare_3way determines if one range is lexicographically less than or greater than another
lower_bound search for the first place that a value can be inserted while preserving order
make_heap creates a heap out of a range of elements
max returns the larger of two elements
max_element returns the largest element in a range
merge merge two sorted ranges
min returns the smaller of two elements
min_element returns the smallest element in a range
mismatch finds the first position where two ranges differ
next_permutation generates the next greater lexicographic permutation of a range of elements
nth_element put one element in its sorted location and make sure that no elements to its left are greater than any elements to its right
partial_sort sort the first N elements of a range
partial_sort_copy copy and partially sort a range of elements
partial_sum compute the partial sum of a range of elements
partition divide a range of elements into two groups
pop_heap remove the largest element from a heap
power compute the value of some number raised to the Nth power
prev_permutation generates the next smaller lexicographic permutation of a range of elements
push_heap add an element to a heap
random_sample randomly copy elements from one range to another
random_sample_n sample N random elements from a range
random_shuffle randomly re-order elements in some range
remove remove elements equal to certain value
remove_copy copy a range of elements omitting those that match a certian value
remove_copy_if create a copy of a range of elements, omitting any for which a predicate is true
remove_if remove all elements for which a predicate is true
replace replace every occurrence of some value in a range with another value
replace_copy copy a range, replacing certain elements with new ones
replace_copy_if copy a range of elements, replacing those for which a predicate is true
replace_if change the values of elements for which a predicate is true
reverse reverse elements in some range
reverse_copy create a copy of a range that is reversed
rotate move the elements in some range to the left by some amount
rotate_copy copy and rotate a range of elements
search search for a range of elements
search_n search for N consecutive copies of an element in some range
set_difference computes the difference between two sets
set_intersection computes the intersection of two sets
set_symmetric_difference computes the symmetric difference between two sets
set_union computes the union of two sets
sort sort a range into ascending order
sort_heap turns a heap into a sorted range of elements
stable_partition divide elements into two groups while preserving their relative order
stable_sort sort a range of elements while preserving order between equal elements
swap swap the values of two objects
swap_ranges swaps two ranges of elements
transform applies a function to a range of elements
unique remove consecutive duplicate elements in a range
unique_copy create a copy of some range of elements that contains no consecutive duplicates
upper_bound searches for the last possible location to insert an element into an ordered range

 

C++ Vectors

Vectors contain contiguous elements stored as an array. Accessing members of a vector or appending elements can be done in constant time, whereas locating a specific value or inserting elements into the vector takes linear time.

Vector constructors create vectors and initialize them with some data
Vector operators compare, assign, and access elements of a vector
assign assign elements to a vector
at returns an element at a specific location
back returns a reference to last element of a vector
begin returns an iterator to the beginning of the vector
capacity returns the number of elements that the vector can hold
clear removes all elements from the vector
empty true if the vector has no elements
end returns an iterator just past the last element of a vector
erase removes elements from a vector
front returns a reference to the first element of a vector
insert inserts elements into the vector
max_size returns the maximum number of elements that the vector can hold
pop_back removes the last element of a vector
push_back add an element to the end of the vector
rbegin returns a reverse_iterator to the end of the vector
rend returns a reverse_iterator to the beginning of the vector
reserve sets the minimum capacity of the vector
resize change the size of the vector
size returns the number of items in the vector
swap swap the contents of this vector with another

 

C++ Double-ended Queues

Double-ended queues are like vectors, except that they allow fast insertions and deletions at the beginning (as well as the end) of the container.

Container constructors create dequeues and initialize them with some data
Container operators compare, assign, and access elements of a dequeue
assign assign elements to a dequeue
at returns an element at a specific location
back returns a reference to last element of a dequeue
begin returns an iterator to the beginning of the dequeue
clear removes all elements from the dequeue
empty true if the dequeue has no elements
end returns an iterator just past the last element of a dequeue
erase removes elements from a dequeue
front returns a reference to the first element of a dequeue
insert inserts elements into the dequeue
max_size returns the maximum number of elements that the dequeue can hold
pop_back removes the last element of a dequeue
pop_front removes the first element of the dequeue
push_back add an element to the end of the dequeue
push_front add an element to the front of the dequeue
rbegin returns a reverse_iterator to the end of the dequeue
rend returns a reverse_iterator to the beginning of the dequeue
resize change the size of the dequeue
size returns the number of items in the dequeue
swap swap the contents of this dequeue with another

 

C++ Lists

Lists are sequences of elements stored in a linked list. Compared to vectors, they allow fast insertions and deletions, but slower random access.

Container constructors create lists and initialize them with some data
Container operators assign and compare lists
assign assign elements to a list
back returns a reference to last element of a list
begin returns an iterator to the beginning of the list
clear removes all elements from the list
empty true if the list has no elements
end returns an iterator just past the last element of a list
erase removes elements from a list
front returns a reference to the first element of a list
insert inserts elements into the list
max_size returns the maximum number of elements that the list can hold
merge merge two lists
pop_back removes the last element of a list
pop_front removes the first element of the list
push_back add an element to the end of the list
push_front add an element to the front of the list
rbegin returns a reverse_iterator to the end of the list
remove removes elements from a list
remove_if removes elements conditionally
rend returns a reverse_iterator to the beginning of the list
resize change the size of the list
reverse reverse the list
size returns the number of items in the list
sort sorts a list into ascending order
splice merge two lists in constant time
swap swap the contents of this list with another
unique removes consecutive duplicate elements

 

C++ Priority Queues

C++ Priority Queues are like queues, but the elements inside the the data structure are ordered by some predicate.

Priority queue constructors construct a new priority queue
empty true if the priority queue has no elements
pop removes the top element of a priority queue
push adds an element to the end of the priority queue
size returns the number of items in the priority queue
top returns the top element of the priority queue

 

C++ Queues

The C++ Queue is a container adapter that gives the programmer a FIFO (first-in, first-out) data structure.

Queue constructor construct a new queue
back returns a reference to last element of a queue
empty true if the queue has no elements
front returns a reference to the first element of a queue
pop removes the top element of a queue
push adds an element to the end of the queue
size returns the number of items in the queue

 

C++ Stacks

The C++ Stack is a container adapter that gives the programmer the functionality of a stack — specifically, a FILO (first-in, last-out) data structure.

Stack constructors construct a new stack
empty true if the stack has no elements
pop removes the top element of a stack
push adds an element to the top of the stack
size returns the number of items in the stack
top returns the top element of the stack

 

C++ Sets

The C++ Set is an associative container that contains a sorted set of unique objects.

Set constructors & destructors default methods to allocate, copy, and deallocate sets
Set operators assign and compare sets
begin returns an iterator to the beginning of the set
clear removes all elements from the set
count returns the number of elements matching a certain key
empty true if the set has no elements
end returns an iterator just past the last element of a set
equal_range returns iterators to the first and just past the last elements matching a specific key
erase removes elements from a set
find returns an iterator to specific elements
insert insert items into a set
key_comp returns the function that compares keys
lower_bound returns an iterator to the first element greater than or equal to a certain value
max_size returns the maximum number of elements that the set can hold
rbegin returns a reverse_iterator to the end of the set
rend returns a reverse_iterator to the beginning of the set
size returns the number of items in the set
swap swap the contents of this set with another
upper_bound returns an iterator to the first element greater than a certain value
value_comp returns the function that compares values

 

C++ Multisets

C++ Multisets are like sets, in that they are associative containers containing a sorted set of objects, but differ in that they allow duplicate objects.

Container constructors & destructors default methods to allocate, copy, and deallocate multisets
Container operators assign and compare multisets
begin returns an iterator to the beginning of the multiset
clear removes all elements from the multiset
count returns the number of elements matching a certain key
empty true if the multiset has no elements
end returns an iterator just past the last element of a multiset
equal_range returns iterators to the first and just past the last elements matching a specific key
erase removes elements from a multiset
find returns an iterator to specific elements
insert inserts items into a multiset
key_comp returns the function that compares keys
lower_bound returns an iterator to the first element greater than or equal to a certain value
max_size returns the maximum number of elements that the multiset can hold
rbegin returns a reverse_iterator to the end of the multiset
rend returns a reverse_iterator to the beginning of the multiset
size returns the number of items in the multiset
swap swap the contents of this multiset with another
upper_bound returns an iterator to the first element greater than a certain value
value_comp returns the function that compares values

 

C++ Maps

C++ Maps are sorted associative containers that contain unique key/value pairs. For example, you could create a map that associates a string with an integer, and then use that map to associate the number of days in each month with the name of each month.

Map constructors & destructors default methods to allocate, copy, and deallocate maps
Map operators assign, compare, and access elements of a map
begin returns an iterator to the beginning of the map
clear removes all elements from the map
count returns the number of elements matching a certain key
empty true if the map has no elements
end returns an iterator just past the last element of a map
equal_range returns iterators to the first and just past the last elements matching a specific key
erase removes elements from a map
find returns an iterator to specific elements
insert insert items into a map
key_comp returns the function that compares keys
lower_bound returns an iterator to the first element greater than or equal to a certain value
max_size returns the maximum number of elements that the map can hold
rbegin returns a reverse_iterator to the end of the map
rend returns a reverse_iterator to the beginning of the map
size returns the number of items in the map
swap swap the contents of this map with another
upper_bound returns an iterator to the first element greater than a certain value
value_comp returns the function that compares values

 

C++ Multimaps

C++ Multimaps are like maps, in that they are sorted associative containers, but differ from maps in that they allow duplicate keys.

Multimap constructors & destructors default methods to allocate, copy, and deallocate multimaps
Multimap operators assign and compare multimaps
begin returns an iterator to the beginning of the multimap
clear removes all elements from the multimap
count returns the number of elements matching a certain key
empty true if the multimap has no elements
end returns an iterator just past the last element of a multimap
equal_range returns iterators to the first and just past the last elements matching a specific key
erase removes elements from a multimap
find returns an iterator to specific elements
insert inserts items into a multimap
key_comp returns the function that compares keys
lower_bound returns an iterator to the first element greater than or equal to a certain value
max_size returns the maximum number of elements that the multimap can hold
rbegin returns a reverse_iterator to the end of the multimap
rend returns a reverse_iterator to the beginning of the multimap
size returns the number of items in the multimap
swap swap the contents of this multimap with another
upper_bound returns an iterator to the first element greater than a certain value
value_comp returns the function that compares values

 

C++ Bitsets

C++ Bitsets give the programmer a set of bits as a data structure. Bitsets can be manipulated by various binary operators such as logical AND, OR, and so on.

Bitset Constructors create new bitsets
Bitset Operators compare and assign bitsets
any true if any bits are set
count returns the number of set bits
flip reverses the bitset
none true if no bits are set
reset sets bits to zero
set sets bits
size number of bits that the bitset can hold
test returns the value of a given bit
to_string string representation of the bitset
to_ulong returns an integer representation of the bitset

 

C++ Iterators

Iterators are used to access members of the container classes, and can be used in a similar manner to pointers. For example, one might use an iterator to step through the elements of a vector. There are several different types of iterators:

Iterator Description
input_iterator Read values with forward movement. These can be incremented, compared, and dereferenced.
output_iterator Write values with forward movement. These can be incremented and dereferenced.
forward_iterator Read or write values with forward movement. These combine the functionality of input and output iterators with the ability to store the iterators value.
bidirectional_iterator Read and write values with forward and backward movement. These are like the forward iterators, but you can increment and decrement them.
random_iterator Read and write values with random access. These are the most powerful iterators, combining the functionality of bidirectional iterators with the ability to do pointer arithmetic and pointer comparisons.
reverse_iterator Either a random iterator or a bidirectional iterator that moves in reverse direction.

Each of the container classes is associated with a type of iterator, and each of the STL algorithms uses a certain type of iterator. For example, vectors are associated with random-access iterators, which means that they can use algorithms that require random access. Since random-access iterators encompass all of the characteristics of the other iterators, vectors can use algorithms designed for other iterators as well.

Notice that you can access the elements of the container by dereferencing the iterator.


Lista de referências compilada a partir de: https://doc.bccnsoft.com/docs/cppreference_en/index.html