mirror of
https://github.com/cookiengineer/audacity
synced 2025-05-05 14:18:53 +02:00
Remove transform_iterator and related, no clear need for it yet
This commit is contained in:
parent
d6dea3d224
commit
2ff75acffa
@ -611,96 +611,6 @@ make_iterator_range( const Container &container )
|
||||
return { container.begin(), container.end() };
|
||||
}
|
||||
|
||||
/*
|
||||
* Transform an iterator sequence, as another iterator sequence
|
||||
*/
|
||||
template <
|
||||
typename Result,
|
||||
typename Iterator
|
||||
>
|
||||
class transform_iterator
|
||||
: public std::iterator<
|
||||
typename std::iterator_traits<Iterator>::iterator_category,
|
||||
const Result
|
||||
>
|
||||
{
|
||||
// This takes a function on iterators themselves, not on the
|
||||
// dereference of those iterators, in case you ever need the generality.
|
||||
using Function = std::function< Result( const Iterator& ) >;
|
||||
|
||||
private:
|
||||
Iterator mIterator;
|
||||
Function mFunction;
|
||||
|
||||
public:
|
||||
transform_iterator(const Iterator &iterator, const Function &function)
|
||||
: mIterator( iterator )
|
||||
, mFunction( function )
|
||||
{}
|
||||
|
||||
transform_iterator &operator ++ ()
|
||||
{ ++this->mIterator; return *this; }
|
||||
transform_iterator operator ++ (int)
|
||||
{ auto copy{*this}; ++this->mIterator; return copy; }
|
||||
transform_iterator &operator -- ()
|
||||
{ --this->mIterator; return *this; }
|
||||
transform_iterator operator -- (int)
|
||||
{ auto copy{*this}; --this->mIterator; return copy; }
|
||||
|
||||
Result operator * ()
|
||||
{ return this->mFunction(this->mIterator); }
|
||||
|
||||
friend inline bool operator == (
|
||||
const transform_iterator &a, const transform_iterator &b)
|
||||
{ return a.mIterator == b.mIterator; }
|
||||
friend inline bool operator != (
|
||||
const transform_iterator &a, const transform_iterator &b)
|
||||
{ return !(a == b); }
|
||||
};
|
||||
|
||||
template <
|
||||
typename Iterator,
|
||||
typename Function
|
||||
>
|
||||
transform_iterator<
|
||||
decltype( std::declval<Function>() ( std::declval<Iterator>() ) ),
|
||||
Iterator
|
||||
>
|
||||
make_transform_iterator(const Iterator &iterator, Function function)
|
||||
{
|
||||
return { iterator, function };
|
||||
}
|
||||
|
||||
template < typename Function, typename Iterator > struct value_transformer
|
||||
{
|
||||
// Adapts a function on values to a function on iterators.
|
||||
Function function;
|
||||
|
||||
auto operator () (const Iterator &iterator) const
|
||||
-> decltype( function( *iterator ) )
|
||||
{ return this->function( *iterator ); }
|
||||
};
|
||||
|
||||
template <
|
||||
typename Function,
|
||||
typename Iterator
|
||||
>
|
||||
using value_transform_iterator = transform_iterator<
|
||||
decltype( std::declval<Function>()( *std::declval<Iterator>() ) ),
|
||||
Iterator
|
||||
>;
|
||||
|
||||
template <
|
||||
typename Function,
|
||||
typename Iterator
|
||||
>
|
||||
value_transform_iterator< Function, Iterator >
|
||||
make_value_transform_iterator(const Iterator &iterator, Function function)
|
||||
{
|
||||
using NewFunction = value_transformer<Function, Iterator>;
|
||||
return { iterator, NewFunction{ function } };
|
||||
}
|
||||
|
||||
#if !wxCHECK_VERSION(3, 1, 0)
|
||||
// For using std::unordered_map on wxString
|
||||
namespace std
|
||||
|
Loading…
x
Reference in New Issue
Block a user