バナーをクリックすれば目次に戻ります
Copyright 1999 Rogue Wave Software
Copyright 1999 Sun Microsystems, Inc.
RWTPtrHashSet<T,H,EQ>
#include <rw/tphset.h> RWTPtrHashSet<T,H,EQ> s;
注 - 標準 C++ ライブラリがある場合は、ここで述べるインタフェースを使用します。標準 C++ ライブラリがない場合は、付録 A に記載する RWTPtrHashSet に制限されたインタフェースを使用してください。
unsigned long operator()(const T& x)コレクション中のオブジェクトは、型 EQ の同等オブジェクトにもとづいてグループ化されます。EQ は、次の公開メンバーを介して、このグループ化を保証しなければなりません。
bool operator()(const T& x, const T& y)これは、x と y が等しい場合に TRUE を返し、それ以外の場合は FALSE を返します。
RWTPtrHashSet<T,H,EQ> は、コレクション内の既存の項目と等しい項目は受け付けません (RWTPtrHashMultiSet<T,H,EQ> には、互いに等しい複数の項目を含めることができます)。等しいかどうかは、== 演算子ではなく、同等オブジェクトにもとづいて判定されます。
// // tphset2.cpp // #include <rw/tphset.h> #include <rw/cstring.h> #include <iostream.h> struct silly_hash{ unsigned long operator()(RWCString x) const { return x.length() * (long)x(0); } }; main(){ RWTPtrHashSet<RWCString,silly_hash,equal_to<RWCString> > set1; RWTPtrHashSet<RWCString,silly_hash,equal_to<RWCString> > set2; set1.insert(new RWCString("one")); set1.insert(new RWCString("two")); set1.insert(new RWCString("three")); set1.insert(new RWCString("one")); // 二重挿入が拒絶された cout << set1.entries() << endl; // 「3」を出力する set2 = set1; cout << ((set1.isEquivalent(set2)) ? "TRUE" : "FALSE") << endl; // 「TRUE」を出力する set2.difference(set1); set1.clearAndDestroy(); cout << set1.entries() << endl; // 「0」を出力する cout << set2.entries() << endl; // 「0」を出力する return 0; } |
クラス rw_hashset<T*,rw_deref_hash<H,T>, rw_deref_compare<EQ,T>> は、RWTPtrHashSet<T,H,EQ> の基礎となる実装として使用される C++ 標準コレクションです。
typedef rw_deref_compare<EQ,T> container_eq; typedef rw_deref_hash<H,T> container_hash; typedef rw_hashset<T*,container_hash, container_eq> container_type; typedef container_type::size_type size_type; typedef container_type::difference_type difference_type; typedef container_type::iterator iterator; typedef container_type::const_iterator const_iterator; typedef T* value_type; typedef T* const& reference; typedef T* const& const_reference;
RWTPtrHashSet<T,H,EQ> (size_type sz=1024,const H& h = H(),const EQ& eq = EQ());
RWTPtrHashSet<T,H,EQ>(const RWTPtrHashSet<T,H,EQ>& rws);
RWTPtrHashSet<T,H,EQ> (const H& h,size_type sz = RWDEFAULT_CAPACITY);
RWTPtrHashSet<T,H,EQ> (const rw_hashset<T*,container_hash,container_eq>& s);
RWTPtrHashSet<T,H,EQ>(T*const* first,T*const* last, size_type sz=1024,const H& h = H(),const EQ& eq = EQ());
RWTPtrHashSet<T,H,EQ>& operator=(const RWTPtrHashSet<T,H,EQ>& s);
bool operator==(const RWTPtrHashSet<T,H,EQ>& s) const;
void apply(void (*fn)(const T*,void*), void* d) const;
void yourfun(const T* a, void* d);
iterator begin(); const_iterator begin() const;
size_type capacity() const;
void clear();
void clearAndDestroy();
bool contains(const T* a) const;
bool contains(bool (*fn)(const T*,void*), void* d) const;
bool yourTester(const T*,void*), void* d) const;
void difference(const RWTPtrHashSet<T,H,EQ>& s);
iterator end(); const_iterator end() const;
size_type entries() const;
float fillRatio() const;
const T* find(const T* a) const;
const T* find(bool (*fn)(const T*,void*), void* d) const;
bool yourTester(const T* a, void* d);
bool insert(T* a);
void intersection(const RWTPtrHashSet<T,H,EQ>& s);
bool isEmpty() const;
bool isEquivalent(const RWTPtrHashSet<T,H,EQ>& s) const;
bool isProperSubsetOf(const RWTPtrHashSet<T,H,EQ>& s) const;
bool isSubsetOf(const RWTPtrHashSet<T,H,EQ>& s) const;
size_type occurrencesOf(const T* a) const;
size_type occurrencesOf(bool (*fn)(const T*,void*), void* d) const;
bool yourTester(const T* a, void* d);
T* remove(const T* a);
T* remove(bool (*fn)(const T*,void*), void* d);
bool yourTester(const T* a, void* d);
size_type removeAll(const T* a);
size_type removeAll(bool (*fn)(const T*,void*), void* d);
bool yourTester(const T* a, void* d);
void resize(size_type sz);
rw_hashset<T*,container_hash, container_eq>& std(); const rw_hashset<T*,container_hash, container_eq>& std() const;
void symmetricDifference(const RWTPtrHashSet<T,H,EQ>& s);
void Union(const RWTPtrHashSet<T,H,EQ>& s);
RWvostream& operator<<(RWvostream& strm, const RWTPtrHashSet<T,H,EQ>& coll); RWFile& operator<<(RWFile& strm, const RWTPtrHashSet<T,H,EQ>& coll);
RWvistream& operator>>(RWvistream& strm, RWTPtrHashSet<T,H,EQ>& coll); RWFile& operator>>(RWFile& strm, RWTPtrHashSet<T,H,EQ>& coll);
RWvistream& operator>>(RWvistream& strm, RWTPtrHashSet<T,H,EQ>*& p); RWFile& operator>>(RWFile& strm, RWTPtrHashSet<T,H,EQ>*& p);