Qt 4.8
Public Functions | Properties | List of all members
QPatternist::DeduplicateIterator Class Reference

Performs deduplication of the nodes on its source list. More...

#include <qdeduplicateiterator_p.h>

Inheritance diagram for QPatternist::DeduplicateIterator:
QPatternist::ListIterator< Item > QPatternist::ListIteratorPlatform< InputType, OutputType, Derived, ListType > QAbstractXmlForwardIterator< OutputType > QSharedData

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...
 
 DeduplicateIterator (const Item::List &source)
 
virtual Item next ()
 Returns the next item in the sequence, or a null object if the end has been reached. More...
 
- Public Functions inherited from QPatternist::ListIterator< Item >
 ListIterator (const QList< Item > &list)
 
virtual QList< ItemtoList ()
 Performs a copy of this QAbstractXmlForwardIterator(with copy()), and returns its items in a QList. More...
 
virtual QVector< ItemtoVector ()
 
- Public Functions inherited from QPatternist::ListIteratorPlatform< InputType, OutputType, Derived, ListType >
virtual OutputType current () const
 Returns the current item in the sequence. More...
 
virtual qint64 position () const
 Returns the current position in the sequence represented by this. More...
 
- Public Functions inherited from QAbstractXmlForwardIterator< OutputType >
virtual bool isEmpty ()
 Returns true if the sequence is empty. More...
 
virtual OutputType 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 QAbstractXmlForwardIterator< OutputType >::Ptr toReversed ()
 Returns a reverse iterator for the sequence. 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

int m_listPos
 

Additional Inherited Members

- Public Types inherited from QAbstractXmlForwardIterator< OutputType >
typedef QList< QExplicitlySharedDataPointer< QAbstractXmlForwardIterator< OutputType > > > List
 A QList containing QAbstractXmlForwardIterator::Ptr instances. More...
 
typedef QExplicitlySharedDataPointer< QAbstractXmlForwardIterator< OutputType > > Ptr
 A smart pointer wrapping an instance of a QAbstractXmlForwardIterator subclass. More...
 
typedef QVector< QExplicitlySharedDataPointer< QAbstractXmlForwardIterator< OutputType > > > Vector
 A QVector containing QAbstractXmlForwardIterator::Ptr instances. More...
 
- Public Variables inherited from QSharedData
QAtomicInt ref
 
- Protected Functions inherited from QPatternist::ListIteratorPlatform< InputType, OutputType, Derived, ListType >
 ListIteratorPlatform (const ListType &list)
 Constructs a ListIteratorPlatform that walks the given list. More...
 
- Protected Variables inherited from QPatternist::ListIteratorPlatform< InputType, OutputType, Derived, ListType >
OutputType m_current
 
const ListType m_list
 
qint64 m_position
 

Detailed Description

Performs deduplication of the nodes on its source list.

Note
The nodes in the source list must be in document order.
Author
Frans Englich frans.nosp@m..eng.nosp@m.lich@.nosp@m.noki.nosp@m.a.com

Definition at line 78 of file qdeduplicateiterator_p.h.

Constructors and Destructors

◆ DeduplicateIterator()

DeduplicateIterator::DeduplicateIterator ( const Item::List source)

Definition at line 48 of file qdeduplicateiterator.cpp.

Referenced by copy().

48  : ListIterator<Item>(source)
49  , m_listPos(0)
50 {
51  Q_ASSERT(!Item());
52  Q_ASSERT(!Item().isNode());
53  Q_ASSERT(!Item().isAtomicValue());
54 }
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
Represents an item in the XPath 2.0 Data Model.
Definition: qitem_p.h:182

Functions

◆ copy()

Item::Iterator::Ptr DeduplicateIterator::copy ( ) const
virtual

Copies this QAbstractXmlForwardIterator and returns the copy.

Warning
This function is not part of the public interface.

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 QPatternist::ListIteratorPlatform< InputType, OutputType, Derived, ListType >.

Definition at line 90 of file qdeduplicateiterator.cpp.

91 {
93 }
DeduplicateIterator(const Item::List &source)
QExplicitlySharedDataPointer< QAbstractXmlForwardIterator< Item > > Ptr
A smart pointer wrapping an instance of a QAbstractXmlForwardIterator subclass.

◆ count()

xsInteger DeduplicateIterator::count ( )
virtual

Determines the number of items this QAbstractXmlForwardIterator represents.

Warning
This function is not part of the public interface.

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 QPatternist::ListIteratorPlatform< InputType, OutputType, Derived, ListType >.

Definition at line 85 of file qdeduplicateiterator.cpp.

86 {
88 }
virtual qint64 count()
Determines the number of items this QAbstractXmlForwardIterator represents.

◆ next()

Item DeduplicateIterator::next ( )
virtual

Returns the next item in the sequence, or a null object if the end has been reached.

Reimplemented from QPatternist::ListIteratorPlatform< InputType, OutputType, Derived, ListType >.

Definition at line 56 of file qdeduplicateiterator.cpp.

57 {
58  if(m_listPos == m_list.count())
59  {
60  m_current.reset();
61  m_position = -1;
62  return Item();
63  }
64 
66 
67  while(next.asNode().is(m_current.asNode()))
68  {
69  ++m_listPos;
70  if(m_listPos == m_list.count())
71  {
72  m_current.reset();
73  m_position = -1;
74  return Item();
75  }
76  else
77  next = m_list.at(m_listPos);
78  }
79 
80  ++m_position;
81  m_current = next;
82  return next;
83 }
virtual Item next()
Returns the next item in the sequence, or a null object if the end has been reached.
bool is(const QXmlNodeModelIndex &other) const
Definition: qitem_p.h:487
const QXmlNodeModelIndex & asNode() const
Definition: qitem_p.h:379
Represents an item in the XPath 2.0 Data Model.
Definition: qitem_p.h:182

Properties

◆ m_listPos

int QPatternist::DeduplicateIterator::m_listPos
private

m_position in ListIteratorPlatform is the position that we show to the outside through position) but do not correspond to the position in m_list, since we skip entries in that one.

However, this guy, m_listPos, is the position into m_list.

Definition at line 95 of file qdeduplicateiterator_p.h.

Referenced by next().


The documentation for this class was generated from the following files: