CoreLinuxAssociativeIterator.hpp
#if !defined(__CORELINUXASSOCIATIVEITERATOR_HPP)
#define __CORELINUXASSOCIATIVEITERATOR_HPP
/*
CoreLinux++
Copyright (C) 2000 CoreLinux Consortium
The CoreLinux++ Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The CoreLinux++ Library Library is distributed in the hope that it will
be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#if !defined(__COMMON_HPP)
#include <Common.hpp>
#endif
#if !defined(__ASSOCIATIVEITERATOR_HPP)
#include <AssociativeIterator.hpp>
#endif
#if !defined(__INVALIDITERATOREXCEPTION_HPP)
#include <InvalidIteratorException.hpp>
#endif
#if !defined(__ITERATORBOUNDSEXCEPTION_HPP)
#include <IteratorBoundsException.hpp>
#endif
namespace corelinux
{
template< class TraverseType, class KeyType, class ElementType >
class CoreLinuxAssociativeIterator :
public AssociativeIterator<KeyType,ElementType>
{
public:
//
// Constructors and destructor
//
CoreLinuxAssociativeIterator( void )
throw(InvalidIteratorException)
:
AssociativeIterator<KeyType,ElementType>()
{
throw InvalidIteratorException(LOCATION);
}
CoreLinuxAssociativeIterator( TraverseType aBegin,
TraverseType aEnd )
:
AssociativeIterator<KeyType,ElementType>(),
theBegin( aBegin ),
theEnd( aEnd ),
theCurrent( theBegin )
{
; // do nothing
}
CoreLinuxAssociativeIterator
(
const CoreLinuxAssociativeIterator &aRef
)
:
AssociativeIterator<KeyType,ElementType>( aRef ),
theBegin( aRef.theBegin ),
theEnd( aRef.theEnd ),
theCurrent( aRef.theBegin )
{
; // do nothing
}
virtual ~CoreLinuxAssociativeIterator( void )
{
theBegin = theEnd;
theCurrent = theEnd;
}
//
// Operator overloads
//
CoreLinuxAssociativeIterator & operator=
( const CoreLinuxAssociativeIterator & aRef )
{
theBegin = aRef.theBegin;
theEnd = aRef.theEnd;
theCurrent = theBegin;
return (*this);
}
bool operator==
(
const CoreLinuxAssociativeIterator & aRef
) const
{
return (theBegin == aRef.theBegin &&
theEnd == aRef.theEnd);
}
//
// Accessors
//
virtual bool isValid( void ) const
{
return !(theCurrent == theEnd);
}
virtual ElementType getElement( void )
const throw(IteratorBoundsException)
{
if( this->isValid() == false )
{
throw IteratorBoundsException(LOCATION);
}
else
{
; // do nothing
}
return (*theCurrent).second;
}
virtual KeyType getKey( void )
const throw(IteratorBoundsException)
{
if( this->isValid() == false )
{
throw IteratorBoundsException(LOCATION);
}
else
{
; // do nothing
}
return (*theCurrent).first;
}
//
// Mutators
//
virtual void setFirst( void )
{
theCurrent = theBegin;
}
virtual void setNext( void )
throw(IteratorBoundsException)
{
if( theCurrent != theEnd )
{
++theCurrent;
}
else
{
throw IteratorBoundsException(LOCATION);
}
}
virtual void setPrevious( void )
throw(IteratorBoundsException)
{
if( theCurrent != theBegin &&
theBegin != theEnd )
{
--theCurrent;
}
else
{
throw IteratorBoundsException(LOCATION);
}
}
virtual void setLast( void )
throw(IteratorBoundsException)
{
theCurrent = theEnd;
setPrevious();
}
//
// Protected methods
//
protected:
//
// Protected members
//
protected:
TraverseType theBegin;
TraverseType theEnd;
TraverseType theCurrent;
};
}
#endif // if !defined(__CORELINUXASSOCIATIVEITERATOR_HPP)
/*
Common rcs information do not modify
$Author: prudhomm $
$Revision: 1.1 $
$Date: 2000/04/23 20:43:13 $
$Locker: $
*/
corelinux::InvalidIteratorException
InvalidIteratorException is an exception that indicates a Iterator could not be properly formed for s...
Definition: InvalidIteratorException.hpp:43
corelinux::IteratorBoundsException
IteratorBoundsException is thrown when a Iterator has position before the begining or past the end po...
Definition: IteratorBoundsException.hpp:44
corelinux::CoreLinuxAssociativeIterator::setLast
virtual void setLast(void)
Set AssociativeIterator to last element.
Definition: CoreLinuxAssociativeIterator.hpp:265
corelinux::CoreLinuxAssociativeIterator::setNext
virtual void setNext(void)
Set AssociativeIterator to next element if attempt to position past end of elements.
Definition: CoreLinuxAssociativeIterator.hpp:230
corelinux::CoreLinuxAssociativeIterator::isValid
virtual bool isValid(void) const
isValid implementation for determining if the current position points to a valid EntityType instance ...
Definition: CoreLinuxAssociativeIterator.hpp:164
corelinux::CoreLinuxAssociativeIterator::~CoreLinuxAssociativeIterator
virtual ~CoreLinuxAssociativeIterator(void)
Destructor.
Definition: CoreLinuxAssociativeIterator.hpp:112
corelinux::CoreLinuxAssociativeIterator::theCurrent
TraverseType theCurrent
The current position.
Definition: CoreLinuxAssociativeIterator.hpp:294
corelinux
Forward reference the various common classes.
Definition: AbstractAllocator.hpp:32
corelinux::CoreLinuxAssociativeIterator::setFirst
virtual void setFirst(void)
Set AssociativeIterator to first element.
Definition: CoreLinuxAssociativeIterator.hpp:219
corelinux::CoreLinuxAssociativeIterator::getKey
virtual KeyType getKey(void) const
getKey returns the KeyType instance that is currently pointed to by the AssociativeIterator ...
Definition: CoreLinuxAssociativeIterator.hpp:199
corelinux::AssociativeIterator
The AssociativeIterator that extends Iterator to include the interface for describing an associative ...
Definition: AssociativeIterator.hpp:44
corelinux::CoreLinuxAssociativeIterator
The CoreLinuxAssociativeIterator provides a way to access the elements of any of the associative STL ...
Definition: CoreLinuxAssociativeIterator.hpp:51
corelinux::CoreLinuxAssociativeIterator::CoreLinuxAssociativeIterator
CoreLinuxAssociativeIterator(void)
Default constructor - the CoreLinuxAssociativeIterator requires being constructed with a valid collec...
Definition: CoreLinuxAssociativeIterator.hpp:67
corelinux::CoreLinuxAssociativeIterator::theEnd
TraverseType theEnd
The last position.
Definition: CoreLinuxAssociativeIterator.hpp:290
corelinux::CoreLinuxAssociativeIterator::theBegin
TraverseType theBegin
The first position.
Definition: CoreLinuxAssociativeIterator.hpp:286
corelinux::CoreLinuxAssociativeIterator::setPrevious
virtual void setPrevious(void)
Set AssociativeIterator to previous element if attempt to position before begining of elements...
Definition: CoreLinuxAssociativeIterator.hpp:249
corelinux::CoreLinuxAssociativeIterator::getElement
virtual ElementType getElement(void) const
getElement returns the ElementType instance that is currently managed by the CoreLinuxAssociativeIter...
Definition: CoreLinuxAssociativeIterator.hpp:177
corelinux::CoreLinuxAssociativeIterator::CoreLinuxAssociativeIterator
CoreLinuxAssociativeIterator(TraverseType aBegin, TraverseType aEnd)
Initializing constructor.
Definition: CoreLinuxAssociativeIterator.hpp:81

This is the CoreLinux++ reference manual
Provided by The CoreLinux Consortium