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

void test_stable_partition::operator() ( SortBuffer buf) const [inline]

Definition at line 92 of file test_algo.cpp.

    {
        less_by_reference<SortClass> throw_cmp( partitionPoint );

        SortClass* d = EH_STD::stable_partition( buf.begin(), buf.end(), throw_cmp );

        // Suppress warning about unused variable.
        d;

        // If we get here no exception occurred during the operation.
        // Stop any potential failures that might occur during verification.
        gTestController.CancelFailureCountdown();

        // Prepare an array of counts of the occurrence of each value in
        // the legal range.
        unsigned counts[SortClass::kRange];
        EH_STD::fill_n( counts, (int)SortClass::kRange, 0 );
        for ( const SortClass *q = orig.begin(); q != orig.end(); q++ )
            counts[ q->value() ]++;

        less_by_reference<TestClass> cmp( partitionPoint );
        for ( const SortClass* p = buf.begin(); p != buf.end(); p++ )
        {
          // Check that adjacent items with the same value haven't been
          // reordered. This could be a more thorough test.
            if ( p != buf.begin() && p->value() == p[-1].value() ) {
                EH_ASSERT( p->GetAddress() > p[-1].GetAddress() );
            }

            // Check that the partitioning worked.
            EH_ASSERT( (p < d) == cmp( *p ) );

            // Decrement the appropriate count for each value.
            counts[ p->value() ]--;
        }

        // Check that the values were only rearranged, and none were lost.
        for ( unsigned j = 0; j < SortClass::kRange; j++ ) {
            EH_ASSERT( counts[j] == 0 );
        }
    }

Generated on Fri May 25 2012 06:42:35 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.