|
std::list< T > Class Template Reference#include <c04p232.h>
List of all members.
Detailed Description
template<typename T>
class std::list< T >
Definition at line 15 of file c04p232.h.
|
Public Member Functions |
| list () |
| list (size_type num, const T &val=T()) |
| list (const list< T > &anotherList) |
bool | empty () const |
size_type | size () const |
size_type | max_size () |
iterator | insert (iterator i, const T &val=T()) |
void | remove (const T &val) |
iterator | erase (iterator i) |
iterator | begin () |
iterator | end () |
void | sort () |
Constructor & Destructor Documentation
|
Default constructor; initializes an empty list. - Precondition:
- None.
- Postcondition:
- An empty list exists.
|
template<typename T> |
std::list< T >::list |
( |
size_type |
num, |
|
|
const T & |
val = T() |
|
) |
|
|
|
Constructor; initializes list to have num elements with the value val. - Precondition:
- None.
- Postcondition:
- A list with num elements.
- Parameters:
-
| num | Number of elements needed. |
| val | Value to initialize all list items to. |
|
|
Copy constructor; initializes list to have the same elements as list anotherList. - Precondition:
- None.
- Postcondition:
- A list with the same elements as anotherList.
- Parameters:
-
| anotherList | The list to copy. |
|
Member Function Documentation
template<typename T> |
bool std::list< T >::empty |
( |
|
) |
const |
|
|
Determines whether a list is empty. - Precondition:
- None.
- Postcondition:
- None.
- Returns:
- True if the list is empty; otherwise returns false.
|
template<typename T> |
size_type std::list< T >::size |
( |
|
) |
const |
|
|
Determines the length of the list. size_type is an integral type. - Precondition:
- None.
- Postcondition:
- None.
- Returns:
- The number of items that are currently in the list.
Referenced by main(). |
template<typename T> |
size_type std::list< T >::max_size |
( |
|
) |
|
|
|
Determines the maximum number of items the list can hold. - Precondition:
- None.
- Postcondition:
- None.
- Returns:
- The maximum number of items.
|
template<typename T> |
iterator std::list< T >::insert |
( |
iterator |
i, |
|
|
const T & |
val = T() |
|
) |
|
|
|
Inserts an item val into the list immediately before the element specified by the iterator i. - Precondition:
- The iterator must be initialized, even if the list is empty.
- Postcondition:
- Item val is inserted into the list.
- Parameters:
-
| i | An iterator refering to the place to insert. |
| val | Item to insert. |
- Returns:
- An iterator to the newly inserted item.
Referenced by main(). |
template<typename T> |
void std::list< T >::remove |
( |
const T & |
val |
) |
|
|
|
Removes all items with value val from the list. - Precondition:
- None.
- Postcondition:
- The list has no item with value val.
- Parameters:
-
| val | Value to remove from the list. |
|
template<typename T> |
iterator std::list< T >::erase |
( |
iterator |
i |
) |
|
|
|
Removes the item in the list pointed to by iterator i. - Precondition:
- The iterator must be initialized to point to an element in the list.
- Postcondition:
- The list item pointed to by i is no longer in the list.
- Returns:
- An iterator to the item following the removed item. If the item removed is the last item in the list, the iterator value will be the same as the value returned by end().
|
template<typename T> |
iterator std::list< T >::begin |
( |
|
) |
|
|
|
Returns an iterator to the first item in the list. - Precondition:
- None.
- Postcondition:
- None.
- Returns:
- If the list is empty, the iterator value returned will be the same as the value returned by end().
Referenced by main(). |
template<typename T> |
iterator std::list< T >::end |
( |
|
) |
|
|
|
Returns an iterator value that can be used to test whether the end of the list has been reached. - Precondition:
- None.
- Postcondition:
- None.
- Returns:
- The iterator value indicating the end of the list.
Referenced by main(). |
template<typename T> |
void std::list< T >::sort |
( |
|
) |
|
|
|
Sorts elements according to the operator < and maintains the relative order of equal elements. - Precondition:
- None.
- Postcondition:
- The list is sorted in ascending order.
Referenced by main(). |
The documentation for this class was generated from the following file:
|