RWTPtrHashSetIterator(3C++)

RWTPtrHashSetIterator<T,H,EQ> - Rogue Wave library class

As shipped in IRIX 6.5. First release of IRIX 6.5.

Name
     RWTPtrHashSetIterator<T,H,EQ> - Rogue Wave library class

Synopsis
              #include<rw/tphset.h>



              RWTPtrHashSet<T,H,EQ> m;
          RWTPtrHashSet<T,H,EQ> itr(m);

Please Note!
     If you have the Standard C++ Library, use the interface described here.
     Otherwise, use the restricted interface to RWTPtrHashTableIterator
     described in Appendix A.


Description
     RWTPtrHashSetIterator is supplied with Tools.h++ 7.x to provide an
     iterator interface to the Standard Library based collections that has
     backward compatibility with the container iterators provided in Tools.h++
     6.x. Iteration over an RWTPtrHashSet is pseudorandom and dependent on the
     capacity of the underlying hash table and the hash function being used.
     The current item referenced by this iterator is undefined after
     construction or after a call to reset().  The iterator becomes valid
     after being advanced with either a pre-increment or an operator().  For
     both operator++ and operator(), iterating past the last element will
     return a value equivalent to boolean false.  Continued increments will
     return a value equivalent to false until reset() is called.

Persistence
     None

Examples
              #include<rw/tphset.h>



              #include<iostream.h>
          #include<rw/cstring.h>
          struct silly_h{
             unsigned long operator()(RWCString x) const
               { return x.length() * (long)x(0); }
          };


              int main(){

                 RWTPtrHashSet <RWCString,silly_h,equal_to<RWCString> > age;



                 RWTPtrHashSetIterator



                   <RWCString,silly_h,equal_to<RWCString> > itr(age);



                 age.insert(new RWCString("John"));



                 age.insert(new RWCString("Steve"));
             age.insert(new RWCString("Mark"));


              //Duplicate insertion is rejected



                 age.insert(new RWCString("Steve"));



                 for(;++itr;) cout << *itr.key() << endl;
             return 0;



              }



              Program Output (not necessarily in this order)



              John
          Mark
          Steve

Public Constructors
              RWTPtrHashSetIterator<T,H,EQ>(RWTPtrHashSet<T,H,EQ>&h);


     Creates an iterator for the hashed set h.  The iterator begins in an
     undefined state and must be advanced before the first element will be
     accessible.

Public Member Operators
              T*
          operator()();


     Advances self to the next element, dereferences the resulting iterator
     and returns its value.  If the iterator has advanced past the last item
     in the container,  the element returned will be a nil pointer equivalent
     to boolean false.

              RWBoolean
          operator++();


     Advances self to the next element.  If the iterator has been reset or
     just created self will now reference the first element.  If, before
     iteration, self referenced the last association in the multi-map, self
     will now point to an undefined value and a value equivalent to false will
     be returned.  Otherwise, a value equivalent to true is returned. Note: no
     post-increment operator is provided.

Public Member Functions
              RWTPtrHashSet<T,H,EQ>*
          container() const;


     Returns a pointer to the collection being iterated over.

              T*
          key() const;


     Returns the element referenced by self. Undefined if self is not
     referencing a value within the set.

              void
          reset();
          void
          reset(RWTPtrHashSet<T,H,EQ>& h);


     Resets the iterator so that after being advanced it will reference the
     first element of the collection.  Using reset() with no argument will
     reset the iterator on the current container.  Supplying a RWTPtrHashSet
     to reset() will reset the iterator on that container.