List, types of list constructors and operators in C++

A list is for sequential access in STL. List classes are bidirectional linear lists. Bidirectional means that they can be accessed from front and rear both.

A list class is declared as:

template <class T, class Allocator = allocator<T>> class list

Types of list constructors:

Type-1: Empty list

explicit list(const Allocator &a = Allocator( ) );

Type-2: List having x elements and y values

explicit list(size_type x, const T &y = T ( ), const Allocator &a = Allocator( ));

Type-3: List having same elements as obj

list(const list<T, Allocator> &obj);

Type-4: List having elements in the range of i and j

template <class InIter>list(InIter i, InIter j, const Allocator &a = Allocator( ));

Types of list operators: ==, <, <=, !=, >, >=

Leave a Reply