home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
cset21v1.zip
/
IBMCPP
/
IBMCLASS
/
IAVLKSS.IF
< prev
next >
Wrap
Text File
|
1993-09-22
|
15KB
|
414 lines
/*******************************************************************************
* *
* COPYRIGHT: *
* IBM C/C++ Tools Version 2.01 - Collection Class Library *
* Licensed Materials - Property of IBM *
* (C) Copyright IBM Corporation 1992, 1993 *
* All Rights Reserved *
* US Government Users Restricted Rights - Use, duplication, or disclosure *
* restricted by GSA ADP Schedule Contract with IBM Corp. *
* *
*******************************************************************************/
#include <ibexcept.h>
template < class Element, class Key, class ElementOps >
inline void IGAvlKeySortedSet < Element, Key, ElementOps >::
checkNotEmpty () const {
#ifndef INO_CHECKS
ICHECK (!isEmpty (), IEmptyException, ICollectionIsEmptyText)
#endif
}
template < class Element, class Key, class ElementOps >
inline void IGAvlKeySortedSet < Element, Key, ElementOps >::
checkCursorIsForThis (ICursor const& c) const {
#ifndef INO_CHECKS
ICHECK (((Cursor const&)c).isFor (*this), ICursorInvalidException,
ICursorNotForThisText)
#endif
}
template < class Element, class Key, class ElementOps >
inline void IGAvlKeySortedSet < Element, Key, ElementOps >::
checkCursor (ICursor const& c) const {
#ifndef INO_CHECKS
ICHECK (((Cursor const&)c).isFor (*this), ICursorInvalidException,
ICursorNotForThisText)
ICHECK (c.isValid (), ICursorInvalidException, IInvalidCursorText)
#endif
#ifdef IALL_CHECKS
ICHECK (ivImpl.checkNode(((Cursor const&)c).ivNode),
ICursorInvalidException, ICursorNotContainedText)
#endif
}
template < class Element, class Key, class ElementOps >
inline void IGAvlKeySortedSet < Element, Key, ElementOps >::
checkPositionExists (IPosition position) const {
#ifndef INO_CHECKS
ICHECK (1 <= position && position <= numberOfElements(),
IPositionInvalidException, IInvalidPositionText)
#endif
}
template < class Element, class Key, class ElementOps >
inline IGAvlKeySortedSet < Element, Key, ElementOps >::
IGAvlKeySortedSet (INumber n)
: ivImpl (&ivOps) {
}
template < class Element, class Key, class ElementOps >
inline IGAvlKeySortedSet < Element, Key, ElementOps >::
IGAvlKeySortedSet (IGAvlKeySortedSet < Element, Key, ElementOps > const& collection)
: ivImpl (collection.ivImpl, &ivOps) {
}
template < class Element, class Key, class ElementOps >
inline IGAvlKeySortedSet < Element, Key, ElementOps >&
IGAvlKeySortedSet < Element, Key, ElementOps >::
operator = (IGAvlKeySortedSet < Element, Key, ElementOps > const& a)
{ ivImpl = a.ivImpl;
return *this;
}
template < class Element, class Key, class ElementOps >
inline IGAvlKeySortedSet < Element, Key, ElementOps >::
~IGAvlKeySortedSet () {
}
template < class Element, class Key, class ElementOps >
inline void IGAvlKeySortedSet < Element, Key, ElementOps >::
addAllFrom (IGAvlKeySortedSet < Element, Key, ElementOps > const& a)
{
#ifndef INO_CHECKS
ICHECK (this != &a,
IIdenticalCollectionException, IIdenticalCollectionText)
#endif
ivImpl.addAllFrom (a.ivImpl);
}
template < class Element, class Key, class ElementOps >
inline IBoolean IGAvlKeySortedSet < Element, Key, ElementOps >::
add (Element const& e)
{ Cursor dummy (*this);
return add (e, dummy);
}
template < class Element, class Key, class ElementOps >
inline IBoolean IGAvlKeySortedSet < Element, Key, ElementOps >::
add (Element const& e, ICursor& c)
{ checkCursorIsForThis (c);
IBoolean hasBeenAdded = ivImpl.add (&e, ((Cursor&)c).ivNode);
return hasBeenAdded;
}
template < class Element, class Key, class ElementOps >
inline Element const& IGAvlKeySortedSet < Element, Key, ElementOps >::
elementAt (ICursor const& c) const
{ checkCursor (c);
return *(Element const*)
ivImpl.elementAt (((Cursor const&)c).ivNode);
}
template < class Element, class Key, class ElementOps >
inline Element& IGAvlKeySortedSet < Element, Key, ElementOps >::
elementAt (ICursor const& c)
{ checkCursor (c);
return *(Element*)
ivImpl.elementAt (((Cursor const&)c).ivNode);
}
template < class Element, class Key, class ElementOps >
inline Element const& IGAvlKeySortedSet < Element, Key, ElementOps >::
anyElement () const
{ checkNotEmpty ();
return *(Element const*) ivImpl.firstElement ();
}
template < class Element, class Key, class ElementOps >
inline void IGAvlKeySortedSet < Element, Key, ElementOps >::
removeAt (ICursor const& c)
{ checkCursor (c);
ivImpl.removeAt (((Cursor&)c).ivNode);
}
template < class Element, class Key, class ElementOps >
inline INumber IGAvlKeySortedSet < Element, Key, ElementOps >::
removeAll (IBoolean (*predicate) (Element const&, void*), void* env)
{ return ivImpl.removeAll (predicate, env);
}
template < class Element, class Key, class ElementOps >
inline void IGAvlKeySortedSet < Element, Key, ElementOps >::
replaceAt (ICursor const& c, Element const& e)
{ checkCursor (c);
#ifndef INO_CHECKS
ICHECK (elementOps().keyOps.compare
(elementOps().key
(((Node const*)((Cursor const&)c).ivNode)->ivElement),
elementOps().key (e)) == 0,
IInvalidReplacementException, IInvalidReplacementText)
#endif
ivImpl.replaceAt (((Cursor const&)c).ivNode, &e);
}
template < class Element, class Key, class ElementOps >
inline void IGAvlKeySortedSet < Element, Key, ElementOps >::
removeAll ()
{ ivImpl.removeAll ();
}
template < class Element, class Key, class ElementOps >
inline IBoolean IGAvlKeySortedSet < Element, Key, ElementOps >::
isBounded () const
{ return ivImpl.isBounded ();
}
template < class Element, class Key, class ElementOps >
inline INumber IGAvlKeySortedSet < Element, Key, ElementOps >::
maxNumberOfElements () const
{ ICHECK (False, INotBoundedException,
INotBoundedText)
return 0;
}
template < class Element, class Key, class ElementOps >
inline INumber IGAvlKeySortedSet < Element, Key, ElementOps >::
numberOfElements () const
{ return ivImpl.numberOfElements ();
}
template < class Element, class Key, class ElementOps >
inline IBoolean IGAvlKeySortedSet < Element, Key, ElementOps >::
isEmpty () const
{ return ivImpl.isEmpty ();
}
template < class Element, class Key, class ElementOps >
inline IBoolean IGAvlKeySortedSet < Element, Key, ElementOps >::
isFull () const
{ return ivImpl.isFull ();
}
template < class Element, class Key, class ElementOps >
inline ICursor* IGAvlKeySortedSet < Element, Key, ElementOps >::
newCursor () const
{ ICursor* result = new Cursor (*this);
ICHECK (result != 0, IOutOfMemory, IOutOfMemoryText)
return result;
}
template < class Element, class Key, class ElementOps >
inline IBoolean IGAvlKeySortedSet < Element, Key, ElementOps >::
setToFirst (ICursor& c) const
{ checkCursorIsForThis (c);
return ivImpl.setToFirst (((Cursor&)c).ivNode);
}
template < class Element, class Key, class ElementOps >
inline IBoolean IGAvlKeySortedSet < Element, Key, ElementOps >::
setToNext (ICursor& c) const
{ checkCursor (c);
return ivImpl.setToNext (((Cursor&)c).ivNode);
}
template < class Element, class Key, class ElementOps >
inline IBoolean IGAvlKeySortedSet < Element, Key, ElementOps >::
allElementsDo (IBoolean (*iterationFunction) (Element const&, void*),
void* env) const
{ return ivImpl.allElementsDo (iterationFunction, env);
}
template < class Element, class Key, class ElementOps >
inline IBoolean IGAvlKeySortedSet < Element, Key, ElementOps >::
allElementsDo (IBoolean (*iterationFunction) (Element&, void*), void* env)
{ return ivImpl.allElementsDo (iterationFunction, env);
}
template < class Element, class Key, class ElementOps >
inline IBoolean IGAvlKeySortedSet < Element, Key, ElementOps >::
allElementsDo (IConstantIterator <Element>& iterator) const
{ return ivImpl.allElementsDo (&iterator);
}
template < class Element, class Key, class ElementOps >
inline IBoolean IGAvlKeySortedSet < Element, Key, ElementOps >::
allElementsDo (IIterator <Element>& iterator)
{ return ivImpl.allElementsDo (&iterator);
}
template < class Element, class Key, class ElementOps >
inline IBoolean IGAvlKeySortedSet < Element, Key, ElementOps >::
isConsistent () const
{ return ivImpl.isConsistent ();
}
template < class Element, class Key, class ElementOps >
inline Key const& IGAvlKeySortedSet < Element, Key, ElementOps >::
key (Element const& element) const
{ return elementOps().key (element);
}
template < class Element, class Key, class ElementOps >
inline IBoolean IGAvlKeySortedSet < Element, Key, ElementOps >::
containsElementWithKey (Key const& k) const
{ return ivImpl.containsElementWithKey (&k);
}
template < class Element, class Key, class ElementOps >
inline IBoolean IGAvlKeySortedSet < Element, Key, ElementOps >::
containsAllKeysFrom (IGAvlKeySortedSet < Element, Key, ElementOps > const& a) const
{ return ivImpl.containsAllKeysFrom (a.ivImpl);
}
template < class Element, class Key, class ElementOps >
inline IBoolean IGAvlKeySortedSet < Element, Key, ElementOps >::
locateElementWithKey (Key const& k, ICursor& c) const
{ checkCursorIsForThis (c);
return ivImpl.locateElementWithKey (&k, ((Cursor&)c).ivNode);
}
template < class Element, class Key, class ElementOps >
inline IBoolean IGAvlKeySortedSet < Element, Key, ElementOps >::
replaceElementWithKey (Element const& e)
{ return ivImpl.replaceElementWithKey (&e);
}
template < class Element, class Key, class ElementOps >
inline IBoolean IGAvlKeySortedSet < Element, Key, ElementOps >::
replaceElementWithKey (Element const& e, ICursor& c)
{ checkCursorIsForThis (c);
return ivImpl.replaceElementWithKey (&e,((Cursor&)c).ivNode);
}
template < class Element, class Key, class ElementOps >
inline IBoolean IGAvlKeySortedSet < Element, Key, ElementOps >::
addOrReplaceElementWithKey (Element const& e)
{ return ivImpl.addOrReplaceElementWithKey (&e);
}
template < class Element, class Key, class ElementOps >
inline IBoolean IGAvlKeySortedSet < Element, Key, ElementOps >::
addOrReplaceElementWithKey (Element const& e, ICursor& c)
{ checkCursorIsForThis (c);
return ivImpl.addOrReplaceElementWithKey (&e, ((Cursor&)c).ivNode);
}
template < class Element, class Key, class ElementOps >
inline IBoolean IGAvlKeySortedSet < Element, Key, ElementOps >::
locateOrAddElementWithKey (Element const& e)
{ return ivImpl.locateOrAddElementWithKey (&e);
}
template < class Element, class Key, class ElementOps >
inline IBoolean IGAvlKeySortedSet < Element, Key, ElementOps >::
locateOrAddElementWithKey (Element const& e, ICursor& c)
{ checkCursorIsForThis (c);
return ivImpl.locateOrAddElementWithKey (&e, ((Cursor&)c).ivNode);
}
template < class Element, class Key, class ElementOps >
inline IBoolean IGAvlKeySortedSet < Element, Key, ElementOps >::
removeElementWithKey (Key const& k)
{ return ivImpl.removeElementWithKey (&k);
}
template < class Element, class Key, class ElementOps >
inline Element const& IGAvlKeySortedSet < Element, Key, ElementOps >::
elementWithKey (Key const& k) const
{ return *(Element const*) ivImpl.elementWithKey (&k);
}
template < class Element, class Key, class ElementOps >
inline Element& IGAvlKeySortedSet < Element, Key, ElementOps >::
elementWithKey (Key const& k)
{ return *(Element*) ivImpl.elementWithKey (&k);
}
template < class Element, class Key, class ElementOps >
inline void IGAvlKeySortedSet < Element, Key, ElementOps >::
removeFirst ()
{ checkNotEmpty ();
ivImpl.removeFirst ();
}
template < class Element, class Key, class ElementOps >
inline void IGAvlKeySortedSet < Element, Key, ElementOps >::
removeLast ()
{ checkNotEmpty ();
ivImpl.removeLast ();
}
template < class Element, class Key, class ElementOps >
inline void IGAvlKeySortedSet < Element, Key, ElementOps >::
removeAtPosition (IPosition p)
{ checkPositionExists (p);
ivImpl.removeAtPosition (p);
}
template < class Element, class Key, class ElementOps >
inline Element const& IGAvlKeySortedSet < Element, Key, ElementOps >::
firstElement () const
{ checkNotEmpty ();
return *(Element const*) ivImpl.firstElement ();
}
template < class Element, class Key, class ElementOps >
inline Element const& IGAvlKeySortedSet < Element, Key, ElementOps >::
lastElement () const
{ checkNotEmpty ();
return *(Element const*) ivImpl.lastElement ();
}
template < class Element, class Key, class ElementOps >
inline Element const& IGAvlKeySortedSet < Element, Key, ElementOps >::
elementAtPosition (IPosition p) const
{ checkPositionExists (p);
return *(Element const*) ivImpl.elementAtPosition (p);
}
template < class Element, class Key, class ElementOps >
inline IBoolean IGAvlKeySortedSet < Element, Key, ElementOps >::
setToLast (ICursor& c) const
{ checkCursorIsForThis (c);
return ivImpl.setToLast (((Cursor&)c).ivNode);
}
template < class Element, class Key, class ElementOps >
inline IBoolean IGAvlKeySortedSet < Element, Key, ElementOps >::
setToPrevious (ICursor& c) const
{ checkCursor (c);
return ivImpl.setToPrevious (((Cursor&)c).ivNode);
}
template < class Element, class Key, class ElementOps >
inline void IGAvlKeySortedSet < Element, Key, ElementOps >::
setToPosition (IPosition p, ICursor& c) const
{ checkPositionExists (p);
checkCursorIsForThis (c);
ivImpl.setToPosition (p, ((Cursor&)c).ivNode);
}
template < class Element, class Key, class ElementOps >
inline IBoolean IGAvlKeySortedSet < Element, Key, ElementOps >::
isFirst (ICursor const& c) const
{ checkCursor (c);
return ivImpl.isFirst (((Cursor&)c).ivNode);
}
template < class Element, class Key, class ElementOps >
inline IBoolean IGAvlKeySortedSet < Element, Key, ElementOps >::
isLast (ICursor const& c) const
{ checkCursor (c);
return ivImpl.isLast (((Cursor&)c).ivNode);
}
template < class Element, class Key, class ElementOps >
inline long IGAvlKeySortedSet < Element, Key, ElementOps >::
compare (IGAvlKeySortedSet < Element, Key, ElementOps > const& collection,
long (*comparisonFunction)
(Element const&, Element const&)) const
{ return ivImpl.compare
(collection.ivImpl, comparisonFunction);
}