home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-04-21 | 5.3 KB | 178 lines | [TEXT/MPS ] |
- // The C++ Booch Components (Version 2.1)
- // (C) Copyright 1990-1993 Grady Booch. All Rights Reserved.
- //
- // Restricted Rights Legend
- // Use, duplication, or disclosure is subject to restrictions as set forth
- // in subdivision (c)(1)(ii) of the Rights in Technical Data and Computer
- // Software clause at DFARS 252.227-7013.
- //
- // BCSetU.cpp
- //
- // This file contains the definitions for the unbounded set.
-
- #include "BCSetU.h"
-
- template<class Item, BC_Index Buckets, class StorageManager>
- BC_TUnboundedSet<Item, Buckets, StorageManager>::BC_TUnboundedSet() {}
-
- template<class Item, BC_Index Buckets, class StorageManager>
- BC_TUnboundedSet<Item, Buckets, StorageManager>::
- BC_TUnboundedSet(BC_Index (*hash)(const Item&))
- : fRep(hash) {}
-
- template<class Item, BC_Index Buckets, class StorageManager>
- BC_TUnboundedSet<Item, Buckets, StorageManager>::
- BC_TUnboundedSet(const BC_TUnboundedSet<Item, Buckets, StorageManager>& s)
- : fRep(s.fRep) {}
-
- template<class Item, BC_Index Buckets, class StorageManager>
- BC_TUnboundedSet<Item, Buckets, StorageManager>::~BC_TUnboundedSet() {}
-
- template<class Item, BC_Index Buckets, class StorageManager>
- BC_TSet<Item>& BC_TUnboundedSet<Item, Buckets, StorageManager>::
- operator=(const BC_TSet<Item>& s)
- {
- return BC_TSet<Item>::operator=(s);
- }
-
- template<class Item, BC_Index Buckets, class StorageManager>
- BC_TSet<Item>& BC_TUnboundedSet<Item, Buckets, StorageManager>::
- operator=(const BC_TUnboundedSet<Item, Buckets, StorageManager>& s)
- {
- fRep = s.fRep;
- return *this;
- }
-
- template<class Item, BC_Index Buckets, class StorageManager>
- BC_Boolean BC_TUnboundedSet<Item, Buckets, StorageManager>::
- operator==(const BC_TSet<Item>& s) const
- {
- return BC_TSet<Item>::operator==(s);
- }
-
- template<class Item, BC_Index Buckets, class StorageManager>
- BC_Boolean BC_TUnboundedSet<Item, Buckets, StorageManager>::
- operator==(const BC_TUnboundedSet<Item, Buckets, StorageManager>& s) const
- {
- return (fRep == s.fRep);
- }
-
- template<class Item, BC_Index Buckets, class StorageManager>
- BC_Boolean BC_TUnboundedSet<Item, Buckets, StorageManager>::
- operator!=(const BC_TUnboundedSet<Item, Buckets, StorageManager>& s) const
- {
- return !operator==(s);
- }
-
- template<class Item, BC_Index Buckets, class StorageManager>
- void BC_TUnboundedSet<Item, Buckets, StorageManager>::
- SetHashFunction(BC_Index (*hash)(const Item&))
- {
- fRep.SetHashFunction(hash);
- }
-
- template<class Item, BC_Index Buckets, class StorageManager>
- void BC_TUnboundedSet<Item, Buckets, StorageManager>::Clear()
- {
- fRep.Clear();
- }
-
- template<class Item, BC_Index Buckets, class StorageManager>
- BC_Boolean BC_TUnboundedSet<Item, Buckets, StorageManager>::Add(const Item& item)
- {
- return fRep.Bind(item, 1);
- }
-
- template<class Item, BC_Index Buckets, class StorageManager>
- BC_Boolean BC_TUnboundedSet<Item, Buckets, StorageManager>::Remove(const Item& item)
- {
- return fRep.Unbind(item);
- }
-
- template<class Item, BC_Index Buckets, class StorageManager>
- BC_Index BC_TUnboundedSet<Item, Buckets, StorageManager>::Extent() const
- {
- return fRep.Extent();
- }
-
- template<class Item, BC_Index Buckets, class StorageManager>
- BC_Boolean BC_TUnboundedSet<Item, Buckets, StorageManager>::IsEmpty() const
- {
- return (fRep.Extent() == 0);
- }
-
- template<class Item, BC_Index Buckets, class StorageManager>
- BC_Boolean BC_TUnboundedSet<Item, Buckets, StorageManager>::IsMember(const Item& item) const
- {
- return fRep.IsBound(item);
- }
-
- template<class Item, BC_Index Buckets, class StorageManager>
- void* BC_TUnboundedSet<Item, Buckets, StorageManager>::operator new(size_t s)
- {
- return StorageManager::Allocate(s);
- }
-
- template<class Item, BC_Index Buckets, class StorageManager>
- void BC_TUnboundedSet<Item, Buckets, StorageManager>::operator delete(void* p, size_t s)
- {
- StorageManager::Deallocate(p, s);
- }
-
- template<class Item, BC_Index Buckets, class StorageManager>
- void BC_TUnboundedSet<Item, Buckets, StorageManager>::Purge()
- {
- fRep.Clear();
- }
-
- template<class Item, BC_Index Buckets, class StorageManager>
- BC_Boolean BC_TUnboundedSet<Item, Buckets, StorageManager>::
- Attach(const Item& item, const BC_Boolean& value)
- {
- return BC_TSet<Item>::Attach(item, value);
- }
-
- template<class Item, BC_Index Buckets, class StorageManager>
- BC_Boolean BC_TUnboundedSet<Item, Buckets, StorageManager>::Attach(const Item& item)
- {
- return fRep.Bind(item, 1);
- }
-
- template<class Item, BC_Index Buckets, class StorageManager>
- BC_Boolean BC_TUnboundedSet<Item, Buckets, StorageManager>::Detach(const Item& item)
- {
- return fRep.Unbind(item);
- }
-
- template<class Item, BC_Index Buckets, class StorageManager>
- BC_Index BC_TUnboundedSet<Item, Buckets, StorageManager>::Cardinality() const
- {
- return fRep.Extent();
- }
-
- template<class Item, BC_Index Buckets, class StorageManager>
- BC_Index BC_TUnboundedSet<Item, Buckets, StorageManager>::NumberOfBuckets() const
- {
- return Buckets;
- }
-
- template<class Item, BC_Index Buckets, class StorageManager>
- BC_Index BC_TUnboundedSet<Item, Buckets, StorageManager>::Length(BC_Index bucket) const
- {
- return fRep.Bucket(bucket)->Length();
- }
-
- template<class Item, BC_Index Buckets, class StorageManager>
- BC_Boolean BC_TUnboundedSet<Item, Buckets, StorageManager>::
- Exists(const Item& item) const
- {
- return fRep.IsBound(item);
- }
-
- template<class Item, BC_Index Buckets, class StorageManager>
- const Item& BC_TUnboundedSet<Item, Buckets, StorageManager>::
- ItemAt(BC_Index bucket, BC_Index index) const
- {
- return (*fRep.Bucket(bucket))[index].fItem;
- }
-