📄 reverse.htm
字号:
<html>
<head>
<title>reverse_iterator</title>
<head>
<body bgcolor="#FFFFFF">
<a name="here"></a>
<img src="itraban.gif">
<pre>
<font size=5>Class Name</font> reverse_iterator
<font size=5>Header File</font> <iterator>
<font size=5>Classification</font> abstract data type
</pre>
<a href="reverse.htm#crd">Class Relationship Diagram</a><br>
<br>
<a href="reverse.htm#class-descrip">Class Description</a>
<h1>Member Classes</h1>
<a href="reverse.htm#iterator">Iterator current</a>
<h1>Methods</h1>
<pre>
<a href="reverse.htm#base">Iterator base() const;</a>
<a href="reverse.htm#reverse1">reverse_iterator();</a>
<a href="reverse.htm#reverse2">explicit reverse_iterator(Iterator x);</a>
</pre>
<h1>Operators</h1>
<pre>
<a href="reverse.htm#operator*">Reference operator*() const;</a>
<a href="reverse.htm#operator++1">reverse_operator& operator++();</a>
<a href="reverse.htm#operator++2">reverse_operator& operator++(int);</a>
<a href="reverse.htm#operator--1">reverse_operator& operator--();</a>
<a href="reverse.htm#operator--2">reverse_operator operator--(int);</a>
<a href="reverse.htm#operator->">Pointer operator>() const;</a>
<a href="reverse.htm#operator+">reverse_operator operator+(Distance n) const;</a>
<a href="reverse.htm#operator+=">reverse_operator& operator+=(Distance n);</a>
<a href="reverse.htm#operator-">reverse_operator operator-(Distance n) const;</a>
<a href="reverse.htm#operator-=">reverse_operator& operator-=(Distance n);</a>
<a href="reverse.htm#operator[]">reverse_operator& operator[](Distance n) const;</a>
</pre>
<hr>
<a name="class-descrip"><h3>Class Description</h3></a>
<p>
The reverse_iterator is a <a href="defines.htm#reverse">reverse iterator</a>.
The reverse_iterator is an adaptation of a <a href="defines.htm#random">random access iterator</a>. It can
traverse through a container in the same manner as a random access iterator
but in the reverse direction. Because the reverse iterator traverses in the
reverse order, iterator that points to the start of the container (rbegin())
actually points to one element after the last element in the container.
In order to avoid this type of violation, the dereference operator decrements
that iterator by 1 or current -1. Thus the mapping of this type of iteration
with the original sequence with random access iterator i is:
&*(reverse_iterator(i)) == &*(i - 1). The incrementation, ++, and
decrementation, --, operators perform opposite operations. The
incrementation operator decrements the current iterator and the decrementation
operator increments the current iterator.<br>
<br>
The reverse_iterator meets all of the requirements for the random access
iterator therefore, operator+, operator-, operator+=, operator-=, operator[]
members are all defined along with the global operators: operator>,
operator<, operator>=, operator<=, operator+, and operator-. The -, -= ,
+ , and += operators allows pointer arithmetic to be performed on these
iterators.
</p>
<hr>
<a name="iterator"><h3>Iterator current</h3></a>
<p>
The random access iterator which points into the container. This iterator is
used to determine the current iterator in reverse order.
</p>
<hr>
<pre>
<a name="reverse1">
Method reverse_iterator()</a>
Access Public
Classification Constructor
Syntax reverse_iterator();
Parameters None
Returns None
</pre>
<h3>Description</h3>
<p>
This constructor constructs a reverse_iterator object.
</p>
<hr>
<pre>
<a name="reverse2">
Method reverse_iterator()</a>
Access Public
Classification Constructor
Syntax explicit reverse_iterator(Iterator x);
Paramters <em>x</em> is the random access iterator which points into
the container.
Returns None
</pre>
<h3>Description</h3>
<p>
This constructor constructs a reverse_iterator object and initializes
Iterator <em>current</em> with <em>x</em>.
</p>
<hr>
<pre>
<a name="operator*">
Method operator*()</a>
Access Public
Classification Accessor
Syntax reference operator*() const;
Parameters None
Returns This operator returns a reference to the iterator.
</pre>
<h3>Description</h3>
<p>
The dereference operator of a const object makes a copy of Iterator <em>current</em>,
decrements the copy and returns a reference to the copy.
</p>
<hr>
<pre>
<a name="operator[]">
Method operator[]()</a>
Access Public
Classification Accessor
Syntax Reference operator[](Distance n) const;
Parameters <em>n</em> is a Distance type. It represents the distance between the
iterators in the container. It is used as an offset
value.
Returns The operator will return the element that is n distance + 1
from the end of the container.
</pre>
<h3>Description</h3>
<p>
The subscript operator will return the element that is n distance + 1 from the end of the container.
</p>
<hr>
<pre>
<a name="operator++1">
Method operator++()</a>
Access Public
Classification Accessor
Syntax reverse_iterator& operator++();
Parameters None
Returns This operator returns a pointer to the current object.
</pre>
<h3>Description</h3>
<p>
The pre-incrementation operator decrements Iterator <em>current</em>
(--current) and then returns *this.
</p>
<hr>
<pre>
<a name="operator++2">
Method operator++()</a>
Access Public
Classification Accessor
Syntax reverse_iterator& operator++(int x);
Parameter <em>x</em> is a dummy argument to distinguish between the
postfix and prefix incrementation that is never
used.
Returns This operator returns a pointer to the current object.
</pre>
<h3>Description</h3>
<p>
The postfix incrementation operator makes a copy of *this, decrements
Iterator <em>current</em> (--current) and then returns the copy of *this.
</p>
<hr>
<pre>
<a name="operator--1">
Method operator--()</a>
Access Public
Classification Accessor
Syntax reverse_iterator& operator--();
Parameters None
Returns This operator returns a pointer to the current object.
</pre>
<h3>Description</h3>
<p>
The pre-decrementation operator increments Iterator <em>current</em>
(++current) and then returns *this.
</p>
<hr>
<pre>
<a name="operator--2">
Method operator--()</a>
Access Public
Classification Accessor
Syntax reverse_iterator& operator--(int x);
Parameters <em>x</em> is a dummy argument to distinguish between the
postfix and prefix incrementation that is never used.
Returns This operator returns a pointer to the current object.
</pre>
<h3>Description</h3>
<p>
The postfix decrementation operator makes a copy of *this, increments
Iterator <em>current</em> (++current) and then returns the copy of *this.
</p>
<hr>
<pre>
<a name="base">
Method base()const</a>
Access Public
Classification Accessor
Syntax Iterator base()const;
Parameters None
Returns This method returns Iterator current.
</pre>
<h3>Description</h3>
<p>
The base() method returns Iterator <em>current</em>.
</p>
<hr>
<pre>
<a name="operator+">
Method operator+()</a>
Access Public
Classification Accessor
Syntax reverse_iterator operator+(Distance n) const;
Parameters <em>n</em> is the offset.
Returns This operator returns &(current - n).
</pre>
<h3>Description</h3>
<p>
The operator+() decrements <em>n</em> from Iterator <em>current</em>
and returns a pointer to this element.
</p>
<hr>
<pre>
<a name="operator+=">
Method operator+=()</a>
Access Public
Classification Modifier
Syntax reverse_iterator operator+=(Distance n);
Parameters <em>n</em> is the offset.
Returns This operator returns &(current -= n).
</pre>
<h3>Description</h3>
<p>
The operator+() changes the Iterator <em>current</em> by decrementing <em>current</em>
by <em>n</em> and returns a pointer to this element.
</p>
<hr>
<pre>
<a name="operator-">
Method operator-()</a>
Access Public
Classification Accessor
Syntax reverse_iterator operator(Distance n) const;
Parameters <em>n</em> is the offset.
Returns This operator returns &(current + n).
</pre>
<h3>Description</h3>
<p>
The operator+() increments Iterator <em>current</em> by <em>n</em>
and returns a pointer to this element.
</p>
<hr>
<pre>
<a name="operator-=">
Method operator-=()</a>
Access Public
Classification Modifier
Syntax reverse_iterator operator-=(Distance n);
Parameters <em>n</em> is the offset.
Returns This operator returns &(current += n).
</pre>
<h3>Description</h3>
<p>
The operator+() changes the Iterator <em>current</em> by incrementing
<em>current</em> by <em>n</em> and returns a pointer to this element.
</p>
<hr>
<pre>
<a name="operator->">
Method operator->()</a>
Access Public
Classification Accessor
Syntax pointer operator->() const;
Parameters None
Returns type This operator returns &(operator*()).
</pre>
<h3>Description</h3>
<p>
This pointer operator of a const object makes a copy Iterator <em>current</em>,
decrements the copy and returns a pointer to the copy.
</p>
<hr>
<a name="crd"><h2>The Class Relationship Diagram for reverse_iterator</h2></a>
<img src="rreverse.gif">
<hr>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -