home *** CD-ROM | disk | FTP | other *** search
/ C Programming Starter Kit 2.0 / SamsPublishing-CProgrammingStarterKit-v2.0-Win31.iso / bc45 / clobss.pak / BABSTARY.CPO < prev    next >
Text File  |  1997-07-23  |  2KB  |  88 lines

  1. /*------------------------------------------------------------------------*/
  2. /*                                                                        */
  3. /*  BABSTARY.CPP                                                          */
  4. /*                                                                        */
  5. /*  Copyright Borland International 1991, 1993                            */
  6. /*  All Rights Reserved                                                   */
  7. /*                                                                        */
  8. /*------------------------------------------------------------------------*/
  9.  
  10. #if !defined( TEMPLATES )
  11. #define TEMPLATES
  12. #endif
  13.  
  14. #if !defined( __IOSTREAM_H )
  15. #include <iostream.h>
  16. #endif    // __IOSTREAM_H
  17.  
  18. #if !defined( __STDLIB_H )
  19. #include <stdlib.h>
  20. #endif    // __STDLIB_H
  21.  
  22. #if !defined( __MEM_H )
  23. #include <mem.h>
  24. #endif  // __MEM_H
  25.  
  26. #if !defined( CHECKS_H )
  27. #include <checks.h>
  28. #endif  // CHECKS_H
  29.  
  30. #if !defined( __ABSTARRY_H )
  31. #include "classlib\obsolete\abstarry.h"
  32. #endif  // __ABSTARRY_H
  33.  
  34. inline int isZero( const Object& o )
  35. {
  36.     return o == NOOBJECT;
  37. }
  38.  
  39. int AbstractArray::isEqual( const Object& obj ) const
  40. {
  41.     PRECONDITION( isA() == obj.isA() );
  42.     AbstractArray& test = (AbstractArray&)obj;
  43.     if( lowerBound() != test.lowerBound() ||
  44.         upperBound() != test.upperBound()
  45.       )
  46.         return 0;
  47.  
  48.     ContainerIterator& iter1 = initIterator();
  49.     ContainerIterator& iter2 = test.initIterator();
  50.     while( iter1 && iter2 )
  51.         if( iter1.current() != iter2.current() )
  52.             {
  53.             delete &iter1;
  54.             delete &iter2;
  55.             return 0;
  56.             }
  57.         else
  58.             {
  59.             iter1++;
  60.             iter2++;
  61.             }
  62.  
  63.     delete &iter1;
  64.     delete &iter2;
  65.     return 1;
  66. }
  67.  
  68. void AbstractArray::printContentsOn( ostream& outputStream ) const
  69. {
  70.     ContainerIterator& printIterator = initIterator();
  71.     printHeader( outputStream );
  72.     while( printIterator != 0 )
  73.         {
  74.         Object& arrayObject = printIterator++;
  75.         if( arrayObject != NOOBJECT )
  76.             {
  77.             arrayObject.printOn( outputStream );
  78.             if( printIterator != 0 )
  79.                 printSeparator( outputStream );
  80.             else
  81.                 break;
  82.             }
  83.         }
  84.     printTrailer( outputStream );
  85.     delete &printIterator;
  86. }
  87.  
  88.