#ifndef __X10_UTIL_MAPITERATOR_H
#define __X10_UTIL_MAPITERATOR_H

#include <x10rt.h>


#define X10_LANG_OBJECT_H_NODEPS
#include <x10/lang/Object.h>
#undef X10_LANG_OBJECT_H_NODEPS
#define X10_LANG_ITERATOR_H_NODEPS
#include <x10/lang/Iterator.h>
#undef X10_LANG_ITERATOR_H_NODEPS
namespace x10 { namespace lang { 
template<class TPMGL(Z1), class TPMGL(U)> class Fun_0_1;
} } 
namespace x10 { namespace lang { 
class Boolean;
} } 
namespace x10 { namespace util { 

template<class TPMGL(S), class TPMGL(T)> class MapIterator;
template <> class MapIterator<void, void>;
template<class TPMGL(S), class TPMGL(T)> class MapIterator : public x10::lang::Object
  {
    public:
    RTT_H_DECLS_CLASS
    
    static x10aux::itable_entry _itables[3];
    
    virtual x10aux::itable_entry* _getITables() { return _itables; }
    
    static typename x10::lang::Iterator<TPMGL(T)>::template itable<x10::util::MapIterator<TPMGL(S), TPMGL(T)> > _itable_0;
    
    static x10::lang::Any::itable<x10::util::MapIterator<TPMGL(S), TPMGL(T)> > _itable_1;
    
    x10aux::ref<x10::lang::Iterator<TPMGL(S)> > FMGL(i);
    
    x10aux::ref<x10::lang::Fun_0_1<TPMGL(S), TPMGL(T)> > FMGL(f);
    
    void _constructor(x10aux::ref<x10::lang::Iterator<TPMGL(S)> > i,
                      x10aux::ref<x10::lang::Fun_0_1<TPMGL(S), TPMGL(T)> > f);
    
    static x10aux::ref<x10::util::MapIterator<TPMGL(S), TPMGL(T)> > _make(
             x10aux::ref<x10::lang::Iterator<TPMGL(S)> > i, x10aux::ref<x10::lang::Fun_0_1<TPMGL(S), TPMGL(T)> > f);
    
    virtual x10_boolean hasNext();
    virtual TPMGL(T) next();
    virtual x10aux::ref<x10::util::MapIterator<TPMGL(S), TPMGL(T)> >
      x10__util__MapIterator____x10__util__MapIterator__this();
    
    // Serialization
    public: static const x10aux::serialization_id_t _serialization_id;
    
    public: virtual x10aux::serialization_id_t _get_serialization_id() {
         return _serialization_id;
    }
    
    public: virtual void _serialize_body(x10aux::serialization_buffer& buf);
    
    public: static x10aux::ref<x10::lang::Reference> _deserializer(x10aux::deserialization_buffer& buf);
    
    public: void _deserialize_body(x10aux::deserialization_buffer& buf);
    
};
template <> class MapIterator<void, void> : public x10::lang::Object
{
    public:
    static x10aux::RuntimeType rtt;
    static const x10aux::RuntimeType* getRTT() { return & rtt; }
    
};

} } 
#endif // X10_UTIL_MAPITERATOR_H

namespace x10 { namespace util { 
template<class TPMGL(S), class TPMGL(T)> class MapIterator;
} } 

#ifndef X10_UTIL_MAPITERATOR_H_NODEPS
#define X10_UTIL_MAPITERATOR_H_NODEPS
#include <x10/lang/Object.h>
#include <x10/lang/Iterator.h>
#include <x10/lang/Fun_0_1.h>
#include <x10/lang/Boolean.h>
#ifndef X10_UTIL_MAPITERATOR_H_GENERICS
#define X10_UTIL_MAPITERATOR_H_GENERICS
#endif // X10_UTIL_MAPITERATOR_H_GENERICS
#ifndef X10_UTIL_MAPITERATOR_H_IMPLEMENTATION
#define X10_UTIL_MAPITERATOR_H_IMPLEMENTATION
#include <x10/util/MapIterator.h>

template<class TPMGL(S), class TPMGL(T)> typename x10::lang::Iterator<TPMGL(T)>::template itable<x10::util::MapIterator<TPMGL(S), TPMGL(T)> >  x10::util::MapIterator<TPMGL(S), TPMGL(T)>::_itable_0(&x10::util::MapIterator<TPMGL(S), TPMGL(T)>::equals, &x10::util::MapIterator<TPMGL(S), TPMGL(T)>::hasNext, &x10::util::MapIterator<TPMGL(S), TPMGL(T)>::hashCode, &x10::util::MapIterator<TPMGL(S), TPMGL(T)>::next, &x10::util::MapIterator<TPMGL(S), TPMGL(T)>::toString, &x10::util::MapIterator<TPMGL(S), TPMGL(T)>::typeName);
template<class TPMGL(S), class TPMGL(T)> x10::lang::Any::itable<x10::util::MapIterator<TPMGL(S), TPMGL(T)> >  x10::util::MapIterator<TPMGL(S), TPMGL(T)>::_itable_1(&x10::util::MapIterator<TPMGL(S), TPMGL(T)>::equals, &x10::util::MapIterator<TPMGL(S), TPMGL(T)>::hashCode, &x10::util::MapIterator<TPMGL(S), TPMGL(T)>::toString, &x10::util::MapIterator<TPMGL(S), TPMGL(T)>::typeName);
template<class TPMGL(S), class TPMGL(T)> x10aux::itable_entry x10::util::MapIterator<TPMGL(S), TPMGL(T)>::_itables[3] = {x10aux::itable_entry(&x10aux::getRTT<x10::lang::Iterator<TPMGL(T)> >, &_itable_0), x10aux::itable_entry(&x10aux::getRTT<x10::lang::Any>, &_itable_1), x10aux::itable_entry(NULL, (void*)x10aux::getRTT<x10::util::MapIterator<TPMGL(S), TPMGL(T)> >())};

//#line 15 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/MapIterator.x10": x10.ast.X10FieldDecl_c

//#line 16 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/MapIterator.x10": x10.ast.X10FieldDecl_c

//#line 18 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/MapIterator.x10": x10.ast.X10ConstructorDecl_c
template<class TPMGL(S), class TPMGL(T)> void x10::util::MapIterator<TPMGL(S), TPMGL(T)>::_constructor(
                                           x10aux::ref<x10::lang::Iterator<TPMGL(S)> > i,
                                           x10aux::ref<x10::lang::Fun_0_1<TPMGL(S), TPMGL(T)> > f) {
    
    //#line 18 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/MapIterator.x10": x10.ast.X10ConstructorCall_c
    (this)->::x10::lang::Object::_constructor();
    
    //#line 18 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/MapIterator.x10": x10.ast.AssignPropertyCall_c
    
    //#line 19 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/MapIterator.x10": Eval of x10.ast.X10FieldAssign_c
    ((x10aux::ref<x10::util::MapIterator<TPMGL(S), TPMGL(T)> >)this)->
      FMGL(i) = i;
    
    //#line 20 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/MapIterator.x10": Eval of x10.ast.X10FieldAssign_c
    ((x10aux::ref<x10::util::MapIterator<TPMGL(S), TPMGL(T)> >)this)->
      FMGL(f) = f;
}
template<class TPMGL(S), class TPMGL(T)> x10aux::ref<x10::util::MapIterator<TPMGL(S), TPMGL(T)> > x10::util::MapIterator<TPMGL(S), TPMGL(T)>::_make(
                                           x10aux::ref<x10::lang::Iterator<TPMGL(S)> > i,
                                           x10aux::ref<x10::lang::Fun_0_1<TPMGL(S), TPMGL(T)> > f)
{
    x10aux::ref<x10::util::MapIterator<TPMGL(S), TPMGL(T)> > this_ = new (memset(x10aux::alloc<x10::util::MapIterator<TPMGL(S), TPMGL(T)> >(), 0, sizeof(x10::util::MapIterator<TPMGL(S), TPMGL(T)>))) x10::util::MapIterator<TPMGL(S), TPMGL(T)>();
    this_->_constructor(i, f);
    return this_;
}



//#line 23 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/MapIterator.x10": x10.ast.X10MethodDecl_c
template<class TPMGL(S), class TPMGL(T)> x10_boolean x10::util::MapIterator<TPMGL(S), TPMGL(T)>::hasNext(
  ) {
    
    //#line 23 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/MapIterator.x10": x10.ast.X10Return_c
    return x10::lang::Iterator<TPMGL(S)>::hasNext(x10aux::nullCheck(((x10aux::ref<x10::util::MapIterator<TPMGL(S), TPMGL(T)> >)this)->
                                                                      FMGL(i)));
    
}

//#line 24 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/MapIterator.x10": x10.ast.X10MethodDecl_c
template<class TPMGL(S), class TPMGL(T)> TPMGL(T) x10::util::MapIterator<TPMGL(S), TPMGL(T)>::next(
  ) {
    
    //#line 24 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/MapIterator.x10": x10.ast.X10Return_c
    return x10::lang::Fun_0_1<TPMGL(S), TPMGL(T)>::__apply(x10aux::nullCheck(((x10aux::ref<x10::util::MapIterator<TPMGL(S), TPMGL(T)> >)this)->
                                                                               FMGL(f)), 
      x10::lang::Iterator<TPMGL(S)>::next(x10aux::nullCheck(((x10aux::ref<x10::util::MapIterator<TPMGL(S), TPMGL(T)> >)this)->
                                                              FMGL(i))));
    
}

//#line 14 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/MapIterator.x10": x10.ast.X10MethodDecl_c
template<class TPMGL(S), class TPMGL(T)> x10aux::ref<x10::util::MapIterator<TPMGL(S), TPMGL(T)> >
  x10::util::MapIterator<TPMGL(S), TPMGL(T)>::x10__util__MapIterator____x10__util__MapIterator__this(
  ) {
    
    //#line 14 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/MapIterator.x10": x10.ast.X10Return_c
    return ((x10aux::ref<x10::util::MapIterator<TPMGL(S), TPMGL(T)> >)this);
    
}
template<class TPMGL(S), class TPMGL(T)> const x10aux::serialization_id_t x10::util::MapIterator<TPMGL(S), TPMGL(T)>::_serialization_id = 
    x10aux::DeserializationDispatcher::addDeserializer(x10::util::MapIterator<TPMGL(S), TPMGL(T)>::_deserializer, x10aux::CLOSURE_KIND_NOT_ASYNC);

template<class TPMGL(S), class TPMGL(T)> void x10::util::MapIterator<TPMGL(S), TPMGL(T)>::_serialize_body(x10aux::serialization_buffer& buf) {
    x10::lang::Object::_serialize_body(buf);
    buf.write(this->FMGL(i));
    buf.write(this->FMGL(f));
    
}

template<class TPMGL(S), class TPMGL(T)> x10aux::ref<x10::lang::Reference> x10::util::MapIterator<TPMGL(S), TPMGL(T)>::_deserializer(x10aux::deserialization_buffer& buf) {
    x10aux::ref<x10::util::MapIterator<TPMGL(S), TPMGL(T)> > this_ = new (memset(x10aux::alloc<x10::util::MapIterator<TPMGL(S), TPMGL(T)> >(), 0, sizeof(x10::util::MapIterator<TPMGL(S), TPMGL(T)>))) x10::util::MapIterator<TPMGL(S), TPMGL(T)>();
    buf.record_reference(this_);
    this_->_deserialize_body(buf);
    return this_;
}

template<class TPMGL(S), class TPMGL(T)> void x10::util::MapIterator<TPMGL(S), TPMGL(T)>::_deserialize_body(x10aux::deserialization_buffer& buf) {
    x10::lang::Object::_deserialize_body(buf);
    FMGL(i) = buf.read<x10aux::ref<x10::lang::Iterator<TPMGL(S)> > >();
    FMGL(f) = buf.read<x10aux::ref<x10::lang::Fun_0_1<TPMGL(S), TPMGL(T)> > >();
}

template<class TPMGL(S), class TPMGL(T)> x10aux::RuntimeType x10::util::MapIterator<TPMGL(S), TPMGL(T)>::rtt;
template<class TPMGL(S), class TPMGL(T)> void x10::util::MapIterator<TPMGL(S), TPMGL(T)>::_initRTT() {
    const x10aux::RuntimeType *canonical = x10aux::getRTT<x10::util::MapIterator<void, void> >();
    if (rtt.initStageOne(canonical)) return;
    const x10aux::RuntimeType* parents[2] = { x10aux::getRTT<x10::lang::Object>(), x10aux::getRTT<x10::lang::Iterator<TPMGL(T)> >()};
    const x10aux::RuntimeType* params[2] = { x10aux::getRTT<TPMGL(S)>(), x10aux::getRTT<TPMGL(T)>()};
    x10aux::RuntimeType::Variance variances[2] = { x10aux::RuntimeType::invariant, x10aux::RuntimeType::invariant};
    const char *baseName = "x10.util.MapIterator";
    rtt.initStageTwo(baseName, x10aux::RuntimeType::class_kind, 2, parents, 2, params, variances);
}
#endif // X10_UTIL_MAPITERATOR_H_IMPLEMENTATION
#endif // __X10_UTIL_MAPITERATOR_H_NODEPS
