📄 list.htm
字号:
<html>
<head>
<title> The list Class</title>
</head>
<body bgcolor="#FFFFFF">
<img src="listban.gif">
<pre>
<font size=5>Class Name</font> list
<font size=5>Header File</font> <list>
<font size=5>Classification</font> Container
</pre>
<a href="list.htm#desc">Class Description</a><br>
<h1>Member Classes</h1>
<i>None</i>
<h1>Methods</h1>
<pre>
<a href="list.htm#assign1">template <class InputIterator> void assign(InputIterator first, InputIterator last)</a><br>
<a href="list.htm#assign2">template <class Size, class T> void assign(Size n, const T& t = T())</a><br>
<a href="list.htm#back">reference back()</a><br>
<a href="list.htm#back">const_reference back() const</a><br>
<a href="sequence.htm#begin">iterator begin()</a><br>
<a href="sequence.htm#begin">const_iterator begin() const</a><br>
<a href="list.htm#clear">void clear()</a><br>
<a href="common.htm#empty">bool empty() const</a><br>
<a href="common.htm#end">iterator end()</a><br>
<a href="common.htm#end">const_iterator end() const</a><br>
<a href="sequence.htm#erase">iterator erase(iterator position)</a><br>
<a href="sequence.htm#erase">iterator erase(iterator position, iterator last)</a><br>
<a href="list.htm#front">reference front()</a><br>
<a href="list.htm#front">const_reference front() const</a><br>
<a href="list.htm#getallocator">allocator_type get_allocator() const</a><br>
<a href="sequence.htm#insert1">iterator insert(iterator position, const T& x = T())</a><br>
<a href="sequence.htm#insert2">void insert(iterator position, size_type n, const T& x)</a><br>
<a href="sequence.htm#insert3">template <class InputIterator> void insert(iterator position, InputIterator first, InputIterator last)</a><br>
<a href="list.htm#list1">explicit list(const Allocator& = Allocator())</a><br>
<a href="list.htm#list2">explicit list(size_type Num, const T& Value = T(), const Allocator& = Allocator())</a><br>
<a href="list.htm#list3">template <class InputIterator> list(InputIterator First, InputIterator Last, const Allocator& = Allocator())</a><br>
<a href="list.htm#list4">list(const list<T,Allocator>& X)</a><br>
<a href="common.htm#maxsize">size_type max_size() const</a><br>
<a href="list.htm#merge1">template <class Compare> void merge(list<T,Allocator>& X, Compare comp)</a><br>
<a href="list.htm#merge2">void merge(list<T,Allocator>& x)</a><br>
<a href="list.htm#popback">void pop_back()</a><br>
<a href="list.htm#popfront">void pop_front()</a><br>
<a href="list.htm#pushback">void push_back(const T& X)</a><br>
<a href="list.htm#pushfront">void push_front(const T& X)</a><br>
<a href="common.htm#rbegin">reverse_iterator rbegin()</a><br>
<a href="common.htm#rbegin">const_reverse_iterator rbegin() const</a><br>
<a href="list.htm#remove">void remove(const T& value)</a><br>
<a href="list.htm#removeif">template <class Predicate> void remove_if(Predicate pred)</a><br>
<a href="common.htm#rend">reverse_iterator rend()</a><br>
<a href="common.htm#rend">const_reverse_iterator rend() const</a><br>
<a href="list.htm#resize">void resize(size_type sz, T C = T)</a><br>
<a href="list.htm#reverse">void reverse()</a><br>
<a href="common.htm#size">size_type size() const</a><br>
<a href="list.htm#sort1">void sort()</a><br>
<a href="list.htm#sort2">template <class Compare> void sort(Compare comp)</a><br>
<a href="list.htm#swap">void swap(list<T,Allocator>&)</a><br>
<a href="list.htm#splice1">void splice(iterator Pos, list<T,Allocator>& X)</a><br>
<a href="list.htm#splice2">void splice(iterator Pos, list<T,Allocator>& X, iterator I)</a><br>
<a href="list.htm#splice3">void splice(iterator Pos, list<T,Allocator>& X, iterator First, iterator Last)</a><br>
<a href="list.htm#unique1">void unique()</a><br>
<a href="list.htm#unique2">template <class BinaryPredicate> void unique(BinaryPredicate binary_pred);</a><br>
</pre>
<h2>Operators</h2>
list<T,Allocato>& operator=(const list<T,Allocator>& x);
<a href="list.htm#example"><h2>Example</h2></a><br>
<a name="desc"><h3>Description</h3></a>
<p>
The list container is object oriented implementation of the classic <i>list</i> data structure. The
list container class abstracts a sequence of objects that can only be accessed from either the
front of the list or the rear of the list.
</p>
<hr>
<pre>
<a name="assign1">Method assign()</a>
Access Public
Classification Modifier
Syntax template <class InputIterator> void assign(InputIterator first, InputIterator last)
Parameters [first,last] is the range of objects that will be assigned to the list.
Return None
</pre>
<h3>Description</h3>
<p>
This assign() method is assigns the objects in the range [first,last] to the objects in
the list in the range [first,last].
</p>
<hr>
<pre>
<a name="assign2">Method assign()</a>
Access Public
Classification Modifier
Syntax template <class Size, class T> void assign(Size n, const T& t = T())
Parameters n is the number of t objects to be assigned to the list.
Return None
</pre>
<h3>Description</h3>
<p>
This assign() method is assigns <i>n</i> objects with value <i>t</i> to the list.
</p>
<hr>
<pre>
<a name="back">Method back()</a>
Access Public
Classification Modifier
Syntax reference back()
Parameters none
Return returns the last element in the list.
</pre>
<h3>Description</h3>
<p>
This back() method returns the last element in the list.
</p>
<hr>
<pre>
<a name="clear">Method clear()</a>
Access Public
Classification Modifier
Syntax void clear()
Parameters none
Return none
</pre>
<h3>Description</h3>
<p>
The clear() method erases every object from the container.
</p>
<hr>
<pre>
<a name="front">Method front()</a>
Access Public
Classification Accessor
Syntax reference front()
Parameters none
Return This method returns the object at the head of the list.
</pre>
<h3>Description</h3>
<p>
The front() method returns object at the beginning(head) of the list.
</p>
<hr>
<pre>
<a name="getallocator">Method get_allocator</a>
Access Public
Classification Accessor
Syntax allocator_type get_allocator() const
Parameters none
Return This method returns a copy of the allocator object.
</pre>
<h3>Description</h3>
<p>
The get_allocator() method returns a copy of this object's allocator object.
</p>
<hr>
<pre>
<a name="list1">Method list</a>
Access Public
Classification Constructor
Syntax list(const Allocator& = Allocator())
Parameters Allocator object.
Return None
</pre>
<h3>Description</h3>
<p>
This list() method constructs and object of type list and supplies the allocator.
</p>
<hr>
<pre>
<a name="list2">Method list</a>
Access Public
Classification Constructor
Syntax explicit list(size_type Num, const T& Value = T(), const Allocator& = Allocator())
Parameters Num is the of objects that are initialized with Value that will be used
to construct the list. Allocator is an allocator object.
Return None
</pre>
<h3>Description</h3>
<p>
This list() method constructs and object of type list and supplies the allocator.
The list is constructed to contain Num objects that have been initialized with Value.
</p>
<hr>
<pre>
<a name="list3">Method list</a>
Access Public
Classification Constructor
Syntax template <class InputIterator> list(InputIterator First, InputIterator Last, const Allocator& = Allocator())
Parameters [First,Last) is the range of objects that will be used to construct
the list.
Return None
</pre>
<h3>Description</h3>
<p>
This list() method constructs and object of type list and supplies the allocator.
The list is constructed to contain copies of the objects in the range [First,Last).
</p>
<hr>
<pre>
<a name="list4">Method list</a>
Access Public
Classification Constructor
Syntax list(const list<T,Allocator>& X)
Parameters X is a list object that will be used to construct this
container.
Return None
</pre>
<h3>Description</h3>
<p>
This list() method constructs a new list object using the list object X.
</p>
<hr>
<pre>
<a name="merge1">Method merge</a>
Access Public
Classification Modifier
Syntax template <class Compare> void merge(list<T,Allocator>& X, Compare comp)
Parameters X is a list to merger with this container. comp is the comparison object
that will be used in the merge.
Return None
</pre>
<h3>Description</h3>
<p>
This merge() method merges the list object X with the current list object.
</p>
<hr>
<pre>
<a name="merge2">Method merge</a>
Access Public
Classification Modifier
Syntax void merge(list<T,Allocator>& x)
Parameters X is a list to merger with this container.
Return None
</pre>
<h3>Description</h3>
<p>
This merge() method merges the list object X with the current list object.
</p>
<hr>
<pre>
<a name="popback">Method pop_back</a>
Access Public
Classification Modifier
Syntax void pop_back()
Parameters None
Return None
</pre>
<h3>Description</h3>
<p>
This pop_back() method removes/erases the last element from the list.
</p>
<hr>
<pre>
<a name="popfront">Method pop_front</a>
Access Public
Classification Modifier
Syntax void pop_front()
Parameters None
Return None
</pre>
<h3>Description</h3>
<p>
This pop_front() method removes/erases the element from front/beginning of the list.
</p>
<hr>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -