バナーをクリックすれば目次に戻ります
Copyright 1999 Rogue Wave Software
Copyright 1999 Sun Microsystems, Inc.
RWTPtrSortedVector<T,C>
#include <rw/tpsrtvec.h> RWTPtrSortedVector<T,C> srtvec;
注 - 標準 C++ ライブラリがある場合は、ここで述べるインタフェースを使用します。標準 C++ ライブラリがない場合は、付録 A に記載する RWTPtrSortedVector に限定されたインタフェースを使用してください。
C は、次の公開メンバーを介して、型 T の要素に対する全体的な順序付けを誘導しなければなりません。
bool operator()(const T& x, const T& y)これは、コレクション内において、x が y より前になる場合、TRUE を返します。C++ 標準ヘッダーファイル <functional> からの構造体 less<T> がその例です。コレクションの項目は比較前に間接参照されることに注意してください。
// // tpsrtvec.cpp // #include <rw/rwdate.h> #include <rw/tpsrtvec.h> #include <iostream.h> main(){ RWTPtrSortedVector<RWDate, greater<RWDate> > vec; vec.insert(new RWDate(10, "Aug", 1991)); vec.insert(new RWDate(9, "Aug", 1991)); vec.insert(new RWDate(1, "Sep", 1991)); vec.insert(new RWDate(14, "May", 1990)); vec.insert(new RWDate(1, "Sep", 1991)); // 複製を追加する vec.insert(new RWDate(2, "June", 1991)); for (int i=0; i<vec.entries(); i++) cout << *vec[i] << endl; vec.clearAndDestroy(); return 0; } |
09/01/91 09/01/91 08/10/91 08/09/91 06/02/91 05/14/90 |
クラス vector<T*,allocator> は、このクラスの基礎となる実装として使用される標準 C++ コレクションです。
typedef vector<T*,allocator> container_type; typedef rw_deref_compare<C,T> container_comp; typedef container_type::const_iterator const_iterator; typedef container_type::const_iterator iterator; typedef container_type::size_type size_type; typedef container_type::difference_type difference_type; typedef T* value_type; typedef T*& reference; typedef T* const& const_reference;
RWTPtrSortedVector<T,C>();
RWTPtrSortedVector<T,C>(const vector<T*,allocator>& vec);
RWTPtrSortedVector<T,C>(const RWTPtrSortedVector<T,C>& rwvec);
RWTPtrSortedVector<T,C>(size_type n, T* p);
RWTPtrSortedVector<T,C>(size_type n);
RWTPtrSortedVector<T,C>(T** first,T** last);
bool operator<(const RWTPtrSortedVector<T,C>& vec) const;
bool operator==(const RWTPtrSortedVector<T,C>& vec) const;
reference operator()(size_type i); const_reference operator()(size_type i) const;
reference operator[](size_type i); const_reference operator[](size_type i) const;
void apply(void (*fn)(T*,void*), void* d); void apply(void (*fn)(T*&,void*), void* d); void apply(void (*fn)(const T*,void*), void* d) const;
void yourfun(T* a, void* d); void yourfun(T*& a, void* d); void yourfun(const T* a, void* d);
reference at(size_type i); const_reference at(size_type i) const;
iterator begin(); const_iterator begin() 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* a, void* d);
T* const* data() const;
iterator end(); const_iterator end() const;
size_type entries() 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);
reference first(); const_reference first() const;
size_type index(const T* a) const;
size_type index(bool (*fn)(const T*,void*), void* d) const;
bool yourTester(const T* a, void* d);
bool insert(T* a);
size_type insert(const vector<T*,allocator>& a);
bool isEmpty() const;
bool isSorted() const;
T*& last(); T* const& last() const;
size_type length() const;
size_type merge(const RWTPtrSortedVector<T,C>& vec);
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);
T* removeAt(size_type i);
T* removeFirst();
T* removeLast();
void resize(size_type n);
const vector<T*,allocator>& std() const;
const size_type npos;
RWvostream& operator<<(RWvostream& strm, const RWTPtrSortedVector<T,C>& coll); RWFile& operator<<(RWFile& strm, const RWTPtrSortedVector<T,C>& coll);
RWvistream& operator>>(RWvistream& strm, RWTPtrSortedVector<T,C>& coll); RWFile& operator>>(RWFile& strm, RWTPtrSortedVector<T,C>& coll);
RWvistream& operator>>(RWvistream& strm, RWTPtrSortedVector<T,C>*& p); RWFile& operator>>(RWFile& strm, RWTPtrSortedVector<T,C>*& p);