list::pop_front |
public member function |
Delete first element
Removes the first element in the list container, effectively reducing the list size by one.
This calls the removed element's destructor.
Parameters
none
Return value
none
Example
// list::pop_front
#include <iostream>
#include <list>
using namespace std;
int main ()
{
list<int> mylist;
int sum (0);
mylist.push_back (100);
mylist.push_back (200);
mylist.push_back (300);
cout << "Popping out the elements in mylist:";
while (!mylist.empty())
{
cout << " " << mylist.front();
mylist.pop_front();
}
cout << "\nFinal size of mylist is " << int(mylist.size()) << endl;
return 0;
}
|
Output:
Popping out the elements in mylist: 100 200 300 Final size of mylist is 0
|
Complexity
Constant.
See also