Qt 4.8
|
RangeIterator represents a sequence of integers between a start and end value. More...
#include <qrangeiterator_p.h>
Public Types | |
enum | Direction { Backward = 0, Forward = 1 } |
Public Types inherited from QAbstractXmlForwardIterator< Item > | |
typedef QList< QExplicitlySharedDataPointer< QAbstractXmlForwardIterator< Item > > > | List |
A QList containing QAbstractXmlForwardIterator::Ptr instances. More... | |
typedef QExplicitlySharedDataPointer< QAbstractXmlForwardIterator< Item > > | Ptr |
A smart pointer wrapping an instance of a QAbstractXmlForwardIterator subclass. More... | |
typedef QVector< QExplicitlySharedDataPointer< QAbstractXmlForwardIterator< Item > > > | Vector |
A QVector containing QAbstractXmlForwardIterator::Ptr instances. More... | |
Public Functions | |
virtual Item::Iterator::Ptr | copy () const |
Copies this QAbstractXmlForwardIterator and returns the copy. More... | |
virtual xsInteger | count () |
Determines the number of items this QAbstractXmlForwardIterator represents. More... | |
virtual Item | current () const |
Returns the current item in the sequence. More... | |
virtual Item | next () |
Returns the next item in the sequence, or a null object if the end has been reached. More... | |
virtual xsInteger | position () const |
Returns the current position in the sequence represented by this. More... | |
RangeIterator (const xsInteger start, const Direction direction, const xsInteger end) | |
virtual Item::Iterator::Ptr | toReversed () |
Returns a reverse iterator for the sequence. More... | |
Public Functions inherited from QAbstractXmlForwardIterator< Item > | |
virtual bool | isEmpty () |
Returns true if the sequence is empty. More... | |
virtual Item | last () |
Returns the item at the end of this QAbstractXmlForwardIterator. More... | |
QAbstractXmlForwardIterator () | |
Default constructor. More... | |
virtual qint64 | sizeHint () const |
Gives a hint to the size of the contained sequence. More... | |
virtual QList< Item > | toList () |
Performs a copy of this QAbstractXmlForwardIterator(with copy()), and returns its items in a QList. More... | |
virtual | ~QAbstractXmlForwardIterator () |
Destructor. More... | |
Public Functions inherited from QSharedData | |
QSharedData () | |
Constructs a QSharedData object with a reference count of 0. More... | |
QSharedData (const QSharedData &) | |
Constructs a QSharedData object with reference count 0. More... | |
Properties | |
xsInteger | m_count |
Item | m_current |
const Direction | m_direction |
xsInteger | m_end |
const qint8 | m_increment: 2 |
xsInteger | m_position |
xsInteger | m_start |
Additional Inherited Members | |
Public Variables inherited from QSharedData | |
QAtomicInt | ref |
Related Functions inherited from QAbstractXmlForwardIterator< Item > | |
static QAbstractXmlForwardIterator< TResult >::Ptr | makeSequenceMappingIterator (const TMapper &mapper, const QExplicitlySharedDataPointer< QAbstractXmlForwardIterator< TSource > > &source, const DynamicContext::Ptr &context) |
An object generator for SequenceMappingIterator. More... | |
bool | qIsForwardIteratorEnd (const Item &unit) |
The Callback QAbstractXmlForwardIterator uses for determining whether unit is the end of a sequence. More... | |
RangeIterator represents a sequence of integers between a start and end value.
The RangeIterator contains the evaluation logic for the range expression, N to M
, and its behavior is therefore consistent with the definition of that XPath expression. Hence, the detailed behavior of the RangeIterator can be found in the XPath 2.0 specification.
Definition at line 79 of file qrangeiterator_p.h.
RangeIterator can iterate in both directions. This enumerator exist for identifying different directions.
Enumerator | |
---|---|
Backward | Signifies that the QAbstractXmlForwardIterator operates in a reverse direction, where the first item returned by the next() function is from the beginning of the source sequence. |
Forward | Signifies the forward direction. Iterators do conceptually operate in the forward direction by default. |
Definition at line 87 of file qrangeiterator_p.h.
RangeIterator::RangeIterator | ( | const xsInteger | start, |
const Direction | direction, | ||
const xsInteger | end | ||
) |
Creates an QAbstractXmlForwardIterator that returns integer values from consecutive sequence of integers between start
and end
, where the step taken between each integer is 1 with polarity as specified in direction
.
start
must be smaller than end
, not larger or equal. This is not checked. Definition at line 50 of file qrangeiterator.cpp.
Referenced by copy(), and toReversed().
|
virtual |
Copies this QAbstractXmlForwardIterator and returns the copy.
A copy and the original instance are completely independent of each other. Because evaluating an QAbstractXmlForwardIterator modifies it, one should always use a copy when an QAbstractXmlForwardIterator needs to be used several times.
Reimplemented from QAbstractXmlForwardIterator< Item >.
Definition at line 118 of file qrangeiterator.cpp.
|
virtual |
Determines the number of items this QAbstractXmlForwardIterator represents.
Note that this function is not const
. It modifies the QAbstractXmlForwardIterator. The reason for this is efficiency. If this QAbstractXmlForwardIterator must not be changed, get a copy() before performing the count.
The default implementation simply calls next() until the end is reached. Hence, it may be of interest to override this function if the sub-class knows a better way of computing its count.
The number of items in the sequence is returned.
Reimplemented from QAbstractXmlForwardIterator< Item >.
Definition at line 90 of file qrangeiterator.cpp.
|
virtual |
Returns the current item in the sequence.
If this function is called before the first call to next(), a null object is returned. If the end of the sequence has been reached, a null object is returned.
Implements QAbstractXmlForwardIterator< Item >.
Definition at line 108 of file qrangeiterator.cpp.
|
virtual |
Returns the next item in the sequence, or a null object if the end has been reached.
Implements QAbstractXmlForwardIterator< Item >.
Definition at line 70 of file qrangeiterator.cpp.
|
virtual |
Returns the current position in the sequence represented by this.
The first position is 1, not 0. If next() hasn't been called, 0 is returned. If this has reached the end, -1 is returned.
Implements QAbstractXmlForwardIterator< Item >.
Definition at line 113 of file qrangeiterator.cpp.
|
virtual |
Returns a reverse iterator for the sequence.
This function may modify the iterator, it can be considered a function that evaluates this QAbstractXmlForwardIterator. It is not a getter, but potentially alters the iterator in the same way the next() function does. If this QAbstractXmlForwardIterator must not be modified, such that it can be used for evaluation with next(), use a copy().
Reimplemented from QAbstractXmlForwardIterator< Item >.
Definition at line 103 of file qrangeiterator.cpp.
|
private |
Definition at line 127 of file qrangeiterator_p.h.
Referenced by next(), and RangeIterator().
|
private |
Definition at line 125 of file qrangeiterator_p.h.
|
private |
Definition at line 128 of file qrangeiterator_p.h.
Referenced by copy(), next(), and RangeIterator().
|
private |
Definition at line 124 of file qrangeiterator_p.h.
Referenced by copy(), count(), next(), RangeIterator(), and toReversed().
|
private |
We only need to store -1 or 1, so save memory with a bit field.
Definition at line 133 of file qrangeiterator_p.h.
Referenced by next().
|
private |
Definition at line 126 of file qrangeiterator_p.h.
Referenced by next(), and position().
|
private |
Definition at line 123 of file qrangeiterator_p.h.
Referenced by copy(), count(), RangeIterator(), and toReversed().