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

  1. /*------------------------------------------------------------------------*/
  2. /*                                                                        */
  3. /*  SORTABLE.H                                                            */
  4. /*                                                                        */
  5. /*  Copyright Borland International 1991                                  */
  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. _CLASSDEF(ostream)
  22. _CLASSDEF(Sortable)
  23.  
  24. class _CLASSTYPE Sortable : public Object
  25. {
  26.  
  27. public:
  28.  
  29.     virtual int isEqual( const Object _FAR & ) const = 0;
  30.     virtual int isLessThan( const Object _FAR & ) const = 0;
  31.     virtual int isSortable() const
  32.         {
  33.         return 1;
  34.         }
  35.  
  36.     virtual classType isA() const = 0;
  37.     virtual char _FAR *nameOf() const = 0;
  38.     virtual hashValueType hashValue() const = 0;
  39.     virtual void printOn( ostream& ) const = 0;
  40.  
  41. };
  42.  
  43.  
  44. inline
  45. int operator < ( const Sortable _FAR & test1, const Sortable _FAR & test2 )
  46. {
  47.     return ( (test1.isA() == test2.isA()) && test1.isLessThan( test2 ) );
  48. }
  49.  
  50. inline
  51. int operator > ( const Sortable _FAR & test1, const Sortable _FAR & test2 )
  52. {
  53.     return !( test1 < test2 ) && test1 != test2;
  54. }
  55.  
  56. inline
  57. int operator >=( const Sortable _FAR & test1, const Sortable _FAR & test2 )
  58. {
  59.     return ( !( test1 <( test2 ) ) );
  60. }
  61.  
  62. inline
  63. int operator <=( const Sortable _FAR & test1, const Sortable _FAR & test2 )
  64. {
  65.     return ( test1 < test2 || test1 == test2 );
  66. }
  67.  
  68. #endif
  69.