home *** CD-ROM | disk | FTP | other *** search
- /**********************************************************************
- * *
- * IBM(R) VisualAge(TM) for C++ for Windows(R), Version 3.5 *
- * *
- * PID: 5622-880 *
- * - Licensed Material - Program-Property of IBM *
- * (C) Copyright IBM Corp. 1991, 1995 - All Right Reserved. *
- * *
- * US Government Users Restricted Rights - Use, duplication or *
- * disclosure restricted by GSA ADP Schedule Contract with IBM Corp. *
- * *
- * VisualAge, and IBM are trademarks or registered trademarks of *
- * International Business Machines Corporation. *
- * Windows is a registered trademark of Microsoft Corporation. *
- * *
- **********************************************************************/
-
- #include <new.h>
-
- #pragma info (nocls, nocnd, nocns, nocnv, noext, nognr, novft)
- #pragma pack (4)
-
- // --------------------
- // IKeyBagAsHshTableOps
- // --------------------
-
- // public members
-
- template <class Element, class Key,
- class ElementOps, class Implementation>
- IKeyBagAsHshTableOps <Element, Key, ElementOps, Implementation>::
- IKeyBagAsHshTableOps (INumber numberOfElements)
- : Inherited (__isDTSClass (Element)),
- ivElementOps (),
- ivImpl (*this, numberOfElements)
- {
- }
-
- template <class Element, class Key,
- class ElementOps, class Implementation>
- IKeyBagAsHshTableOps <Element, Key, ElementOps, Implementation>::
- IKeyBagAsHshTableOps (INumber numberOfElements, void* opsArg)
- : Inherited (__isDTSClass (Element)),
- ivElementOps (opsArg),
- ivImpl (*this, numberOfElements)
- {
- }
-
- template <class Element, class Key,
- class ElementOps, class Implementation>
- IKeyBagAsHshTableOps <Element, Key, ElementOps, Implementation>::
- IKeyBagAsHshTableOps
- (IKeyBagAsHshTableOps
- <Element, Key, ElementOps, Implementation> const& collection)
- : Inherited (__isDTSClass (Element)),
- ivElementOps (collection.ivElementOps),
- ivImpl (*this, collection.ivImpl)
- {
- }
-
- template <class Element, class Key,
- class ElementOps, class Implementation>
- IKeyBagAsHshTableOps <Element, Key, ElementOps, Implementation>::
- ~IKeyBagAsHshTableOps ()
- {
- }
-
- template <class Element, class Key,
- class ElementOps, class Implementation>
- void
- IKeyBagAsHshTableOps <Element, Key, ElementOps, Implementation>::
- Assign (void* element1, void const* element2) const
- { ivElementOps.Assign (*(Element*)element1,
- *(Element const*)element2);
- }
-
- template <class Element, class _Key,
- class ElementOps, class Implementation>
- IACollectionImpl*
- IKeyBagAsHshTableOps <Element, _Key, ElementOps, Implementation>::
- Clone () const
- { return (Implementation*) *new Self (*this);
- }
-
- template <class Element, class Key,
- class ElementOps, class Implementation>
- void*
- IKeyBagAsHshTableOps <Element, Key, ElementOps, Implementation>::
- CreateNode (void const* element) const
- { void* node = ivElementOps.Allocate (sizeof (Node)
- #if defined (__DEBUG_ALLOC__)
- , __FILE__, __LINE__
- #endif
- );
- return new (ivImpl.CheckPointer (node))
- Node (*(Element const*)element);
- }
-
- template <class Element, class Key,
- class ElementOps, class Implementation>
- void*
- IKeyBagAsHshTableOps <Element, Key, ElementOps, Implementation>::
- CreateNodes (INumber n) const
- { return ivElementOps.Allocate ((size_t) (sizeof (Node*) * n)
- #if defined (__DEBUG_ALLOC__)
- , __FILE__, __LINE__
- #endif
- );
- }
-
- template <class Element, class Key,
- class ElementOps, class Implementation>
- void
- IKeyBagAsHshTableOps <Element, Key, ElementOps, Implementation>::
- DeleteNode (void* node) const
- { ((Node*)node)->~Node ();
- ivElementOps.Deallocate (node
- #if defined (__DEBUG_ALLOC__)
- , __FILE__, __LINE__
- #endif
- );
- }
-
- template <class Element, class Key,
- class ElementOps, class Implementation>
- void
- IKeyBagAsHshTableOps <Element, Key, ElementOps, Implementation>::
- DeleteNodes (void* nodes) const
- { ivElementOps.Deallocate (nodes
- #if defined (__DEBUG_ALLOC__)
- , __FILE__, __LINE__
- #endif
- );
- }
-
- template <class Element, class _Key,
- class ElementOps, class Implementation>
- IBoolean
- IKeyBagAsHshTableOps <Element, _Key, ElementOps, Implementation>::
- EqualKeys (void const* arg1, void const* arg2, IArgType argType) const
- { IBoolean result;
- switch (argType) {
- case kElementElement: {
- result = ivElementOps.keyOps.Equal
- (ivElementOps.Key (*(Element const*)arg1),
- ivElementOps.Key (*(Element const*)arg2));
- break;
- }
- case kElementKey: {
- result = ivElementOps.keyOps.Equal
- (ivElementOps.Key (*(Element const*)arg1),
- IKeyForOps ((_Key const*)arg2));
- break;
- }
- case kKeyKey: {
- result = ivElementOps.keyOps.Equal
- (IKeyForOps ((_Key const*)arg1),
- IKeyForOps ((_Key const*)arg2));
- break;
- }
-
- }
- return result;
- }
-
- template <class Element, class _Key,
- class ElementOps, class Implementation>
- unsigned long
- IKeyBagAsHshTableOps <Element, _Key, ElementOps, Implementation>::
- HashKey (void const* arg, unsigned long h, IArgType argType) const
- { unsigned long hashValue;
- switch (argType) {
- case kElement: {
- hashValue = ivElementOps.keyOps.Hash
- (ivElementOps.Key (*(Element const*)arg), h);
- break;
- }
- case kKey: {
- hashValue = ivElementOps.keyOps.Hash
- (IKeyForOps ((_Key const*)arg), h);
- break;
- }
- }
- return hashValue;
- }
-
- template <class Element, class _Key,
- class ElementOps, class Implementation>
- void*
- IKeyBagAsHshTableOps <Element, _Key, ElementOps, Implementation>::
- Key (void const* element) const
- { return IKeyFromOps (ivElementOps.Key (*(Element const*)element));
- }
-
- template <class Element, class Key,
- class ElementOps, class Implementation>
- void*
- IKeyBagAsHshTableOps <Element, Key, ElementOps, Implementation>::
- StreamIn (TStream& fromWhere) const
- { Element* element = ivElementOps.GetStreamable ();
- ivElementOps.StreamIn (*element, fromWhere);
- return (void*) element;
- }
-
- template <class Element, class Key,
- class ElementOps, class Implementation>
- void
- IKeyBagAsHshTableOps <Element, Key, ElementOps, Implementation>::
- StreamOut (void const* element, TStream& toWhere) const
- { ivElementOps.StreamOut (*(Element const*)element, toWhere);
- }
-
- template <class Element, class Key,
- class ElementOps, class Implementation>
- TStream&
- IKeyBagAsHshTableOps <Element, Key, ElementOps, Implementation>::
- operator<<= (TStream& fromWhere)
- { return (ivElementOps <<= fromWhere);
- }
-
- template <class Element, class Key,
- class ElementOps, class Implementation>
- TStream&
- IKeyBagAsHshTableOps <Element, Key, ElementOps, Implementation>::
- operator>>= (TStream& toWhere) const
- { return (ivElementOps >>= toWhere);
- }
-
- template <class Element, class Key,
- class ElementOps, class Implementation>
- IKeyBagAsHshTableOps <Element, Key, ElementOps, Implementation>::
- operator Implementation* ()
- { ivImpl.CheckPointer (this);
- return &ivImpl;
- }
-
- #pragma info (restore)
- #pragma pack ()
-