|
Same level pages: | All containers manage a sequence of elements. Such elements can be of any type that is assignable and default constructible. Containers are supported by non-member functions which conform to the following declarations: template<class T> class Cont; template<class T> bool operator==(const Cont<T>& lhs, const Cont<T>& rhs); template<class T> bool operator!=(const Cont<T>& lhs, const Cont<T>& rhs); template<class T> bool operator< (const Cont<T>& lhs, const Cont<T>& rhs); template<class T> bool operator> (const Cont<T>& lhs, const Cont<T>& rhs); template<class T> bool operator<=(const Cont<T>& lhs, const Cont<T>& rhs); template<class T> bool operator>=(const Cont<T>& lhs, const Cont<T>& rhs); template<class T> void swap(const Cont<T>& lhs, const Cont<T>& rhs); Forward ContainerA forward container supports an iterator that allows traversal of the data in the container in one direction via a begin() iterator (pointing to the beginning of the sequence) and an end() iterator(pointing "just beyond" the end of the sequence) via member functions like the following : iterator begin(); const iterator begin() const; iterator end(); const iterator end() const; Reversible ContainerA reversibile container is a forward container that also supports iterators that allow traversal of the data in the reverse direction member functions like the following: reverse_iterator rbegin(); const reverse_iterator rbegin() const; reverse_iterator rend(); const reverse_iterator rend() const; Random Access ContainerA random access container is a reversible container that also can be randomly accessed by member functions such as the following: template<class T> class Cont; T& at(unsigned pos); const T& at(unsigned pos) const; T& operator[](unsigned pos); const T& operator[](unsigned pos); The operator[] is "syntactic sugar" for the at() member function which is available even in language systems that support STL-like functionality but do not support operator overloading as fully as C++. |
NOTICE: The information presented on this page represents the personal views, ideas, and opinions of the author. This is not an official Ball State University web page. Links contained at this web site to other organizations, are presented as a service and neither constitute nor imply university endorsement or warranty. |