Qt 4.8
Functions
qxsdstatemachinebuilder.cpp File Reference
#include "qxsdstatemachinebuilder_p.h"
#include "qxsdelement_p.h"
#include "qxsdmodelgroup_p.h"
#include "qxsdschemahelper_p.h"

Go to the source code of this file.

Functions

template<typename T >
QList< QList< T > > allCombinations (const QList< T > &input)
 
static void internalParticleLookupMap (const XsdParticle::Ptr &particle, QHash< XsdTerm::Ptr, XsdParticle::Ptr > &hash)
 

Function Documentation

◆ allCombinations()

template<typename T >
QList< QList<T> > allCombinations ( const QList< T > &  input)

Definition at line 70 of file qxsdstatemachinebuilder.cpp.

Referenced by QPatternist::XsdStateMachineBuilder::buildTerm().

71 {
72  if (input.count() == 1)
73  return (QList< QList<T> >() << input);
74 
75  QList< QList<T> > result;
76  for (int i = 0; i < input.count(); ++i) {
77  QList<T> subList = input;
78  T value = subList.takeAt(i);
79 
80  QList< QList<T> > subLists = allCombinations(subList);
81  for (int j = 0; j < subLists.count(); ++j) {
82  subLists[j].prepend(value);
83  }
84  result << subLists;
85  }
86 
87  return result;
88 }
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
void prepend(const T &t)
Inserts value at the beginning of the list.
Definition: qlist.h:541
T takeAt(int i)
Removes the item at index position i and returns it.
Definition: qlist.h:484
QList< QList< T > > allCombinations(const QList< T > &input)
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ internalParticleLookupMap()

static void internalParticleLookupMap ( const XsdParticle::Ptr particle,
QHash< XsdTerm::Ptr, XsdParticle::Ptr > &  hash 
)
static

Definition at line 240 of file qxsdstatemachinebuilder.cpp.

Referenced by QPatternist::XsdStateMachineBuilder::particleLookupMap().

241 {
242  hash.insert(particle->term(), particle);
243 
244  if (particle->term()->isModelGroup()) {
245  const XsdModelGroup::Ptr group(particle->term());
246  const XsdParticle::List particles = group->particles();
247  for (int i = 0; i < particles.count(); ++i)
248  internalParticleLookupMap(particles.at(i), hash);
249  }
250 }
static uint hash(const uchar *p, int n)
Definition: qhash.cpp:68
XsdTerm::Ptr term() const
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
Definition: qhash.h:753
static void internalParticleLookupMap(const XsdParticle::Ptr &particle, QHash< XsdTerm::Ptr, XsdParticle::Ptr > &hash)
virtual bool isModelGroup() const
Definition: qxsdterm.cpp:53