ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

SortClass.h
Go to the documentation of this file.
00001 /***********************************************************************************
00002   SortClass.h
00003 
00004  * Copyright (c) 1997
00005  * Mark of the Unicorn, Inc.
00006  *
00007  * Permission to use, copy, modify, distribute and sell this software
00008  * and its documentation for any purpose is hereby granted without fee,
00009  * provided that the above copyright notice appear in all copies and
00010  * that both that copyright notice and this permission notice appear
00011  * in supporting documentation.  Mark of the Unicorn makes no
00012  * representations about the suitability of this software for any
00013  * purpose.  It is provided "as is" without express or implied warranty.
00014 
00015     SUMMARY: A class designed to test operations that compares objects. All
00016       comparisons on SortClass may fail. Also records its own address for
00017       the sake of testing the stability of sorting algorithms.
00018 
00019 ***********************************************************************************/
00020 #if ! defined (INCLUDED_MOTU_SortClass)
00021 #define INCLUDED_MOTU_SortClass 1
00022 
00023 # include "Prefix.h"
00024 # include "TestClass.h"
00025 
00026 class SortClass : public TestClass
00027 {
00028 public:
00029   enum { kRange = 100 };
00030 
00031   SortClass( int v ) : TestClass( v ), addr(0) {
00032      ResetAddress();
00033   }
00034 
00035   SortClass() : TestClass( (int)get_random(kRange) ), addr(0) {
00036      ResetAddress();
00037   }
00038 
00039   bool operator<( const TestClass& rhs ) const
00040   {
00041     simulate_possible_failure();
00042     return (const TestClass&)*this < ( rhs );
00043   }
00044 
00045   bool operator==( const TestClass& rhs ) const
00046   {
00047     simulate_possible_failure();
00048     return (const TestClass&)*this == ( rhs );
00049   }
00050 
00051   SortClass* GetAddress() const { return addr; }
00052   void ResetAddress() { addr = this; }
00053 
00054 private:
00055   SortClass* addr;
00056 };
00057 
00058 inline bool operator>( const SortClass& lhs, const SortClass& rhs ) {
00059     return rhs < lhs;
00060 }
00061 
00062 inline bool operator<=( const SortClass& lhs, const SortClass& rhs ) {
00063     return !(rhs < lhs);
00064 }
00065 
00066 inline bool operator>=( const SortClass& lhs, const SortClass& rhs ) {
00067     return !(lhs < rhs);
00068 }
00069 
00070 inline bool operator != ( const SortClass& lhs, const SortClass& rhs ) {
00071     return !(lhs == rhs);
00072 }
00073 
00074 #if defined( __MWERKS__ ) && __MWERKS__ <= 0x3000 && !__SGI_STL
00075 # if defined( __MSL__ ) && __MSL__ < 0x2406
00076 __MSL_FIX_ITERATORS__(SortClass);
00077 __MSL_FIX_ITERATORS__(const SortClass);
00078 # endif
00079 #endif
00080 
00081 #endif // INCLUDED_MOTU_SortClass

Generated on Fri May 25 2012 04:33:43 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.