5 #ifndef BALL_CONCEPT_ENUMERATOR_H
6 #define BALL_CONCEPT_ENUMERATOR_H
12 #ifndef BALL_COMMON_EXCEPTION_H
16 #ifndef BALL_COMMON_RTTI_H
20 #ifndef BALL_CONCEPT_FORWARDITERATOR_H
46 :
private std::vector<Position>
77 template <
typename Variant,
typename VariantIterator>
78 EnumeratorIndex(
const std::list<std::pair<VariantIterator, std::vector<Variant> > >& variant_list);
100 template <
typename Variant,
typename VariantIterator>
101 const EnumeratorIndex& operator = (
const std::list<std::pair<VariantIterator, std::vector<Variant> > >& variant_list);
110 const std::vector<Size>& getModulus()
const;
140 Size getSize()
const;
203 std::vector<Size> modulus_;
205 std::vector<Size> base_multipliers_;
209 template <
typename Variant,
typename VariantIterator>
211 : std::vector<
Position>(variant_list.size()),
212 modulus_(variant_list.size()),
213 base_multipliers_(variant_list.size())
219 template <
typename Variant,
typename VariantIterator>
221 (
const std::list<std::pair<VariantIterator, std::vector<Variant> > >& variant_list)
223 resize(variant_list.size());
224 modulus_.resize(variant_list.size());
225 base_multipliers_.resize(variant_list.size());
230 typename std::list<std::pair<VariantIterator, std::vector<Variant> > >::const_iterator list_it = variant_list.begin();
231 for (i = (
Size)(size() - 1); i >= 0; i--, list_it++)
234 modulus_[i] = (
Size)list_it->second.size();
236 base_multipliers_[i] = multiplier;
237 multiplier *= modulus_[i];
272 template <
class Container,
class SiteIterator,
class Variant>
300 typedef std::pair<SiteIterator, VariantVector>
Site;
361 typename SiteList::iterator var_it;
376 typename SiteList::iterator it;
379 total *= it->second.size();
577 void mutate_(SiteIterator& it,
const Variant& v)
589 template <
typename Container,
typename SiteIterator,
typename Variant>
591 : container_(const_cast<Container&>(RTTI::
getDefault<Container>())),
596 template <
typename Container,
typename SiteIterator,
typename Variant>
598 : container_(container),
599 mutator_(defaultAssign_)
603 template <
typename Container,
typename SiteIterator,
typename Variant>
607 : container_(container),
613 template <
typename Container,
typename SiteIterator,
typename Variant>
620 template <
typename Container,
typename SiteIterator,
typename Variant>
626 createCombination(position_);
634 template <
typename Container,
typename SiteIterator,
typename Variant>
637 if (&index != &position_)
642 typename SiteList::iterator it = variant_sites_.begin();
644 for (; it != variant_sites_.end(); ++it, --i)
646 mutate_(it->first, it->second[index[i]]);
649 is_valid_position_ =
true;
652 template <
typename Container,
typename SiteIterator,
typename Variant>
656 return Iterator::begin(*
this);
659 template <
typename Container,
typename SiteIterator,
typename Variant>
663 return Iterator::end(*
this);
666 template <
typename Container,
typename VariantConstIterator,
typename Variant>
670 return ConstIterator::begin(*
this);
673 template <
typename Container,
typename VariantConstIterator,
typename Variant>
677 return ConstIterator::end(*
this);
681 # ifndef BALL_NO_INLINE_FUNCTIONS
682 # include <BALL/CONCEPT/enumerator.iC>
687 #endif // BALL_CONCEPT_ENUMERATOR_H
std::pair< SiteIterator, VariantVector > Site
Enumerator< Container, SiteIterator, Variant > * ContainerPointer
IteratorTraits_(const ContainerType &enumerator)
ForwardIterator< Enumerator< Container, SiteIterator, Variant >, Container, EnumeratorIndex *, IteratorTraits_ > Iterator
IteratorPosition & getPosition()
EnumeratorIndex position_
void(* MutatorFunction)(Variant &, const Variant &)
ContainerConstPointer getContainer() const
const IteratorPosition & getPosition() const
EnumeratorIndex position_
std::list< Site > SiteList
ContainerPointer getContainer()
BALL_EXPORT std::ostream & operator<<(std::ostream &os, const Exception::GeneralException &e)
EnumeratorIndex IteratorPosition
BALL_EXPORT bool operator>(const String &s1, const String &s2)
void mutate_(SiteIterator &it, const Variant &v)
Enumerator< Container, SiteIterator, Variant > ContainerType
std::vector< Variant > VariantVector
BALL_EXPORT bool operator!=(const String &s1, const String &s2)
const Enumerator< Container, SiteIterator, Variant > * ContainerConstPointer
bool operator==(const IteratorTraits_ &traits) const
void addVariants(const SiteIterator &it, const VariantVector &variants)
void createCombination(const Position index)
BALL_EXPORT bool operator>=(const String &s1, const String &s2)
BALL_EXPORT bool operator==(const String &s1, const String &s2)
ConstForwardIterator< Enumerator< Container, SiteIterator, Variant >, Container, EnumeratorIndex *, IteratorTraits_ > ConstIterator
BALL_EXPORT bool operator<=(const String &s1, const String &s2)
const ValueType & getData() const
bool operator!=(const IteratorTraits_ &traits) const
const EnumeratorIndex & operator=(const EnumeratorIndex &rhs)
static void defaultAssign_(Variant &a, const Variant &b)
void deleteVariants(const SiteIterator &it, const VariantVector &variants)
BALL_EXPORT bool operator<(const String &s1, const String &s2)