本文整理汇总了C++中CKData::SetSize方法的典型用法代码示例。如果您正苦于以下问题:C++ CKData::SetSize方法的具体用法?C++ CKData::SetSize怎么用?C++ CKData::SetSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CKData
的用法示例。
在下文中一共展示了CKData::SetSize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DayToMonth
int CKData::DayToMonth( CKData &kdday, CKData &kdmonth )
{
// convert day k line to month k line
SP_ASSERT( ktypeDay == kdday.GetKType() );
SP_ASSERT( ktypeMonth == kdmonth.GetKType() );
kdmonth.SetSize( 0, kdday.GetSize() / 20 + 5 );
int nStart = kdday.GetSize() % 3;
int nCount = 0;
KDATA dataDest;
memset( &dataDest, 0, sizeof(dataDest) );
int nYearCur = 0, nMonthCur = 0 ;
for( int pos=nStart; pos<kdday.GetSize(); pos++ )
{
KDATA & dataSrc = kdday.ElementAt( pos );
CSPTime tm;
if( !tm.FromStockTimeDay(dataSrc.m_date) )
continue;
int nYear = tm.GetYear();
int nMonth = tm.GetMonth();
if( nYear != nYearCur || nMonth != nMonthCur ) // a new month
{
if( 0 != pos )
kdmonth.Add( dataDest ); // add a month
memcpy( &dataDest, &dataSrc, sizeof(dataDest) ); // begin a new month
nYearCur = nYear;
nMonthCur = nMonth;
}
else
{
dataDest.m_fAmount += dataSrc.m_fAmount;
if( dataDest.m_fHigh < dataSrc.m_fHigh ) dataDest.m_fHigh = dataSrc.m_fHigh;
if( dataDest.m_fLow > dataSrc.m_fLow ) dataDest.m_fLow = dataSrc.m_fLow;
dataDest.m_fVolume += dataSrc.m_fVolume;
dataDest.m_fClose = dataSrc.m_fClose;
}
if( pos == kdday.GetSize()-1 ) // the latest one
kdmonth.Add( dataDest );
}
return kdmonth.GetSize();
}
示例2: DayToWeek
int CKData::DayToWeek( CKData &kdday, CKData &kdweek )
{
// convert day k line to week k line
SP_ASSERT( ktypeDay == kdday.GetKType() );
SP_ASSERT( ktypeWeek == kdweek.GetKType() );
kdweek.SetSize( 0, kdday.GetSize() / 5 + 5 );
int nStart = kdday.GetSize() % 3;
int nCount = 0;
KDATA dataDest;
memset( &dataDest, 0, sizeof(dataDest) );
for( int pos=nStart; pos<kdday.GetSize(); pos++ )
{
KDATA & dataSrc = kdday.ElementAt( pos );
CSPTime tm;
if( !tm.FromStockTimeDay(dataSrc.m_date) )
continue;
if( tm.GetDayOfWeek() == 2 ) // a new week
{
if( 0 != pos )
kdweek.Add( dataDest ); // add a week
memcpy( &dataDest, &dataSrc, sizeof(dataDest) ); // begin a new week
}
else
{
dataDest.m_fAmount += dataSrc.m_fAmount;
if( dataDest.m_fHigh < dataSrc.m_fHigh ) dataDest.m_fHigh = dataSrc.m_fHigh;
if( dataDest.m_fLow > dataSrc.m_fLow ) dataDest.m_fLow = dataSrc.m_fLow;
dataDest.m_fVolume += dataSrc.m_fVolume;
dataDest.m_fClose = dataSrc.m_fClose;
}
if( pos == kdday.GetSize()-1 ) // the latest one
kdweek.Add( dataDest );
}
return kdweek.GetSize();
}
示例3: ConvertKData
/////////////////////////////////////////////////////////////////////////////
// Private Operations
int CKData::ConvertKData( CKData &kdSrc, CKData &kdDest, int multiple )
{
// convert kdSrc k line to kdDest k line accordding to their multiple
SP_ASSERT( multiple > 1 );
if( multiple < 2 ) return 0;
kdDest.SetSize( 0, kdSrc.GetSize() / multiple + 5 );
int nStart = kdSrc.GetSize() % multiple;
int nCount = 0;
KDATA dataDest;
for( int pos=nStart; pos<kdSrc.GetSize(); pos++ )
{
KDATA & dataSrc = kdSrc.ElementAt( pos );
nCount ++;
if( 1 == nCount )
{
memcpy( &dataDest, &dataSrc, sizeof(dataDest) );
}
else
{
dataDest.m_fAmount += dataSrc.m_fAmount;
if( dataDest.m_fHigh < dataSrc.m_fHigh ) dataDest.m_fHigh = dataSrc.m_fHigh;
if( dataDest.m_fLow > dataSrc.m_fLow ) dataDest.m_fLow = dataSrc.m_fLow;
dataDest.m_fVolume += dataSrc.m_fVolume;
dataDest.m_fClose = dataSrc.m_fClose;
}
if( multiple == nCount ) // new dataDest is over
{
nCount = 0;
kdDest.Add( dataDest );
}
}
return kdDest.GetSize();
}