RWTPtrSet man page on IRIX

Man page or keyword search:  
man Server   31559 pages
apropos Keyword Search (all sections)
Output format
IRIX logo
[printable version]



RWTPtrSet(3C++)						       RWTPtrSet(3C++)

Name
     RWTPtrSet<T,C> - Rogue Wave library class

Synopsis
	      #include <rw/tpset.h>
	  RWTPtrSet<T,C> s;

Standard C++ Library Dependent!

     RWTPtrSet requires the Standard C++ Library.

Description
     This class maintains a pointer-based collection of values, which are
     ordered according to a comparison object of type C.  Class T is the type
     pointed to by the items in the collection. C must induce a total ordering
     on elements of type T via a public member

	      bool operator()(const T& x, const T& y)

     which returns true if x should precede y within the collection. The
     structure less<T> from the C++-standard header file <functional> is an
     example.  Note that items in the collection will be dereferenced before
     being compared.  RWTPtrSet<T,C> will not accept an item that compares
     equal to an item already in the collection.  (RWTPtrMultiSet<T,C> may
     contain multiple items that compare equal to each other.)	Equality is
     based on the comparison object and not on the == operator.	 Given a
     comparison object comp, items a and b are equal if

		   !comp(a,b) && !comp(b,a).

Persistence

     Isomorphic.

Examples
     In this example, a pointer-based set of RWCStrings is exercised.

									Page 1

RWTPtrSet(3C++)						       RWTPtrSet(3C++)

	      //

	      //tpset.cpp
	  //
	  #include <rw/tpset.h>
	  #include <rw/cstring.h>
	  #include <iostream.h>
	  #include <function.h>
	  main(){
	    RWTPtrSet<RWCString, less<RWCString> > set;
	    set.insert(new RWCString("one"));
	    set.insert(new RWCString("two"));
	    set.insert(new RWCString("three"));
	    set.insert(new RWCString("one"));  // Rejected: duplicate entry
	    cout << set.entries() << endl;   // Prints "3"
	    set.clearAndDestroy();
	    cout << set.entries() << endl;   // Prints "0"
	    return 0;
	  }

Related Classes
     Class RWTPtrMultiSet<T,C> offers the same interface to a pointer-based
     collection that accepts multiple items that compare equal to each other.
     RWTPtrMap<K,T,C> is a pointer-based collection of key-value pairs.	 Class
     set<T*,rw_deref_compare<C,T>,allocator> is the C++-standard collection
     that serves as the underlying implementation for RWTPtrSet<T,C>.

Public Typedefs
	      typedef rw_deref_compare<C,T>		     container_comp;
	  typedef set<T*, container_comp,allocator>	 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;

Public Constructors
	      RWTPtrSet<T,C>(const container_comp& comp = container_comp());

     Constructs an empty set.

	      RWTPtrSet<T,C>(const RWTPtrSet<T,C>& rws);

     Copy constructor.

									Page 2

RWTPtrSet(3C++)						       RWTPtrSet(3C++)

	      RWTPtrSet<T,C>(const container_type& s);

     Creates a pointer based set by copying all elements from s.

	      RWTPtrSet<T,C>(T* const* first,T* const* last,const container_comp& comp = container_comp());

     Constructs a set by copying elements from the array of T*s pointed to by
     first, up to, but not including, the element pointed to by last.

Public Member Operators
	      RWTPtrSet<T,C>&
	  operator=(const container_type& s);
	  RWTPtrSet<T,C>&
	  operator=(const RWTPtrSet<T,C>& s);

     Clears all elements of self and replaces them by copying all elements of
     s.

	      bool
	  operator<(const RWTPtrSet<T,C>& s);

     Returns true if self compares lexicographically less than s, otherwise
     returns false.  Items in each collection are dereferenced before being
     compared.	Assumes that type T has well-defined less-than semantics.

	      bool
	  operator==(const RWTPtrSet<T,C>& s);

     Returns true if self compares equal to s, otherwise returns false.	 Two
     collections are equal if both have the same number of entries, and
     iterating through both collections produces, in turn, individual elements
     that compare equal to each other.	Elements are dereferenced before being
     compared.

Public Member Functions
	      void
	  apply(void (*fn)(const T*,void*), void* d) const;

     Applies the user-defined function pointed to by fn to every item in the
     collection.  This function must have prototype:

		 void yourfun(const T* a, void* d);

     Client data may be passed through parameter d.

									Page 3

RWTPtrSet(3C++)						       RWTPtrSet(3C++)

	      iterator
	  begin();
	  const_iterator
	  begin() const;

     Returns an iterator positioned at the first element of self.

	      void
	  clear();

     Clears the collection by removing all items from self.

	      void
	  clearAndDestroy();

     Removes all items from the collection and uses operator delete to destroy
     the objects pointed to by those items.

	      bool
	  contains(const T* a) const;

     Returns true if there exists an element t in self that compares equal
     with *a, otherwise returns false.

	      bool
	  contains(bool (*fn)(const T*,void*), void* d) const;

     Returns true if there exists an element t in self such that the
     expression ((*fn)(t,d)) is true, otherwise returns false.	fn points to a
     user-defined tester function which must have prototype:

		 bool yourTester(const T* a, void* d);

     Client data may be passed through parameter d.

	      void
	  difference(const RWTPtrSet<T,C>& s);

     Sets self to the set-theoretic difference given by (self - s).  Elements
     from each set are dereferenced before being compared.

	      iterator
	  end();
	  const_iterator
	  end() const;

									Page 4

RWTPtrSet(3C++)						       RWTPtrSet(3C++)

     Returns an iterator positioned "just past" the last element in self.

	      size_type
	  entries() const;

     Returns the number of items in self.

	      const T*
	  find(const T* a) const;

     If there exists an element t in self that compares equal with *a, returns
     t.	 Otherwise, returns rwnil.

	      const T*
	  find(bool (*fn)(const T*,void*), void* d) const;

     If there exists an element t in self such that the expression
     ((*fn)(t,d)) is true, returns t.  Otherwise, returns rwnil.  fn points to
     a user-defined tester function which must have prototype:

		 bool yourTester(const T* a, void* d);

     Client data may be passed through parameter d.

	      bool
	  insert(T* a);

     Adds the item a to the collection.	 Returns true if the insertion is
     successful, otherwise returns false.  The function will return true
     unless the collection already holds an element with an equivalent key.

	      void
	  intersection(const RWTPtrSet<T,C>& s);

     Sets self to the intersection of self and s.  Elements from each set are
     dereferenced before being compared.

	      bool
	  isEmpty() const;

     Returns true if there are no items in the collection, false otherwise.

	      bool
	  isEquivalent(const RWTPtrSet<T,C>& s) const;

									Page 5

RWTPtrSet(3C++)						       RWTPtrSet(3C++)

     Returns true if there is set equivalence between self and s, and returns
     false otherwise.

	      bool
	  isProperSubsetOf(const RWTPtrSet<T,C>& s) const;

     Returns true if self is a proper subset of s, and returns	false
     otherwise.

	      bool
	  isSubsetOf(const RWTPtrSet<T,C>& s) const;

     Returns true if self is a subset of s or if self is set equivalent to s,
     false otherwise.

	      size_type
	  occurrencesOf(const T* a) const;

     Returns the number of elements t in self that compare equal with *a.

	      size_type
	  occurrencesOf(bool (*fn)(T*,void*), void* d);
	  size_type
	  occurrencesOf(bool (*fn)(const T*,void*), void* d) const;

     Returns the number of elements t in self such that the expression
     ((*fn)(t,d)) is true.   fn points to a user-defined tester function which
     must have prototype:

		 bool yourTester(const T* a, void* d);

     Client data may be passed through parameter d.

	      T*
	  remove(const T* a);

     Removes and returns the first element t in self that compares equal with
     *a.  Returns rwnil if there is no such element.

	      T*
	  remove(bool (*fn)(const T*,void*), void* d);

     Removes and returns the first element t in self such that the expression
     ((*fn)(t,d)) is true.  Returns rwnil if there is no such element.	fn
     points to a user-defined tester function which must have prototype:

									Page 6

RWTPtrSet(3C++)						       RWTPtrSet(3C++)

		 bool yourTester(const T* a, void* d);

     Client data may be passed through par_meter d.

	      size_type
	  removeAll(const T* a);

     Removes all elements t in self that compares equal with *a.  Returns the
     number of items removed.

	      size_type
	  removeAll(bool (*fn)(const T*,void*), void* d);

     Removes all elements t in self such that the expression ((*fn)(t,d))is
     true.  Returns the number of items removed.  fn points to a user-defined
     tester function which must have prototype:

		 bool yourTester(const T* a, void* d);

     Client data may be passed through parameter d.

	      set<T*, container_comp,allocator>&
	  std();
	  const set<T*, container_comp,allocator>&
	  std() const;

     Returns a reference to the underlying C++-standard collection that serves
     as the implementation for self.

	      void
	  symmetricDifference(const RWTPtrSet<T,C>& s);

     Sets self to the symmetric difference of self and s.  Elements from each
     set are dereferenced before being compared.

	      void
	  Union(const RWTPtrSet<T,C>& s);

     Sets self to the union of self and s.  Elements from each set are
     dereferenced before being compared. Note the uppercase "U" in Union to
     avoid conflict with the C++ reserved word.

									Page 7

RWTPtrSet(3C++)						       RWTPtrSet(3C++)

Related Global Operators
	      RWvostream&
	  operator<<(RWvostream& strm, const RWTPtrSet<T,C>& coll);
	  RWFile&
	  operator<<(RWFile& strm, const RWTPtrSet<T,C>& coll);

     Saves the collection coll onto the output stream strm, or a reference to
     it if it has already been saved.

	      RWvistream&
	  operator>>(RWvistream& strm, RWTPtrSet<T,C>& coll);
	  RWFile&
	  operator>>(RWFile& strm, RWTPtrSet<T,C>& coll);

     Restores the contents of the collection coll from the input stream strm.

	      RWvistream&
	  operator>>(RWvistream& strm, RWTPtrSet<T,C>*& p);
	  RWFile&
	  operator>>(RWFile& strm, RWTPtrSet<T,C>*& p);

     Looks at the next object on the input stream strm and either creates a
     new collection off the heap and sets p to point to it, or sets p to point
     to a previously read instance.  If a collection is created off the heap,
     then you are responsible for deleting it.

									Page 8

[top]

List of man pages available for IRIX

Copyright (c) for man pages and the logo by the respective OS vendor.

For those who want to learn more, the polarhome community provides shell access and support.

[legal] [privacy] [GNU] [policy] [cookies] [netiquette] [sponsors] [FAQ]
Tweet
Polarhome, production since 1999.
Member of Polarhome portal.
Based on Fawad Halim's script.
....................................................................
Vote for polarhome
Free Shell Accounts :: the biggest list on the net