home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
cset21v1.zip
/
IBMCPP
/
IBMCLASS
/
IHSHKB.IF
< prev
next >
Wrap
Text File
|
1993-09-22
|
14KB
|
394 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 IGHashKeyBag < Element, Key, ElementOps >::
checkNotEmpty () const
{
#ifndef INO_CHECKS
ICHECK (!isEmpty (), IEmptyException, ICollectionIsEmptyText)
#endif
}
template < class Element, class Key, class ElementOps >
inline void IGHashKeyBag < 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 IGHashKeyBag < 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 IGHashKeyBag < Element, Key, ElementOps >::
IGHashKeyBag (INumber n)
: ivImpl(n, &ivOps) {
}
template < class Element, class Key, class ElementOps >
inline IGHashKeyBag < Element, Key, ElementOps >::
IGHashKeyBag (IGHashKeyBag < Element, Key, ElementOps > const& h)
: ivImpl(h.ivImpl, &ivOps) {
}
template < class Element, class Key, class ElementOps >
inline IGHashKeyBag < Element, Key, ElementOps >::
~IGHashKeyBag () {
}
template < class Element, class Key, class ElementOps >
inline IBoolean IGHashKeyBag < Element, Key, ElementOps >::
add (Element const& e, ICursor& c)
{ return ivImpl.add
(&e,
elementOps().keyOps.hash(elementOps().key(e), ivImpl.noEntries()),
((Cursor&)c).ivImpl
);
}
template < class Element, class Key, class ElementOps >
inline IBoolean IGHashKeyBag < Element, Key, ElementOps >::
add (Element const& e)
{ return ivImpl.add
(&e,
elementOps().keyOps.hash(elementOps().key(e), ivImpl.noEntries())
);
}
template < class Element, class Key, class ElementOps >
inline void IGHashKeyBag < Element, Key, ElementOps >::
addAllFrom (IGHashKeyBag < Element, Key, ElementOps > const& h)
{
#ifndef INO_CHECKS
ICHECK (this != &h,
IIdenticalCollectionException, IIdenticalCollectionText)
#endif
ivImpl.addAllFrom(h.ivImpl);
}
template < class Element, class Key, class ElementOps >
inline IGHashKeyBag < Element, Key, ElementOps >&
IGHashKeyBag < Element, Key, ElementOps >::
operator = (IGHashKeyBag < Element, Key, ElementOps > const& h)
{ ivImpl = h.ivImpl;
return *this;
}
template < class Element, class Key, class ElementOps >
inline Element const& IGHashKeyBag < 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& IGHashKeyBag < 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& IGHashKeyBag < Element, Key, ElementOps >::
anyElement () const
{ checkNotEmpty();
return *(Element const*) ivImpl.anyElement();
}
template < class Element, class Key, class ElementOps >
inline void IGHashKeyBag < Element, Key, ElementOps >::
removeAt (ICursor const& c)
{ checkCursor(c);
ivImpl.removeAt(((Cursor&)c).ivImpl);
}
template < class Element, class Key, class ElementOps >
inline INumber IGHashKeyBag < 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 IGHashKeyBag < 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 IGHashKeyBag < Element, Key, ElementOps >::
removeAll ()
{ ivImpl.removeAll();
}
template < class Element, class Key, class ElementOps >
inline IBoolean IGHashKeyBag < Element, Key, ElementOps >::
isBounded () const
{ return ivImpl.isBounded();
}
template < class Element, class Key, class ElementOps >
inline INumber IGHashKeyBag < Element, Key, ElementOps >::
maxNumberOfElements () const
{ ICHECK (False, INotBoundedException,
INotBoundedText)
return 0;
}
template < class Element, class Key, class ElementOps >
inline INumber IGHashKeyBag < Element, Key, ElementOps >::
numberOfElements () const
{ return ivImpl.numberOfElements();
}
template < class Element, class Key, class ElementOps >
inline IBoolean IGHashKeyBag < Element, Key, ElementOps >::
isEmpty () const
{ return ivImpl.isEmpty();
}
template < class Element, class Key, class ElementOps >
inline IBoolean IGHashKeyBag < Element, Key, ElementOps >::
isFull () const
{ return ivImpl.isFull();
}
template < class Element, class Key, class ElementOps >
inline ICursor* IGHashKeyBag < 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 IGHashKeyBag < Element, Key, ElementOps >::
setToFirst (ICursor& c) const
{ checkCursorIsForThis(c);
return ivImpl.setToFirst(((Cursor&)c).ivImpl);
}
template < class Element, class Key, class ElementOps >
inline IBoolean IGHashKeyBag < Element, Key, ElementOps >::
setToNext (ICursor& c) const
{ checkCursor(c);
return ivImpl.setToNext(((Cursor&)c).ivImpl);
}
template < class Element, class Key, class ElementOps >
inline IBoolean IGHashKeyBag < 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 IGHashKeyBag < Element, Key, ElementOps >::
allElementsDo (IBoolean (*iterationFunction) (Element&, void*), void* env)
{ return ivImpl.allElementsDo (iterationFunction, env);
}
template < class Element, class Key, class ElementOps >
inline IBoolean IGHashKeyBag < Element, Key, ElementOps >::
allElementsDo (IConstantIterator <Element>& iterator) const
{ return ivImpl.allElementsDo (&iterator);
}
template < class Element, class Key, class ElementOps >
inline IBoolean IGHashKeyBag < Element, Key, ElementOps >::
allElementsDo (IIterator <Element>& iterator)
{ return ivImpl.allElementsDo (&iterator);
}
template < class Element, class Key, class ElementOps >
inline IBoolean IGHashKeyBag < Element, Key, ElementOps >::
isConsistent () const
{ return ivImpl.isConsistent ();
}
template < class Element, class Key, class ElementOps >
inline Key const& IGHashKeyBag < Element, Key, ElementOps >::
key (Element const& element) const
{ return elementOps().key (element);
}
template < class Element, class Key, class ElementOps >
inline IBoolean IGHashKeyBag < 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 IGHashKeyBag < Element, Key, ElementOps >::
containsAllKeysFrom (IGHashKeyBag < Element, Key, ElementOps > const& h) const
{ return ivImpl.containsAllKeysFrom(h.ivImpl);
}
template < class Element, class Key, class ElementOps >
inline IBoolean IGHashKeyBag < 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 IGHashKeyBag < 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 IGHashKeyBag < 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 IGHashKeyBag < 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 IGHashKeyBag < 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 IGHashKeyBag < 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 IGHashKeyBag < 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 IGHashKeyBag < 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& IGHashKeyBag < 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& IGHashKeyBag < Element, Key, ElementOps >::
elementWithKey (Key const& k)
{ return *(Element*) ivImpl.elementWithKey
(&k, elementOps().keyOps.hash(k, ivImpl.noEntries()));
}
template < class Element, class Key, class ElementOps >
inline INumber IGHashKeyBag < Element, Key, ElementOps >::
numberOfElementsWithKey (Key const& k) const
{ return ivImpl.numberOfElementsWithKey
(&k,
elementOps().keyOps.hash(k, ivImpl.noEntries())
);
}
template < class Element, class Key, class ElementOps >
inline IBoolean IGHashKeyBag < Element, Key, ElementOps >::
locateNextElementWithKey (Key const& k, ICursor& c) const
{ checkCursor(c);
return ivImpl.locateNextElementWithKey
(&k,
elementOps().keyOps.hash(k, ivImpl.noEntries()),
((Cursor&)c).ivImpl
);
}
template < class Element, class Key, class ElementOps >
inline INumber IGHashKeyBag < Element, Key, ElementOps >::
removeAllElementsWithKey (Key const& k)
{ return ivImpl.removeAllElementsWithKey
(&k, elementOps().keyOps.hash(k, ivImpl.noEntries()));
}
template < class Element, class Key, class ElementOps >
inline INumber IGHashKeyBag < Element, Key, ElementOps >::
numberOfDifferentKeys() const
{ return ivImpl.numberOfDifferentKeys ();
}
template < class Element, class Key, class ElementOps >
inline IBoolean IGHashKeyBag < Element, Key, ElementOps >::
setToNextWithDifferentKey (ICursor& c) const
{ checkCursor(c);
return ivImpl.setToNextWithDifferentKey (((Cursor&)c).ivImpl);
}