Commit 6d52d9be authored by Pascal Palenda's avatar Pascal Palenda
Browse files

Some more naming changes

parent 7b1dc2b9
......@@ -12,36 +12,36 @@ namespace ITA
// https://www.numbercrunch.de/blog/2018/02/range-based-for-loops-with-counters/
// wraps an iterator into a pair of an iterator and an integer index
template<typename iterator_type>
class enumerate_iterator
template<typename IteratorType>
class EnumerateIterator
{
public:
using iterator = iterator_type;
using reference = typename std::iterator_traits<iterator>::reference;
using index_type = typename std::iterator_traits<iterator>::difference_type;
using Iterator = IteratorType;
using Reference = typename std::iterator_traits<Iterator>::reference;
using IndexType = typename std::iterator_traits<Iterator>::difference_type;
private:
iterator iter;
index_type index = 0;
Iterator iter;
IndexType index = 0;
public:
enumerate_iterator ( ) = delete;
explicit enumerate_iterator ( iterator iter, index_type start )
EnumerateIterator ( ) = delete;
explicit EnumerateIterator ( Iterator iter, IndexType start )
: iter ( iter ), index ( start )
{ }
enumerate_iterator& operator++( )
EnumerateIterator& operator++( )
{
++iter;
++index;
return *this;
}
bool operator==( const enumerate_iterator& other ) const
bool operator==( const EnumerateIterator& other ) const
{
return iter == other.iter;
}
bool operator!=( const enumerate_iterator& other ) const
bool operator!=( const EnumerateIterator& other ) const
{
return iter != other.iter;
}
std::pair<reference, const index_type&> operator*( ) const
std::pair<Reference, const IndexType&> operator*( ) const
{
return { *iter, index };
}
......@@ -49,56 +49,56 @@ namespace ITA
// pseudo container, wraps a range given by two iterators [first, last)
// into a range of enumerate iterators
template<typename iterator_type>
class enumerate_range
template<typename IteratorType>
class EnumerateRange
{
public:
using iterator = enumerate_iterator<iterator_type>;
using index_type = typename std::iterator_traits<iterator_type>::difference_type;
using Iterator = EnumerateIterator<IteratorType>;
using IndexType = typename std::iterator_traits<IteratorType>::difference_type;
private:
const iterator_type first, last;
const index_type start;
const IteratorType first, last;
const IndexType start;
public:
enumerate_range ( ) = delete;
explicit enumerate_range ( iterator_type first, iterator_type last,
index_type start = 0 )
EnumerateRange ( ) = delete;
explicit EnumerateRange ( IteratorType first, IteratorType last,
IndexType start = 0 )
: first ( first ), last ( last ), start ( start )
{ }
iterator begin ( ) const
Iterator begin ( ) const
{
return iterator ( first, start );
return Iterator ( first, start );
}
iterator end ( ) const
Iterator end ( ) const
{
return iterator ( last, start );
return Iterator ( last, start );
}
};
// convert a container into a range of enumerate iterators
template<typename container_type>
enumerate_range<typename container_type::iterator> Enumerate ( container_type& content,
typename std::iterator_traits<typename container_type::iterator>::difference_type start = 0 )
template<typename ContainerType>
EnumerateRange<typename ContainerType::iterator> Enumerate ( ContainerType& content,
typename std::iterator_traits<typename ContainerType::iterator>::difference_type start = 0 )
{
using ::std::begin;
using ::std::end;
return enumerate_range<typename container_type::iterator> ( begin ( content ), end ( content ), start );
return EnumerateRange<typename ContainerType::iterator> ( begin ( content ), end ( content ), start );
}
// convert a range given by two iterators [first, last) into a range
// of enumerate iterators
template<typename iterator_type>
enumerate_range<iterator_type> Enumerate ( iterator_type first, iterator_type last,
typename std::iterator_traits<iterator_type>::difference_type start = 0 )
template<typename IteratorType>
EnumerateRange<IteratorType> Enumerate ( IteratorType first, IteratorType last,
typename std::iterator_traits<IteratorType>::difference_type start = 0 )
{
return enumerate_range<iterator_type> ( first, last, start );
return EnumerateRange<IteratorType> ( first, last, start );
}
// convert an initializer list into a range of enumerate iterators
template<typename type>
enumerate_range<typename std::initializer_list<type>::iterator> Enumerate ( const std::initializer_list<type>& content,
template<typename Type>
EnumerateRange<typename std::initializer_list<Type>::iterator> Enumerate ( const std::initializer_list<Type>& content,
std::ptrdiff_t start = 0 )
{
return enumerate_range<typename std::initializer_list<type>::iterator> ( content.begin ( ), content.end ( ), start );
return EnumerateRange<typename std::initializer_list<Type>::iterator> ( content.begin ( ), content.end ( ), start );
}
} // namespace Utils
} // namespace SimulationScheduler
......
......@@ -142,38 +142,38 @@ private:
template<typename Enum>
auto operator |( Enum lhs, Enum rhs ) -> typename std::enable_if<EnableBitMaskOperators<Enum>::value, Enum>::type
{
using underlying = typename std::underlying_type<Enum>::type;
using Underlying = typename std::underlying_type<Enum>::type;
return static_cast< Enum > (
static_cast< underlying >( lhs ) |
static_cast< underlying >( rhs )
static_cast< Underlying >( lhs ) |
static_cast< Underlying >( rhs )
);
}
template<typename Enum>
auto operator &( Enum lhs, Enum rhs ) -> typename std::enable_if<EnableBitMaskOperators<Enum>::value, Enum>::type
{
using underlying = typename std::underlying_type<Enum>::type;
using Underlying = typename std::underlying_type<Enum>::type;
return static_cast< Enum > (
static_cast< underlying >( lhs ) &
static_cast< underlying >( rhs )
static_cast< Underlying >( lhs ) &
static_cast< Underlying >( rhs )
);
}
template<typename Enum>
auto operator |=( Enum& lhs, const Enum& rhs ) -> typename std::enable_if<EnableBitMaskOperators<Enum>::value, Enum>::type&
{
using underlying = typename std::underlying_type<Enum>::type;
auto lhsTmp = static_cast< underlying >( lhs ) |
static_cast< underlying >( rhs );
using Underlying = typename std::underlying_type<Enum>::type;
auto lhsTmp = static_cast< Underlying >( lhs ) |
static_cast< Underlying >( rhs );
return lhs = static_cast< Enum > ( lhsTmp );
}
template<typename Enum>
auto operator &=( Enum& lhs, const Enum& rhs ) -> typename std::enable_if<EnableBitMaskOperators<Enum>::value, Enum>::type&
{
using underlying = typename std::underlying_type<Enum>::type;
auto lhsTmp = static_cast< underlying >( lhs ) &
static_cast< underlying >( rhs );
using Underlying = typename std::underlying_type<Enum>::type;
auto lhsTmp = static_cast< Underlying >( lhs ) &
static_cast< Underlying >( rhs );
return lhs = static_cast< Enum > ( lhsTmp );
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment