#if !defined(_INLINE)
static char cvsid[] = "@(#)$Id: RangedContainerEnumeration.cpp,v 1.3 1999/03/03 19:09:45 philogelos Exp $";
static char debugFileId[] = __FILE__;
#endif
#include "iter/enumerations/RangedContainerEnumeration.hpp"
#include "containers/RangedContainer.hpp"
#include "containers/IndexPosition.hpp"
#include "String.hpp"
#include "Debug.hpp"
#include "LinkManager.hpp"
RangedContainerEnumeration::RangedContainerEnumeration( RangedContainer *aHost )
{
sure_( ( Object * ) aHost != null );
LinkManager::reg( this, aHost );
host = aHost;
position = host -> getLowBound();
}
RangedContainerEnumeration::~RangedContainerEnumeration()
{
LinkManager::free( this, host );
}
Top *RangedContainerEnumeration::getPrevElement()
{
preC_( ! isAtBeginning() );
return ( host -> getPosition( --position ) );
}
void RangedContainerEnumeration::reset()
{
position = host -> getLowBound();
}
void RangedContainerEnumeration::ff()
{
position = host -> getHighBound();
}
boolean RangedContainerEnumeration::isAtBeginning()
{
return ( position == ( host -> getLowBound() ) );
}
boolean RangedContainerEnumeration::hasMoreElements()
{
return ( position < ( host -> getHighBound() ) );
}
Top *RangedContainerEnumeration::getNextElement()
{
return MutablePositionEnumeration::getNextElement();
}
MutablePosition *RangedContainerEnumeration::getNextMutablePosition()
{
preC_( hasMoreElements() );
return ( host -> getPosition( position++ ) );
}
Top *RangedContainerEnumeration::clone() const
{
return new RangedContainerEnumeration( host );
}
String RangedContainerEnumeration::getString() const
{
return String( "over container: ``" ) + host -> getString() +
"'' in a position: " + String( position, 10 );
}
String RangedContainerEnumeration::getClassName() const
{
return "RangedContainerEnumeration";
}
#if defined(_INLINE)
#include "../src/Debug.ipp"
#endif
#if defined(_INLINE)
#include "../src/String.ipp"
#endif