Documente Academic
Documente Profesional
Documente Cultură
DATA STRUCTURES
AND
ALGORITHMS
Lecture Notes 7
Sequential Containers
Spring 2008
typedefs Meaning
value_type The type of the object stored in the container.
iterator An iterator appropriate for the container.
const_iterator A const_iterator appropriate for the container
Constructors Purpose
X() Default constructor where X is the container type.
X(a)
Copy constructor where X is the container type and a is
an object of this type.
Functions Behavior
~X() Destructor
X& operator=(const X& a) Assignment operator
bool operator==(const X& a) const Equality operator
bool operator!=(const X& a) const Negation of equals
bool operator<(const X& a) const
bool operator>(const X& a) const Comparison operators. Compares each item in the two
bool operator<=(const X& a) const containers. Objects must implement < operator.
bool operator>=(const X& a) const
void swap(X& a) Swap the contents of this container with the other.
iterator begin()
const_iterator() begin() const Return an iterator to the beginning of the container
iterator end()
const_iterator end() const Return an iterator to one past the end of the container
size_t size() const Return the number of objects in the container
bool empty() const Returns true if the container is empty.
a_vector.resize(a_list.size());
copy(a_list.begin(), a_list.end(),
a_vector.begin());