Rosetta
Public Types | Public Member Functions | Private Attributes | List of all members
utility::LexicographicalIterator Class Reference

#include <LexicographicalIterator.hh>

Public Types

typedef platform::Size Size
 

Public Member Functions

 LexicographicalIterator ()
 default constructor – requires that set_dimension_sizes later be called. or the default alphabet (size 0). More...
 
 LexicographicalIterator (utility::vector1< Size > const &dim_sizes)
 Constructor with dimension sizes. More...
 
void set_dimension_sizes (utility::vector1< Size > const &dim_sizes)
 Set the dimension sizes; resets the curr_pos_ to the beginning of the enumeration. More...
 
void begin ()
 reset the iterator to the beginning string (1,1,1,...) More...
 
bool at_end () const
 Is the iterator at the end? More...
 
Size operator++ ()
 Increment the iterator and return the number of dimensions that were advanced. the number of advanced dimensions ranges from 0 to ndims. 0 is returned only if the iterator is at the end. More...
 
Size size () const
 The number of dimensions. More...
 
Size ndims () const
 The number of dimensions. More...
 
Size operator[] (Size dim) const
 Access the ith dimension (from most-significant digit to least). If the iterator pointed to the string "MACE", then dimension "2" refers to the position holding "A". Unsigned dimension input. More...
 
utility::vector1< Size > const & operator* () const
 Access to the current state of the iterator. Basically a concatenation of the operator[] elements So using 1-26 for A-M, "MACE" would be { 13, 1, 3, 5 }. More...
 
Size dimsize (Size dim) const
 
Size index () const
 Give an integer index of the current state. This can be used to reset the lexicographical iterator to the current state again later. More...
 
void set_position_from_index (Size index)
 Set the state of the lexicographical iterator using a particular index. More...
 
Size continue_at_dimension (Size dim)
 Advance the nth dimension to its next value and reset the higher dimensions to their initial values. E.g. If there were four dimensions of size 5, and the current state was [ 1, 3, 2, 4 ], then continue_at_dimension( 2 ) would result in the state [ 1, 4, 1, 1 ], and if the state were [ 1, 5, 2, 3 ], then continue_at_dimension( 2 ) would result in the state [ 2, 1, 1, 1 ]. Returns the number of dimensions that were advanced (0 if at_end, but otherwise, >= dim) More...
 
Size num_states_total () const
 Returns the number of states that could be enumerated. More...
 

Private Attributes

utility::vector1< Sizedim_sizes_
 
utility::vector1< Sizecurr_pos_
 

Member Typedef Documentation

◆ Size

Constructor & Destructor Documentation

◆ LexicographicalIterator() [1/2]

utility::LexicographicalIterator::LexicographicalIterator ( )

default constructor – requires that set_dimension_sizes later be called. or the default alphabet (size 0).

– fake that there's one alphabet and that it has size 0.

◆ LexicographicalIterator() [2/2]

utility::LexicographicalIterator::LexicographicalIterator ( utility::vector1< Size > const &  dim_sizes)

Constructor with dimension sizes.

No alphabet may have size 0.

References debug_assert, and create_a3b_hbs::ii.

Member Function Documentation

◆ at_end()

bool utility::LexicographicalIterator::at_end ( ) const

Is the iterator at the end?

both curr_pos_ and dim_sizes_ must have size greater than 0. Therefore, even the empty set of alphabets (used by the default ctor) must contain 1 alphabet.

References curr_pos_, and dim_sizes_.

Referenced by main(), operator++(), and sweep_params_from_match_constraint_file().

◆ begin()

void utility::LexicographicalIterator::begin ( )

reset the iterator to the beginning string (1,1,1,...)

First element is the 1 string

References curr_pos_, and detail::fill().

Referenced by set_dimension_sizes(), and sweep_params_from_match_constraint_file().

◆ continue_at_dimension()

LexicographicalIterator::Size utility::LexicographicalIterator::continue_at_dimension ( Size  dim)

Advance the nth dimension to its next value and reset the higher dimensions to their initial values. E.g. If there were four dimensions of size 5, and the current state was [ 1, 3, 2, 4 ], then continue_at_dimension( 2 ) would result in the state [ 1, 4, 1, 1 ], and if the state were [ 1, 5, 2, 3 ], then continue_at_dimension( 2 ) would result in the state [ 2, 1, 1, 1 ]. Returns the number of dimensions that were advanced (0 if at_end, but otherwise, >= dim)

set the higher dimensions to their maximum values, and simply invoke the ++operator which will handle the logic of rolling over lower dimensions if the nth dimension is at its maximum value.

References curr_pos_, dim_sizes_, and create_a3b_hbs::ii.

◆ dimsize()

Size utility::LexicographicalIterator::dimsize ( Size  dim) const
inline

◆ index()

LexicographicalIterator::Size utility::LexicographicalIterator::index ( ) const

Give an integer index of the current state. This can be used to reset the lexicographical iterator to the current state again later.

References curr_pos_, dim_sizes_, and create_a3b_hbs::ii.

Referenced by set_position_from_index().

◆ ndims()

Size utility::LexicographicalIterator::ndims ( ) const
inline

The number of dimensions.

References size().

◆ num_states_total()

LexicographicalIterator::Size utility::LexicographicalIterator::num_states_total ( ) const

Returns the number of states that could be enumerated.

References dim_sizes_, and create_a3b_hbs::ii.

Referenced by sweep_params_from_match_constraint_file().

◆ operator*()

utility::vector1< Size > const& utility::LexicographicalIterator::operator* ( ) const
inline

Access to the current state of the iterator. Basically a concatenation of the operator[] elements So using 1-26 for A-M, "MACE" would be { 13, 1, 3, 5 }.

References curr_pos_.

◆ operator++()

LexicographicalIterator::Size utility::LexicographicalIterator::operator++ ( )

Increment the iterator and return the number of dimensions that were advanced. the number of advanced dimensions ranges from 0 to ndims. 0 is returned only if the iterator is at the end.

Return the number of dimensions advanced by the increment operator so that an outside observer can track the progress of the iterator

References at_end(), curr_pos_, dim_sizes_, create_a3b_hbs::ii, and size().

◆ operator[]()

Size utility::LexicographicalIterator::operator[] ( Size  dim) const
inline

Access the ith dimension (from most-significant digit to least). If the iterator pointed to the string "MACE", then dimension "2" refers to the position holding "A". Unsigned dimension input.

References curr_pos_.

◆ set_dimension_sizes()

void utility::LexicographicalIterator::set_dimension_sizes ( utility::vector1< Size > const &  dim_sizes)

Set the dimension sizes; resets the curr_pos_ to the beginning of the enumeration.

References begin(), curr_pos_, dim_sizes_, and create_a3b_hbs::ii.

◆ set_position_from_index()

void utility::LexicographicalIterator::set_position_from_index ( Size  index)

Set the state of the lexicographical iterator using a particular index.

No requirement that the index doesn't "overflow" the iterator; however, if it should overflow, then at_end() will return true.

References curr_pos_, dim_sizes_, create_a3b_hbs::ii, and index().

◆ size()

Size utility::LexicographicalIterator::size ( ) const
inline

The number of dimensions.

References dim_sizes_.

Referenced by ndims(), and operator++().

Member Data Documentation

◆ curr_pos_

utility::vector1< Size > utility::LexicographicalIterator::curr_pos_
private

◆ dim_sizes_

utility::vector1< Size > utility::LexicographicalIterator::dim_sizes_
private

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