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 / RWTPtrHashMultiMapIterator.z / RWTPtrHashMultiMapIterator
Encoding:
Text File  |  1998-10-30  |  8.3 KB  |  199 lines

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