P4C
The P4 Compiler
Loading...
Searching...
No Matches
P4::Util::MapEnumerator< T, S, Mapper > Class Template Referencefinal

Transforms all elements from type T to type S. More...

#include <enumerator.h>

Inheritance diagram for P4::Util::MapEnumerator< T, S, Mapper >:
[legend]

Public Member Functions

 MapEnumerator (Enumerator< T > *input, Mapper map)
 
getCurrent () const
 Get current element in the collection.
 
bool moveNext ()
 
void reset ()
 Move back to the beginning of the collection.
 
std::string toString () const
 
- Public Member Functions inherited from P4::Util::Enumerator< S >
bool any ()
 True if the enumerator has at least one element.
 
Enumerator< S > * as ()
 Cast to an enumerator of S objects.
 
EnumeratorHandle< S > begin ()
 
virtual Enumerator< S > * concat (Enumerator< S > *other)
 Append all elements of other after all elements of this.
 
uint64_t count ()
 Enumerate all elements and return the count.
 
EnumeratorHandle< S > end ()
 
Enumerator< std::invoke_result_t< Mapper, S > > * map (Mapper map)
 Apply specified function to all elements of this enumerator.
 
next ()
 Next element; throws if there are no elements.
 
nextOrDefault ()
 Next element, or the default value if none exists.
 
single ()
 The only next element; throws if the enumerator does not have exactly 1 element.
 
singleOrDefault ()
 
const char * stateName () const
 
std::vector< S > toVector ()
 
Enumerator< S > * where (Filter filter)
 Return an enumerator returning all elements that pass the filter.
 

Protected Attributes

current
 
Enumerator< T > * input
 
Mapper map
 
- Protected Attributes inherited from P4::Util::Enumerator< S >
EnumeratorState state
 

Additional Inherited Members

- Public Types inherited from P4::Util::Enumerator< S >
using value_type
 
- Static Public Member Functions inherited from P4::Util::Enumerator< S >
static Enumerator< S > * concatAll (Enumerator< Enumerator< S > * > *inputs)
 Concatenate all these collections into a single one.
 
static Enumerator< typename Container::value_type > * createEnumerator (const Container &data)
 
static Enumerator< typename Iter::value_type > * createEnumerator (Iter begin, Iter end)
 
static Enumerator< typename Iter::value_type > * createEnumerator (iterator_range< Iter > range)
 
static Enumerator< S > * emptyEnumerator ()
 
- Static Protected Attributes inherited from P4::Util::Enumerator< S >
static std::vector< S > emptyVector
 

Detailed Description

template<typename T, typename S, typename Mapper>
class P4::Util::MapEnumerator< T, S, Mapper >

Transforms all elements from type T to type S.

Member Function Documentation

◆ getCurrent()

template<typename T , typename S , typename Mapper >
S P4::Util::MapEnumerator< T, S, Mapper >::getCurrent ( ) const
inlinevirtual

Get current element in the collection.

Implements P4::Util::Enumerator< S >.

◆ moveNext()

template<typename T , typename S , typename Mapper >
bool P4::Util::MapEnumerator< T, S, Mapper >::moveNext ( )
inlinevirtual

Move to next element in the collection; return false if the next element does not exist

Implements P4::Util::Enumerator< S >.

◆ reset()

template<typename T , typename S , typename Mapper >
void P4::Util::MapEnumerator< T, S, Mapper >::reset ( )
inlinevirtual

Move back to the beginning of the collection.

Reimplemented from P4::Util::Enumerator< S >.