home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_144 / 2.ddi / CLASSINC.ZIP / SORTABLE.H < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-10  |  2.1 KB  |  79 lines

  1. /*------------------------------------------------------------------------*/
  2. /*                                                                        */
  3. /*  SORTABLE.H                                                            */
  4. /*                                                                        */
  5. /*  Copyright Borland International 1991, 1992                            */
  6. /*  All Rights Reserved                                                   */
  7. /*                                                                        */
  8. /*------------------------------------------------------------------------*/
  9.  
  10. #if !defined( _SORTABLE_H )
  11. #define _SORTABLE_H
  12.  
  13. #if !defined( __CLSDEFS_H )
  14. #include <ClsDefs.h>
  15. #endif  // __CLSDEFS_H
  16.  
  17. #if !defined( __OBJECT_H )
  18. #include <Object.h>
  19. #endif  // __OBJECT_H
  20.  
  21. #pragma option -Vo-
  22. #if defined( __BCOPT__ ) && !defined( _ALLOW_po )
  23. #pragma option -po-
  24. #endif
  25.  
  26. _CLASSDEF(ostream)
  27. _CLASSDEF(Sortable)
  28.  
  29. class _CLASSTYPE Sortable : public Object
  30. {
  31.  
  32. public:
  33.  
  34.     virtual int isEqual( const Object _FAR & ) const = 0;
  35.     virtual int isLessThan( const Object _FAR & ) const = 0;
  36.     virtual int isSortable() const
  37.         {
  38.         return 1;
  39.         }
  40.  
  41.     virtual classType isA() const = 0;
  42.     virtual char _FAR *nameOf() const = 0;
  43.     virtual hashValueType hashValue() const = 0;
  44.     virtual void printOn( ostream& ) const = 0;
  45.  
  46. };
  47.  
  48.  
  49. inline
  50. int operator < ( const Sortable _FAR & test1, const Sortable _FAR & test2 )
  51. {
  52.     return ( (test1.isA() == test2.isA()) && test1.isLessThan( test2 ) );
  53. }
  54.  
  55. inline
  56. int operator > ( const Sortable _FAR & test1, const Sortable _FAR & test2 )
  57. {
  58.     return !( test1 < test2 ) && test1 != test2;
  59. }
  60.  
  61. inline
  62. int operator >=( const Sortable _FAR & test1, const Sortable _FAR & test2 )
  63. {
  64.     return ( !( test1 <( test2 ) ) );
  65. }
  66.  
  67. inline
  68. int operator <=( const Sortable _FAR & test1, const Sortable _FAR & test2 )
  69. {
  70.     return ( test1 < test2 || test1 == test2 );
  71. }
  72.  
  73. #if defined( __BCOPT__ ) && !defined( _ALLOW_po )
  74. #pragma option -po.
  75. #endif
  76. #pragma option -Vo.
  77.  
  78. #endif
  79.