Exemplo n.º 1
0
void ShuffleCommand :: Shuffle( IOManager & io ) {
    ALib::RandGen rg( mSeed );
    int nout = mCount;
    int last = mRows.size();
    for ( unsigned int i = 0; i < mRows.size() && nout-- > 0; i++ ) {
        int pos = rg.NextInt( 0, last );
        io.WriteRow( mRows[pos] );
        mRows[pos].swap( mRows[--last] );
    }
}
Exemplo n.º 2
0
void SummaryCommand :: DoFreq( IOManager & io ) {
	CalcFreqs();

	for ( unsigned int i = 0; i < mRows.size(); i++ ) {
		string key = MakeKey( mRows.at(i) );
		unsigned int n = mFreqMap.find( key )->second.mFreq;
		CSVRow r = mRows.at(i);
		r.insert( r.begin(), ALib::Str( n ) );
		io.WriteRow( r );
	}
}
Exemplo n.º 3
0
void  ReadXMLCommand :: WriteRow( const ALib::XMLElement * r,
										IOManager & io ) {
	CSVRow row;

	for ( unsigned int i = 0; i < r->ChildCount(); i++  ) {
		const ALib::XMLElement * ce = r->ChildElement( i );
		if ( ce && ce->Name() == "td" ) {
			row.push_back( TDToCSV( ce ) );
		}
	}

//	ALib::Dump( std::cout, row );
	io.WriteRow( row );
}
Exemplo n.º 4
0
void SummaryCommand :: DoMode( IOManager & io ) {

	unsigned int mode = CalcFreqs();

	for ( FreqMap::const_iterator it = mFreqMap.begin();
			it != mFreqMap.end(); ++it ) {

		if ( it->second.mFreq == mode ) {
			for ( unsigned int i = 0; i < it->second.mIndex.size(); i++ ) {
				CSVRow r = mRows.at( it->second.mIndex.at(i) );
				r.insert( r.begin(), ALib::Str( mode ) );
				io.WriteRow( r );
			}
		}
	}
}
Exemplo n.º 5
0
void SummaryCommand :: DoMinMax( IOManager & io ) {
	CSVRow r = mRows.at(0);

	for ( unsigned int i = 1; i < mRows.size(); i++ ) {
		if ( mType == Min && Cmp( mRows.at(i), r ) < 0 ) {
			r = mRows.at(i);
		}
		else if ( mType == Max && Cmp( mRows.at(i), r ) > 0 ) {
			r = mRows.at(i);
		}
	}

	for ( unsigned int i = 0; i < mRows.size(); i++ ) {
		if ( Cmp( r, mRows.at(i) ) == 0 ) {
			io.WriteRow( mRows.at(i) );
		}
	}
}