home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2001 May / SGI IRIX Base Documentation 2001 May.iso / usr / share / catman / p_man / cat3 / librw / RWTPtrHashMultiSetIterator.z / RWTPtrHashMultiSetIterator
Encoding:
Text File  |  1998-10-30  |  8.6 KB  |  199 lines

  1.  
  2.  
  3.  
  4. RRRRWWWWTTTTPPPPttttrrrrHHHHaaaasssshhhhMMMMuuuullllttttiiiiSSSSeeeettttIIIItttteeeerrrraaaattttoooorrrr((((3333CCCC++++++++))))              RRRRWWWWTTTTPPPPttttrrrrHHHHaaaasssshhhhMMMMuuuullllttttiiiiSSSSeeeettttIIIItttteeeerrrraaaattttoooorrrr((((3333CCCC++++++++))))
  5.  
  6.  
  7.  
  8. NNNNaaaammmmeeee
  9.      RWTPtrHashMultiSetIterator<T,H,EQ> - Rogue Wave library class
  10.  
  11. SSSSyyyynnnnooooppppssssiiiissss
  12.               #include<rw/tphasht.h>
  13.  
  14.  
  15.  
  16.               RWTPtrHashMultiSet<T,H,EQ> m;
  17.           RWTPtrHashMultiSet<T,H,EQ> itr(m);
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24. PPPPlllleeeeaaaasssseeee NNNNooootttteeee!!!!
  25.      IIIIffff yyyyoooouuuu hhhhaaaavvvveeee tttthhhheeee SSSSttttaaaannnnddddaaaarrrrdddd CCCC++++++++ LLLLiiiibbbbrrrraaaarrrryyyy,,,, uuuusssseeee tttthhhheeee iiiinnnntttteeeerrrrffffaaaacccceeee ddddeeeessssccccrrrriiiibbbbeeeedddd hhhheeeerrrreeee....
  26.      OOOOtttthhhheeeerrrrwwwwiiiisssseeee,,,, uuuusssseeee tttthhhheeee iiiinnnntttteeeerrrrffffaaaacccceeee ffffoooorrrr RRRRWWWWTTTTPPPPttttrrrrHHHHaaaasssshhhhTTTTaaaabbbblllleeeeIIIItttteeeerrrraaaattttoooorrrr described in
  27.      Appendix A.
  28.  
  29.  
  30. DDDDeeeessssccccrrrriiiippppttttiiiioooonnnn
  31.      RRRRWWWWTTTTPPPPttttrrrrHHHHaaaasssshhhhMMMMuuuullllttttiiiiSSSSeeeettttIIIItttteeeerrrraaaattttoooorrrr is supplied with TTTToooooooollllssss....hhhh++++++++ 7.x to provide an
  32.      iterator interface to the Standard Library based collections that has
  33.      backward compatibility with the container iterators provided in TTTToooooooollllssss....hhhh++++++++
  34.      6.x. Iteration over an RRRRWWWWTTTTPPPPttttrrrrHHHHaaaasssshhhhMMMMuuuullllttttiiiiSSSSeeeetttt is pseudorandom and dependent
  35.      on the capacity of the underlying hash table and the hash function being
  36.      used.  The only useable relationship between consecutive elements is that
  37.      all elements which are defined to be equivalent by the equivalence
  38.      object, EEEEQQQQ, will remain adjacent.  The current item referenced by this
  39.      iterator is undefined after construction or after a call to rrrreeeesssseeeetttt(((())))
  40.      operation.  The iterator becomes valid after being advanced with either a
  41.      preincrement or ooooppppeeeerrrraaaattttoooorrrr(((()))).  For both ooooppppeeeerrrraaaattttoooorrrr++++++++ and ooooppppeeeerrrraaaattttoooorrrr(((()))),
  42.      iterating past the last element will return a value equivalent to boolean
  43.      ffffaaaallllsssseeee.  Continued increments will return a value equivalent to ffffaaaallllsssseeee
  44.      until rrrreeeesssseeeetttt(((()))) is called.
  45.  
  46. PPPPeeeerrrrssssiiiisssstttteeeennnncccceeee
  47.      None
  48.  
  49. EEEExxxxaaaammmmpppplllleeeessss
  50.               #include<rw/tphasht.h>
  51.  
  52.  
  53.  
  54.               #include<iostream.h>
  55.           #include<rw/cstring.h>
  56.           struct silly_h{
  57.              unsigned long operator()(RWCString x) const
  58.                { return x.length() * (long)x(0); }
  59.           };
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. RRRRWWWWTTTTPPPPttttrrrrHHHHaaaasssshhhhMMMMuuuullllttttiiiiSSSSeeeettttIIIItttteeeerrrraaaattttoooorrrr((((3333CCCC++++++++))))              RRRRWWWWTTTTPPPPttttrrrrHHHHaaaasssshhhhMMMMuuuullllttttiiiiSSSSeeeettttIIIItttteeeerrrraaaattttoooorrrr((((3333CCCC++++++++))))
  71.  
  72.  
  73.  
  74.           int main(){
  75.              RWTPtrHashMultiSet<RWCString,silly_h,equal_to<RWCString> > age;
  76.              RWTPtrHashMultiSetIterator
  77.              <RWCString,silly_h,equal_to<RWCString> > itr(age);
  78.              age.insert(new RWCString("John"));
  79.              age.insert(new RWCString("Steve"));
  80.              age.insert(new RWCString("Mark"));
  81.              age.insert(new RWCString("Steve"));
  82.              for(;++itr;)
  83.                cout << *itr.key() << endl;
  84.              return 0;
  85.           }
  86.           Program Output (not necessarily in this order)
  87.           John
  88.           Mark
  89.           Steve
  90.  
  91. PPPPuuuubbbblllliiiicccc CCCCoooonnnnssssttttrrrruuuuccccttttoooorrrrssss
  92.      Steve
  93.  
  94.  
  95.  
  96.               RRRRWWWWTTTTPPPPttttrrrrHHHHaaaasssshhhhMMMMuuuullllttttiiiiSSSSeeeettttIIIItttteeeerrrraaaattttoooorrrr<<<<TTTT,,,,HHHH,,,,EEEEQQQQ>>>>
  97.           (RWTPtrHashMultiSet<T,H,EQ>&h);
  98.  
  99.  
  100.      Creates an iterator for the hashed multi-set hhhh.  The iterator begins in
  101.      an undefined state and must be advanced before the first element will be
  102.      accessible.
  103.  
  104. PPPPuuuubbbblllliiiicccc MMMMeeeemmmmbbbbeeeerrrr OOOOppppeeeerrrraaaattttoooorrrrssss
  105.               T*
  106.           ooooppppeeeerrrraaaattttoooorrrr(((())))();
  107.  
  108.  
  109.      Advances self to the next element, dereferences the resulting iterator
  110.      and returns its value.  If the iterator has advanced past the last item
  111.      in the container,  the element returned will be a nnnniiiillll pointer equivalent
  112.      to boolean ffffaaaallllsssseeee.
  113.  
  114.               RWBoolean
  115.           ooooppppeeeerrrraaaattttoooorrrr++++++++();
  116.  
  117.  
  118.      Advances self to the next element.  If the iterator has been reset or
  119.      just created self will now reference the first element.  If, before
  120.      iteration, self referenced the last association in the multiset, self
  121.      will now reference an undefined value and a value equivalent to ffffaaaallllsssseeee
  122.      will be returned.  Otherwise, a value equivalent to ttttrrrruuuueeee is returned.
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. RRRRWWWWTTTTPPPPttttrrrrHHHHaaaasssshhhhMMMMuuuullllttttiiiiSSSSeeeettttIIIItttteeeerrrraaaattttoooorrrr((((3333CCCC++++++++))))              RRRRWWWWTTTTPPPPttttrrrrHHHHaaaasssshhhhMMMMuuuullllttttiiiiSSSSeeeettttIIIItttteeeerrrraaaattttoooorrrr((((3333CCCC++++++++))))
  137.  
  138.  
  139.  
  140.      Note: no post-increment operator is provided.
  141.  
  142. PPPPuuuubbbblllliiiicccc MMMMeeeemmmmbbbbeeeerrrr FFFFuuuunnnnccccttttiiiioooonnnnssss
  143.               RWTPtrHashMultiSet<T,H,EQ>*
  144.           ccccoooonnnnttttaaaaiiiinnnneeeerrrr(((()))) const;
  145.  
  146.  
  147.      Returns a pointer to the collection being iterated over.
  148.  
  149.               T*
  150.           kkkkeeeeyyyy() const;
  151.  
  152.  
  153.      Returns the value  currently referenced by sssseeeellllffff. Undefined if self is not
  154.      referencing a value within the multiset.
  155.  
  156.               void
  157.           rrrreeeesssseeeetttt();
  158.           void
  159.           rrrreeeesssseeeetttt(RWTPtrHashMultiSet<T,H,EQ>& h);
  160.  
  161.  
  162.      Resets the iterator so that after being advanced it will reference the
  163.      first element of the collection.  Using rrrreeeesssseeeetttt(((()))) with no argument will
  164.      reset the iterator on the current container.  Supplying a
  165.      RRRRWWWWTTTTPPPPttttrrrrHHHHaaaasssshhhhMMMMuuuullllttttiiiiSSSSeeeetttt to rrrreeeesssseeeetttt(((()))) will reset the iterator on that container.
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.                                                                         PPPPaaaaggggeeee 3333
  196.  
  197.  
  198.  
  199.