home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
cset21v1.zip
/
IBMCPP
/
IBMCLASS
/
IHSHKS.IF
< prev
next >
Wrap
Text File
|
1993-09-22
|
12KB
|
348 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 IGHashKeySet < Element, Key, ElementOps >::
checkNotEmpty () const
{
#ifndef INO_CHECKS
ICHECK (!isEmpty (), IEmptyException, ICollectionIsEmptyText)
#endif
}
template < class Element, class Key, class ElementOps >
inline void IGHashKeySet < 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 IGHashKeySet < 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.checkCursor(((Cursor const&)c).ivImpl),
ICursorInvalidException, ICursorNotContainedText)
#endif
}
template < class Element, class Key, class ElementOps >
inline IGHashKeySet < Element, Key, ElementOps >::
IGHashKeySet (INumber n)
: ivImpl(n, &ivOps) {
}
template < class Element, class Key, class ElementOps >
inline IGHashKeySet < Element, Key, ElementOps >::
IGHashKeySet (IGHashKeySet < Element, Key, ElementOps > const& h)
: ivImpl(h.ivImpl, &ivOps) {
}
template < class Element, class Key, class ElementOps >
inline IGHashKeySet < Element, Key, ElementOps >::
~IGHashKeySet () {
}
template < class Element, class Key, class ElementOps >
inline IBoolean IGHashKeySet < Element, Key, ElementOps >::
add (Element const& e, ICursor& c)
{ return ! locateOrAddElementWithKey (e, c);
}
template < class Element, class Key, class ElementOps >
inline IBoolean IGHashKeySet < Element, Key, ElementOps >::
add (Element const& e)
{ return ! locateOrAddElementWithKey (e);
}
template < class Element, class Key, class ElementOps >
inline void IGHashKeySet < Element, Key, ElementOps >::
addAllFrom (IGHashKeySet < Element, Key, ElementOps > const& h)
{
#ifndef INO_CHECKS
ICHECK (this != &h,
IIdenticalCollectionException, IIdenticalCollectionText)
#endif
Cursor cursor (h);
forCursor (cursor) add (h.elementAt (cursor));
};
template < class Element, class Key, class ElementOps >
inline IGHashKeySet < Element, Key, ElementOps >&
IGHashKeySet < Element, Key, ElementOps >::
operator = (IGHashKeySet < Element, Key, ElementOps > const& h)
{ ivImpl = h.ivImpl;
return *this;
}
template < class Element, class Key, class ElementOps >
inline Element const& IGHashKeySet < Element, Key, ElementOps >::
elementAt (ICursor const& c) const
{ checkCursor(c);
return *(Element const*) ivImpl.elementAt(((Cursor const&)c).ivImpl);
}
template < class Element, class Key, class ElementOps >
inline Element& IGHashKeySet < Element, Key, ElementOps >::
elementAt (ICursor const& c)
{ checkCursor(c);
return *(Element*) ivImpl.elementAt(((Cursor const&)c).ivImpl);
}
template < class Element, class Key, class ElementOps >
inline Element const& IGHashKeySet < Element, Key, ElementOps >::
anyElement () const
{ checkNotEmpty();
return *(Element const*) ivImpl.anyElement();
}
template < class Element, class Key, class ElementOps >
inline void IGHashKeySet < Element, Key, ElementOps >::
removeAt (ICursor const& c)
{ checkCursor(c);
ivImpl.removeAt(((Cursor&)c).ivImpl);
}
template < class Element, class Key, class ElementOps >
inline INumber IGHashKeySet < 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 IGHashKeySet < Element, Key, ElementOps >::
replaceAt (ICursor const& c, Element const& e)
{ checkCursor(c);
#ifndef INO_CHECKS
ICHECK (elementOps().keyOps.equal
(elementOps().key
(((Node const*)((Cursor const&)c).ivImpl.ivNode)->ivElement),
elementOps().key (e)),
IInvalidReplacementException, IInvalidReplacementText)
#endif
ivImpl.replaceAt(((Cursor const&)c).ivImpl, &e);
}
template < class Element, class Key, class ElementOps >
inline void IGHashKeySet < Element, Key, ElementOps >::
removeAll ()
{ ivImpl.removeAll();
}
template < class Element, class Key, class ElementOps >
inline IBoolean IGHashKeySet < Element, Key, ElementOps >::
isBounded () const
{ return ivImpl.isBounded();
}
template < class Element, class Key, class ElementOps >
inline INumber IGHashKeySet < Element, Key, ElementOps >::
maxNumberOfElements () const
{ ICHECK (False, INotBoundedException,
INotBoundedText)
return 0;
}
template < class Element, class Key, class ElementOps >
inline INumber IGHashKeySet < Element, Key, ElementOps >::
numberOfElements () const
{ return ivImpl.numberOfElements();
}
template < class Element, class Key, class ElementOps >
inline IBoolean IGHashKeySet < Element, Key, ElementOps >::
isEmpty () const
{ return ivImpl.isEmpty();
}
template < class Element, class Key, class ElementOps >
inline IBoolean IGHashKeySet < Element, Key, ElementOps >::
isFull () const
{ return ivImpl.isFull();
}
template < class Element, class Key, class ElementOps >
inline ICursor* IGHashKeySet < 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 IGHashKeySet < Element, Key, ElementOps >::
setToFirst (ICursor& c) const
{ checkCursorIsForThis(c);
return ivImpl.setToFirst(((Cursor&)c).ivImpl);
}
template < class Element, class Key, class ElementOps >
inline IBoolean IGHashKeySet < Element, Key, ElementOps >::
setToNext (ICursor& c) const
{ checkCursor(c);
return ivImpl.setToNext(((Cursor&)c).ivImpl);
}
template < class Element, class Key, class ElementOps >
inline IBoolean IGHashKeySet < 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 IGHashKeySet < Element, Key, ElementOps >::
allElementsDo (IBoolean (*iterationFunction) (Element&, void*), void* env)
{ return ivImpl.allElementsDo (iterationFunction, env);
}
template < class Element, class Key, class ElementOps >
inline IBoolean IGHashKeySet < Element, Key, ElementOps >::
allElementsDo (IConstantIterator <Element>& iterator) const
{ return ivImpl.allElementsDo (&iterator);
}
template < class Element, class Key, class ElementOps >
inline IBoolean IGHashKeySet < Element, Key, ElementOps >::
allElementsDo (IIterator <Element>& iterator)
{ return ivImpl.allElementsDo (&iterator);
}
template < class Element, class Key, class ElementOps >
inline IBoolean IGHashKeySet < Element, Key, ElementOps >::
isConsistent () const
{ return ivImpl.isConsistent ();
}
template < class Element, class Key, class ElementOps >
inline Key const& IGHashKeySet < Element, Key, ElementOps >::
key (Element const& element) const
{ return elementOps().key (element);
}
template < class Element, class Key, class ElementOps >
inline IBoolean IGHashKeySet < Element, Key, ElementOps >::
containsElementWithKey (Key const& k) const
{ return ivImpl.containsElementWithKey
(&k,
elementOps().keyOps.hash(k, ivImpl.noEntries())
);
}
template < class Element, class Key, class ElementOps >
inline IBoolean IGHashKeySet < Element, Key, ElementOps >::
containsAllKeysFrom (IGHashKeySet < Element, Key, ElementOps > const& h) const
{ return ivImpl.containsAllKeysFrom(h.ivImpl);
}
template < class Element, class Key, class ElementOps >
inline IBoolean IGHashKeySet < Element, Key, ElementOps >::
locateElementWithKey (Key const& k, ICursor& c) const
{ checkCursorIsForThis(c);
return ivImpl.locateElementWithKey
(&k,
elementOps().keyOps.hash(k, ivImpl.noEntries()),
((Cursor&)c).ivImpl
);
}
template < class Element, class Key, class ElementOps >
inline IBoolean IGHashKeySet < Element, Key, ElementOps >::
replaceElementWithKey (Element const& e, ICursor& c)
{ checkCursorIsForThis(c);
return ivImpl.replaceElementWithKey
(&e,
elementOps().keyOps.hash((elementOps().key(e)), ivImpl.noEntries()),
((Cursor&)c).ivImpl
);
}
template < class Element, class Key, class ElementOps >
inline IBoolean IGHashKeySet < Element, Key, ElementOps >::
replaceElementWithKey (Element const& e)
{ return ivImpl.replaceElementWithKey
(&e,
elementOps().keyOps.hash((elementOps().key(e)), ivImpl.noEntries())
);
}
template < class Element, class Key, class ElementOps >
inline IBoolean IGHashKeySet < Element, Key, ElementOps >::
locateOrAddElementWithKey (Element const& e, ICursor& c)
{ checkCursorIsForThis(c);
return ivImpl.locateOrAddElementWithKey
(&e,
elementOps().keyOps.hash((elementOps().key(e)), ivImpl.noEntries()),
((Cursor&)c).ivImpl
);
}
template < class Element, class Key, class ElementOps >
inline IBoolean IGHashKeySet < Element, Key, ElementOps >::
locateOrAddElementWithKey (Element const& e)
{ return ivImpl.locateOrAddElementWithKey
(&e,
elementOps().keyOps.hash((elementOps().key(e)), ivImpl.noEntries())
);
}
template < class Element, class Key, class ElementOps >
inline IBoolean IGHashKeySet < Element, Key, ElementOps >::
addOrReplaceElementWithKey (Element const& e, ICursor& c)
{ checkCursorIsForThis(c);
return ivImpl.addOrReplaceElementWithKey
(&e,
elementOps().keyOps.hash((elementOps().key(e)), ivImpl.noEntries()),
((Cursor&)c).ivImpl
);
}
template < class Element, class Key, class ElementOps >
inline IBoolean IGHashKeySet < Element, Key, ElementOps >::
addOrReplaceElementWithKey (Element const& e)
{ return ivImpl.addOrReplaceElementWithKey
(&e,
elementOps().keyOps.hash((elementOps().key(e)), ivImpl.noEntries())
);
}
template < class Element, class Key, class ElementOps >
inline IBoolean IGHashKeySet < Element, Key, ElementOps >::
removeElementWithKey (Key const& k)
{ return ivImpl.removeElementWithKey
(&k, elementOps().keyOps.hash(k, ivImpl.noEntries()));
}
template < class Element, class Key, class ElementOps >
inline Element const& IGHashKeySet < Element, Key, ElementOps >::
elementWithKey (Key const& k) const
{ return *(Element const*) ivImpl.elementWithKey
(&k, elementOps().keyOps.hash(k, ivImpl.noEntries()));
}
template < class Element, class Key, class ElementOps >
inline Element& IGHashKeySet < Element, Key, ElementOps >::
elementWithKey (Key const& k)
{ return *(Element*) ivImpl.elementWithKey
(&k, elementOps().keyOps.hash(k, ivImpl.noEntries()));
}