home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_122 / 10.ddi / TVSRC.ZIP / GRP.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-10  |  2.1 KB  |  78 lines

  1. /*------------------------------------------------------------*/
  2. /* filename - grp.cpp                                         */
  3. /*                                                            */
  4. /* function(s)                                                */
  5. /*            TGroup member functions                         */
  6. /*------------------------------------------------------------*/
  7.  
  8. /*------------------------------------------------------------*/
  9. /*                                                            */
  10. /*    Turbo Vision -  Version 1.0                             */
  11. /*                                                            */
  12. /*                                                            */
  13. /*    Copyright (c) 1991 by Borland International             */
  14. /*    All Rights Reserved.                                    */
  15. /*                                                            */
  16. /*------------------------------------------------------------*/
  17.  
  18. #define Uses_TGroup
  19. #include <tv.h>
  20.  
  21. TView *TGroup::at( short index )
  22. {
  23.     TView *temp = last;
  24.     while( index-- > 0 )
  25.         temp = temp->next;
  26.     return temp;
  27. }
  28.  
  29. TView *TGroup::firstThat( Boolean (*func)(TView *, void *), void *args )
  30. {
  31.     TView *temp = last;
  32.     if( temp == 0 )
  33.         return 0;
  34.  
  35.     do  {
  36.         temp = temp->next;
  37.         if( func( temp, args ) == True )
  38.             return temp;
  39.         } while( temp != last );
  40.     return 0;
  41. }
  42.  
  43. void TGroup::forEach( void (*func)(TView*, void *), void *args )
  44. {
  45.     TView *term = last;
  46.     TView *temp = last;
  47.     if( temp == 0 )
  48.         return;
  49.  
  50.     TView *next = temp->next;
  51.     do  {
  52.         temp = next;
  53.         next = temp->next;
  54.         func( temp, args );
  55.         } while( temp != term );
  56.  
  57. }
  58.  
  59. short TGroup::indexOf( TView *p )
  60. {
  61.     if( last == 0 )
  62.         return 0;
  63.  
  64.     short index = 0;
  65.     TView *temp = last;
  66.     do  {
  67.         index++;
  68.         temp = temp->next;
  69.         } while( temp != p && temp != last );
  70.     if( temp != p )
  71.         return 0;
  72.     else
  73.         return index;
  74. }
  75.  
  76.  
  77.  
  78.