stl 之 容器
Standard Library container classes:
----------------------------------------------------------
container class Description
Sequence containers:
vector rapid insertions and deletions at back direct access to any element
deque rapid insertions and deletions at front or back direct access to any element
list doubly linked list, rapid insertion and deletion anywhere
Associative containers:
set rapid lookup, no duplicates allowed
multiset rapid lookup, duplicates allowed
map one-to-one mapping, no duplicates allowed, rapid key-based lookup
multimap one-to-many mapping, duplicates allowed, rapid key-based lookup
Container adapters:
stack last-in, first-out (LIFO)
queue first-in, first-out (FIFO)
priority_queue highest-priority element is always the first element out
Common member functions
for all STL containers Description
-----------------------------------------------------------------------------------
default constructor A constructor to provide a default initialization of the container.
Normally, each container has several constructors that provide
different initialization methods for the container.
copy constructor A constructor that initializes the container to be a copy of
an existing container of the same type.
destructor Destructor function for cleanup after a container
is no longer needed.
* * * * * * * * * * * * * * * * * * * * * *
empty Returns true if there are no elements in the container;
otherwise, returns false.
size Returns the number of elements currently in the container.
operator= Assigns one container to another.
operator< Returns true if the first container is less than the second container;
otherwise, returns false.
operator<= Returns TRue if the first container is less than or equal to the second container;
otherwise, returns false.
operator> Returns true if the first container is greater than the second container;
otherwise, returns false.
operator>= Returns true if the first container is greater than or equal to the second
container; otherwise, returns false.
operator== Returns true if the first container is equal to the second container;
otherwise, returns false.
operator!= Returns TRue if the first container is not equal to the second con-tainer;
otherwise, returns false.
swap Swaps the elements of two containers.
Functions found only in first-class containers:
max_size Returns the maximum number of elements for a container.
begin The two versions of this function return either an iterator or a const_iterator
that refers to the first element of the container.
end The two versions of this function return either an iterator or a const_iterator
that refers to the next position after the end of the container.
rbegin The two versions of this function return either a reverse_iterator or a
const_reverse_iterator that refers to the last element of the container.
rend The two versions of this function return either a reverse_iterator or a
const_reverse_iterator that refers to the next position
after the last element of the reversed container.
erase Erases one or more elements from the container.
clear Erases all elements from the container.
阅读(510) | 评论(0) | 转发(0) |