home *** CD-ROM | disk | FTP | other *** search
/ The Devil's Doorknob BBS Capture (1996-2003) / devilsdoorknobbbscapture1996-2003.iso / Dloads / OTHERUTI / TCPP30-1.ZIP / CLASSSRC.ZIP / BABSTARY.CPP < prev    next >
C/C++ Source or Header  |  1992-02-18  |  2KB  |  88 lines

  1. /*------------------------------------------------------------------------*/
  2. /*                                                                        */
  3. /*  BABSTARY.CPP                                                          */
  4. /*                                                                        */
  5. /*  Copyright Borland International 1991                                  */
  6. /*  All Rights Reserved                                                   */
  7. /*                                                                        */
  8. /*------------------------------------------------------------------------*/
  9.  
  10. #if !defined( TEMPLATES )
  11. #define TEMPLATES
  12. #endif
  13.  
  14. #if !defined( CHECKS_H )
  15. #include <Checks.h>
  16. #endif  // CHECKS_H
  17.  
  18. #if !defined( __ABSTARRY_H )
  19. #include <AbstArry.h>
  20. #endif  // __ABSTARRY_H
  21.  
  22. #ifndef __IOSTREAM_H
  23. #include <iostream.h>
  24. #endif
  25.  
  26. #ifndef __STDLIB_H
  27. #include <stdlib.h>
  28. #endif
  29.  
  30. #if !defined( __MEM_H )
  31. #include <mem.h>
  32. #endif  // __MEM_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.