本文整理汇总了C++中CDWordArray::Add方法的典型用法代码示例。如果您正苦于以下问题:C++ CDWordArray::Add方法的具体用法?C++ CDWordArray::Add怎么用?C++ CDWordArray::Add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CDWordArray
的用法示例。
在下文中一共展示了CDWordArray::Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: EnumMonitorProc
BOOL CALLBACK EnumMonitorProc(HMONITOR hMonitor, HDC hdc, LPRECT prc, LPARAM lParam)
{
CDWordArray *parrHMonitor = (CDWordArray *)lParam;
parrHMonitor->Add((DWORD)hMonitor);
return TRUE;
}
示例2: GetResultIDs
int CTDLFindResultsListCtrl::GetResultIDs(const CFilteredToDoCtrl* pTDC, CDWordArray& aTaskIDs) const
{
CFTDResultsArray aResults;
int nNumRes = GetResults(pTDC, aResults);
for (int nRes = 0; nRes < nNumRes; nRes++)
aTaskIDs.Add(aResults[nRes].dwTaskID);
return aResults.GetSize();
}
示例3: Write
bool CAcceleratorManager::Write()
{
CDWordArray AccelsDatasArray;
CDWordArray CmdDatasArray;
int iCount = 0;
CCmdAccelOb*pCmdAccel;
CAccelsOb* pAccel;
DWORD dwAccelData;
WORD wKey;
POSITION pos = m_mapAccelTable.GetStartPosition();
while (pos != NULL)
{
m_mapAccelTable.GetNextAssoc(pos, wKey, pCmdAccel);
CmdDatasArray.RemoveAll();
POSITION pos = pCmdAccel->m_Accels.GetHeadPosition();
while (pos != NULL)
{
pAccel = pCmdAccel->m_Accels.GetNext(pos);
// if (!pAccel->m_bLocked) {
dwAccelData = pAccel->GetData();
CmdDatasArray.Add(dwAccelData);
// }
}
if (CmdDatasArray.GetSize() > 0)
{
CmdDatasArray.InsertAt(0, MAKELONG(pCmdAccel->m_wIDCommand, CmdDatasArray.GetSize()));
AccelsDatasArray.Append(CmdDatasArray);
iCount++;
}
}
// AccelsDatasArray.InsertAt(0, MAKELONG(65535, iCount));
int count = AccelsDatasArray.GetSize();
DWORD *data = (DWORD *)malloc(count * sizeof(DWORD));
ASSERT(data != NULL);
for (int index = 0; index < count; index++)
data[index] = AccelsDatasArray[index];
regSetBinaryValue("keyboard", (char *)data, count*sizeof(DWORD));
AccelsDatasArray.RemoveAll();
CmdDatasArray.RemoveAll();
free(data);
return true;
}
示例4: DoKeyedDeselect
// When starting a mouse-key select, the anchor point, and all contiguous
// selections that are not in the path of the current item can remain
// selected. All other selections are tossed, like Exploder does.
void CMultiSelTreeCtrl::DoKeyedDeselect( BOOL scrollingDown )
{
CDWordArray keepSet;
HTREEITEM currentItem= m_AnchorItem;
// Record the contiguous selection's we're keeping
keepSet.Add( (DWORD) m_AnchorItem );
while(1)
{
if( scrollingDown )
currentItem= GetPrevSiblingItem( currentItem);
else
currentItem= GetNextSiblingItem( currentItem);
if( currentItem == NULL || !IsSelected( currentItem ) )
break;
keepSet.Add( (DWORD) currentItem );
}
// Unselect everything
//
int i;
for( i= m_SelectionSet.GetSize()-1; i >= 0; i-- )
{
currentItem= (HTREEITEM) m_SelectionSet.GetAt(i);
// Undo any display atts
SetItemState(currentItem, 0, TVIS_CUT | TVIS_BOLD | TVIS_SELECTED);
}
// Then select everything in the keepset
//
m_SelectionSet.RemoveAll();
for( i= keepSet.GetSize()-1; i>=0; i-- )
SetSelectState( (HTREEITEM) keepSet.GetAt(i), TRUE );
m_PendingKeyedDeselect= FALSE;
ShowNbrSelected();
}
示例5: SelectItem
BOOL CTDCTaskListCtrl::SelectItem(int nItem)
{
m_lcTasks.SetSelectionMark(nItem);
m_lcColumns.SetSelectionMark(nItem);
// avoid unnecessary selections
if ((GetSelectedCount() == 1) && (GetSelectedItem() == nItem))
return TRUE;
CDWordArray aTaskIDs;
aTaskIDs.Add(GetTaskID(nItem));
return SelectTasks(aTaskIDs);
}
示例6:
CDWordArray *CGhostTextBuffer:: /* virtual override */
CopyRevisionNumbers(int nStartLine, int nEndLine) const
{
CDWordArray *paSavedRevisionNumbers = CCrystalTextBuffer::CopyRevisionNumbers(nStartLine, nEndLine);
for (int nLine = nEndLine; nLine >= nStartLine; --nLine)
{
if ((GetLineFlags(nLine) & LF_GHOST) != 0)
paSavedRevisionNumbers->RemoveAt(nLine - nStartLine);
}
if ((GetLineFlags(nEndLine) & LF_GHOST) != 0)
{
for (int nLine = nEndLine + 1; nLine < GetLineCount(); ++nLine)
if ((GetLineFlags(nLine) & LF_GHOST) == 0)
{
paSavedRevisionNumbers->Add(GetLineFlags(nLine));
break;
}
}
return paSavedRevisionNumbers;
}
示例7: StartNewGame
void CCLLKDlg::StartNewGame(void)
{
CTime t=CTime::GetCurrentTime();
tGameTime=t;
strTiShi1="系统时间:"+t.Format("%H:%M:%S");
m_StatusBar.SetText(strTiShi1,2,0);
strTiShi2.Format(" 该局时间:00:00:00");
m_StatusBar.SetText(strTiShi2,1,0);
strTiShi3.Format("当前游戏:%d行%d列%d种方块",m_nRow-2,m_nCol-2,m_Kind);
m_StatusBar.SetText(strTiShi3,0,0);
delete[] m_map;
m_map=new int[m_nCol*m_nRow];
for (int iNum=0;iNum<(m_nCol*m_nRow);iNum++)
{
m_map[iNum]=BLANK_STATE;
}
srand(time(NULL));
CDWordArray tmpMap;
for (int i=0;i<(m_nRow-2)*(m_nCol-2)/2;i++)
{
int x=rand()%m_Kind;
tmpMap.Add(x);
tmpMap.Add(x);
}
for (int i=1;i<(m_nCol-1);i++)
{
for (int j=1;j<(m_nRow-1);j++)
{
INT_PTR nIndex=(int(rand()*0.1+rand()*0.01+rand()))%tmpMap.GetSize();
m_map[i+j*m_nCol]=tmpMap.GetAt(nIndex);
tmpMap.RemoveAt(nIndex);
}
}
Invalidate(false);
}
示例8: GetNumbers
void CHexEdit :: GetNumbers ( CDWordArray & cArray )
{
// Get the array into shape.
cArray.RemoveAll ( ) ;
CString strRaw ;
GetWindowText ( strRaw ) ;
TCHAR * szBuff = (TCHAR*)new TCHAR[ strRaw.GetLength ( ) +
1 * sizeof ( TCHAR ) ] ;
_tcscpy ( szBuff , (LPCTSTR)strRaw ) ;
// Use good ol' strtok to do the deed.
TCHAR * pCurr = _tcstok ( szBuff , k_DELIMS ) ;
while ( NULL != pCurr )
{
// Try and convert it to an value. I'm taking the easy way out.
DWORD dwAddr ;
int iRet = _stscanf ( pCurr ,
_T ( "%x" ) ,
&dwAddr ) ;
if ( 1 != iRet )
{
CString sMsg ;
sMsg.FormatMessage ( IDS_LOADADDRBADCONVERSION ,
pCurr ) ;
AfxMessageBox ( sMsg ) ;
}
else
{
cArray.Add ( dwAddr ) ;
}
pCurr = _tcstok ( NULL , k_DELIMS ) ;
}
delete [] szBuff ;
}
示例9: RestoreSelection
void CTDCTaskListCtrl::RestoreSelection(const TDCSELECTIONCACHE& cache)
{
if (cache.aSelTaskIDs.GetSize() == 0)
{
DeselectAll();
return;
}
DWORD dwFocusedTaskID = cache.dwFocusedTaskID;
ASSERT(dwFocusedTaskID);
if (FindTaskItem(dwFocusedTaskID) == -1)
{
dwFocusedTaskID = 0;
int nID = cache.aBreadcrumbs.GetSize();
while (nID--)
{
dwFocusedTaskID = cache.aBreadcrumbs[nID];
if (FindTaskItem(dwFocusedTaskID) != -1)
break;
else
dwFocusedTaskID = 0;
}
}
// add focused task if it isn't already
CDWordArray aTaskIDs;
aTaskIDs.Copy(cache.aSelTaskIDs);
if (Misc::FindT(aTaskIDs, dwFocusedTaskID) == -1)
aTaskIDs.Add(dwFocusedTaskID);
SetSelectedTasks(aTaskIDs, dwFocusedTaskID);
// restore pos
if (cache.dwFirstVisibleTaskID)
SetTopIndex(FindTaskItem(cache.dwFirstVisibleTaskID));
}
示例10: GetCardValue
//.........这里部分代码省略.........
arrWinnerCardsIdx[2] = 6; // table card 3 index
arrWinnerCardsIdx[3] = 7; // table card 4 index
arrWinnerCardsIdx[4] = 1; // hand card 2 index
}
for( int j=0; j<4; j++ ){
// Copy cards array.
memcpy(arrCardsReplaced, arrCards, sizeof(arrCards));
arrCardsReplaced[j] = nHandCardVal1;
arrCardsReplaced[4] = nHandCardVal2;
nBestHandCardsValTemp = GetHandValue(arrCardsReplaced[0], arrCardsReplaced[1], arrCardsReplaced[2], arrCardsReplaced[3], arrCardsReplaced[4]);
if( nBestHandCardsVal > nBestHandCardsValTemp ){
nBestHandCardsVal = nBestHandCardsValTemp;
arrWinnerCardsIdx[0] = 4; // table card 1 index
arrWinnerCardsIdx[1] = 5; // table card 2 index
arrWinnerCardsIdx[2] = 6; // table card 3 index
arrWinnerCardsIdx[3] = 7; // table card 4 index
arrWinnerCardsIdx[4] = 1; // hand card 2 index
arrWinnerCardsIdx[j] = 0; // hand card 1 index
}
}
}
// 5 table cards.
else{
for( int j=0; j<5; j++ ){
// Copy cards array.
memcpy(arrCardsReplaced, arrCards, sizeof(arrCards));
arrCardsReplaced[j] = nHandCardVal1;
nBestHandCardsValTemp = GetHandValue(arrCardsReplaced[0], arrCardsReplaced[1], arrCardsReplaced[2], arrCardsReplaced[3], arrCardsReplaced[4]);
if( nBestHandCardsVal > nBestHandCardsValTemp ){
nBestHandCardsVal = nBestHandCardsValTemp;
arrWinnerCardsIdx[0] = 4; // table card 1 index
arrWinnerCardsIdx[1] = 5; // table card 2 index
arrWinnerCardsIdx[2] = 6; // table card 3 index
arrWinnerCardsIdx[3] = 7; // table card 4 index
arrWinnerCardsIdx[4] = 8; // table card 5 index
arrWinnerCardsIdx[j] = 0; // hand card 1 index
}
}
for( int j=0; j<5; j++ ){
// Copy cards array.
memcpy(arrCardsReplaced, arrCards, sizeof(arrCards));
arrCardsReplaced[j] = nHandCardVal2;
nBestHandCardsValTemp = GetHandValue(arrCardsReplaced[0], arrCardsReplaced[1], arrCardsReplaced[2], arrCardsReplaced[3], arrCardsReplaced[4]);
if( nBestHandCardsVal > nBestHandCardsValTemp ){
nBestHandCardsVal = nBestHandCardsValTemp;
arrWinnerCardsIdx[0] = 4; // table card 1 index
arrWinnerCardsIdx[1] = 5; // table card 2 index
arrWinnerCardsIdx[2] = 6; // table card 3 index
arrWinnerCardsIdx[3] = 7; // table card 4 index
arrWinnerCardsIdx[4] = 8; // table card 5 index
arrWinnerCardsIdx[j] = 1; // hand card 2 index
}
}
for( int j=0; j<5; j++ ){
for( int k=j+1; k<5; k++ ){
// Copy cards array.
memcpy(arrCardsReplaced, arrCards, sizeof(arrCards));
arrCardsReplaced[j] = nHandCardVal1;
arrCardsReplaced[k] = nHandCardVal2;
nBestHandCardsValTemp = GetHandValue(arrCardsReplaced[0], arrCardsReplaced[1], arrCardsReplaced[2], arrCardsReplaced[3], arrCardsReplaced[4]);
if( nBestHandCardsVal > nBestHandCardsValTemp ){
nBestHandCardsVal = nBestHandCardsValTemp;
arrWinnerCardsIdx[0] = 4; // table card 1 index
arrWinnerCardsIdx[1] = 5; // table card 2 index
arrWinnerCardsIdx[2] = 6; // table card 3 index
arrWinnerCardsIdx[3] = 7; // table card 4 index
arrWinnerCardsIdx[4] = 8; // table card 5 index
arrWinnerCardsIdx[j] = 0; // hand card 1 index
arrWinnerCardsIdx[k] = 1; // hand card 2 index
}
}
}
}
_String sClassName;
cardsClass = CardsHandClass(nBestHandCardsVal, &sClassName);
if( cardsClass != PokerHandCardsClass::CardsClass_None ){
arrCardsIdx.Add(arrWinnerCardsIdx[0]);
arrCardsIdx.Add(arrWinnerCardsIdx[1]);
arrCardsIdx.Add(arrWinnerCardsIdx[2]);
arrCardsIdx.Add(arrWinnerCardsIdx[3]);
arrCardsIdx.Add(arrWinnerCardsIdx[4]);
}
return nBestHandCardsVal;
}
示例11: CResult
CResult * CMarkovChain::OnCMarkovChain(CDataInterface *pDataInterface, string VO)
{
CResult * pResult;
pResult = new CResult("马尔可夫链");
m_pResult = pResult;
m_pDataInterface = pDataInterface;
if (!GetValueFromVo(pDataInterface, VO))
{
CTString strWarning = "读取参数发生错误,请重新运行!";
CRsltElementText * pWarningTextRslt = new CRsltElementText( "错误!" );
pWarningTextRslt->AddString( strWarning );
m_pResult->Add( pWarningTextRslt );
return pResult;
}
CDWordArray indexary;
CDoubleMatrix Data_Matrix;
indexary.Add(m_nUserID);
indexary.Add(m_nPath);
// if (m_nTime > -1)
// indexary.Add(m_nTime);
m_nRow = pDataInterface->GetColsData(indexary, Data_Matrix, 0);//取回界面数据
// if (m_nTime > -1)
// {
// CDoubleVector tempSort_vec = Data_Matrix(2);
// CIntVector tempSort_id(m_nRow);
// tempSort_vec.Sort(tempSort_id);
// m_ID_vec.create(m_nRow);
// m_Path_vec.create(m_nRow);
// for (int j=0; j<m_nRow; j++)
// {
// m_ID_vec(j) = Data_Matrix(0, tempSort_id(j)-1);
// m_Path_vec(j) = Data_Matrix(1, tempSort_id(j)-1);
// }
// }
// else
{
m_ID_vec = Data_Matrix(0);
m_Path_vec = Data_Matrix(1);
}
if (Main() )
{
DrawResult();
}
else
{
CTString strWarning = "数据无法计算,请重新运行!";
CRsltElementText * pWarningTextRslt = new CRsltElementText( "错误!" );
pWarningTextRslt->AddString( strWarning );
m_pResult->Add( pWarningTextRslt );
return pResult;
}
// if (m_bSaveModle)
// {
// ...
// }
return pResult;
}
示例12: start_vec
CResult * CMarkovChain::OnMorkovChainPred(CDataInterface *pDataInterface, string VO)//外部调用预测函数
{
m_pResult = new CResult("线性回归模型预测结果");
m_pDataInterface = pDataInterface;
if (!GetPredValueVo(pDataInterface, VO))//读参数及模型
{
CRsltElementText * pWarningTextRslt = new CRsltElementText( "错误!" );
pWarningTextRslt->AddString( "模型参数有误,无法运行。" );
m_pResult->Add( pWarningTextRslt );
return m_pResult;
}
//读取数据
CDWordArray indexary;
CDoubleMatrix Data_Matrix;
indexary.Add(m_nUserID);
indexary.Add(m_nPath);
m_nRow = pDataInterface->GetColsData(indexary, Data_Matrix, 0);//取回界面数据
m_ID_vec = Data_Matrix(0);
m_Path_vec = Data_Matrix(1);
CDoubleVector start_vec(m_nRow);
CDoubleVector pairID_vec(m_nRow);
CDoubleVector length_vec(m_nRow, 0);
int i=0, L, id=0;
// 数据准备(Preprocessing) begin
//
while (i < m_nRow)
{
L=0;
start_vec(id) = i;
pairID_vec(id) = m_ID_vec(i);
while (pairID_vec(id) == m_ID_vec(i))
{
length_vec(id)++;
i++;
if (i >= m_nRow)
{
break;
}
}
id++;
}
m_nTotalID = id;
start_vec.resize(m_nTotalID);
pairID_vec.resize(m_nTotalID);
length_vec.resize(m_nTotalID);
//数据准备(Preprocessing) end
//开始计算
int k, t;
CDoubleMatrix responsibility(m_nTotalID, m_nCluster);
for (i=0; i<m_nTotalID; i++)
{
L=length_vec(i);
for (k=0; k<m_nCluster; k++)
{
double temp = 1;
for (t=start_vec(i); t<start_vec(i)+L-1; t++)
{
temp *= m_Theta_Trans[k](m_Path_vec(t)-1,m_Path_vec(t+1)-1);
}
responsibility(i,k) = temp;
}
}
for (i=0; i<m_nCluster; i++) // Normalization of the responsibilities
{
double s = 0;
for (k=0; k<m_nCluster; k++)
{
s = s + responsibility(i,k);
}
for (k=0; k<m_nCluster; k++)
{
responsibility(i,k) = responsibility(i,k)/s;
}
}
m_VecClus.create(m_nTotalID);
for (i=0; i<m_nTotalID; i++)
{
int which = 0;
for (k=0; k<m_nCluster; k++)
{
if (responsibility(i, which) > responsibility(i,k))
{
which = k;
}
}
m_VecClus(i) = which;
}
//完成计算
DrawResult();
return m_pResult;
}
示例13: CalcHistogram
bool CHistogram::CalcHistogram()
{
int i=0, j=0, k=0;
int nIndex=0, nPtCnt=0, nGroupIndex=0;
int nColIndex=0, nRowCount=0, nDataType=0;
double fTmp=0;
CDWordArray arrCol;
CMapManager dataMap;
CDoubleMatrix dataMatrix;
CIntVector vIndex;
CDoubleVector v;
CTString szTemp("");
CTString szFldNameX("");
CTString szFldNameY("");
if (m_tVarY.iCount > 0)
{
for (i=0; i<m_tVarY.iCount; i++)
{
nGroupIndex = m_tVarY.pValue[i];
szFldNameY = m_pDataInterface->GetFieldName(nGroupIndex);
for (j=0; j<m_tVarX.iCount; j++)
{
nColIndex = m_tVarX.pValue[j];
arrCol.Add(nGroupIndex);
arrCol.Add(nColIndex);
szFldNameX = m_pDataInterface->GetFieldName(nColIndex);
nRowCount = m_pDataInterface->GetColsData(arrCol,dataMatrix,dataMap);
if (nRowCount < 1)
{
szTemp.Format("%s中的有效数据太少(分组变量=%s,数据变量=%s),无法绘图,请检查,Line=%d,File=%s",m_szChartName.GetData(),szFldNameY.GetData(),szFldNameX.GetData(),__LINE__,__FILE__);
m_szErrMsg += szTemp;
arrCol.RemoveAll();
dataMap.Clear();
dataMatrix.destroy();
continue;
}
//有效数据
v.create(nRowCount);
CDoubleVector v1 = dataMatrix(0);
CDoubleVector v2 = dataMatrix(1);
v1.Sort(vIndex);
fTmp = v1(0);
nIndex = 0;
for (k=0; k<nRowCount; k++)
{
if (fTmp == v1(k))
{
v(nIndex) = v2(vIndex(k)-1);
nIndex ++;
continue;
}
szTemp = GetLabel(dataMap,0,nGroupIndex,fTmp);
szTemp = "\n" + szTemp;
//直方图
v.resize(nIndex);
CalcHistogram(v,szFldNameX+szTemp);
v.destroy();
v.create(nRowCount);
fTmp = v1(k);
nIndex =0;
v(nIndex) = v2(vIndex(k)-1);
}
//最后
szTemp = GetLabel(dataMap,0,nGroupIndex,fTmp);
szTemp = "\n" + szTemp;
//直方图
v.resize(nIndex);
CalcHistogram(v,szFldNameX+szTemp);
v.destroy();
v.create(nRowCount);
//释放内存
vIndex.destroy();
dataMap.Clear();
arrCol.RemoveAll();
dataMatrix.destroy();
}
}
}
else
{
for (i=0; i<m_tVarX.iCount; i++)
{
nColIndex = m_tVarX.pValue[i];
arrCol.Add(nColIndex);
szFldNameX = m_pDataInterface->GetFieldName(nColIndex);
nRowCount = m_pDataInterface->GetColsData(arrCol,dataMatrix,0);
if (nRowCount < 1)
{
szTemp.Format("%s中的有效数据太少(%s),无法绘图,请检查,Line=%d,File=%s",m_szChartName.GetData(),szFldNameX.GetData(),__LINE__,__FILE__);
m_szErrMsg += szTemp;
arrCol.RemoveAll();
dataMatrix.destroy();
continue;
}
//有效数据
v = dataMatrix(0);
//直方图
CalcHistogram(v,szFldNameX);
//释放内存
//.........这里部分代码省略.........
示例14: GetCardValue
//.........这里部分代码省略.........
int nHandCardVal1 = GetCardValue(nCard1);
int nHandCardVal2 = GetCardValue(nCard2);
int nHandCardVal3 = GetCardValue(nCard3);
int nHandCardVal4 = GetCardValue(nCard4);
int nBestHandCardsVal = 0x7fffffff;
int nBestHandCardsValTemp = 0;
HandCardsCombination comb[] =
{
{nHandCardVal1, nHandCardVal2, 0, 1},
{nHandCardVal1, nHandCardVal3, 0, 2},
{nHandCardVal1, nHandCardVal4, 0, 3},
{nHandCardVal2, nHandCardVal3, 1, 2},
{nHandCardVal2, nHandCardVal4, 1, 3},
{nHandCardVal3, nHandCardVal4, 2, 3}
};
// 3 table cards
if( nTableCard4 <= -1 ){
for( int x=0; x<6; x++){
HandCardsCombination* pComb = &comb[x];
// Copy cards array.
memcpy(arrCardsReplaced, arrCards, sizeof(arrCards));
arrCardsReplaced[3] = pComb->nHandCardVal1;
arrCardsReplaced[4] = pComb->nHandCardVal2;
nBestHandCardsValTemp = GetHandValue(arrCardsReplaced[0], arrCardsReplaced[1], arrCardsReplaced[2], arrCardsReplaced[3], arrCardsReplaced[4]);
if( nBestHandCardsVal > nBestHandCardsValTemp ){
nBestHandCardsVal = nBestHandCardsValTemp;
arrWinnerCardsIdx[0] = 4; // table card 1 index
arrWinnerCardsIdx[1] = 5; // table card 2 index
arrWinnerCardsIdx[2] = 6; // table card 3 index
arrWinnerCardsIdx[3] = pComb->nHandCardIndex1; // hand card index
arrWinnerCardsIdx[4] = pComb->nHandCardIndex2; // hand card index
}
}
}
else
// 4 table cards.
if( nTableCard5 <= -1 ){
for( int x=0; x<6; x++){
HandCardsCombination* pComb = &comb[x];
for( int j=0; j<4; j++ ){
// Copy cards array.
memcpy(arrCardsReplaced, arrCards, sizeof(arrCards));
arrCardsReplaced[j] = pComb->nHandCardVal1;
arrCardsReplaced[4] = pComb->nHandCardVal2;
nBestHandCardsValTemp = GetHandValue(arrCardsReplaced[0], arrCardsReplaced[1], arrCardsReplaced[2], arrCardsReplaced[3], arrCardsReplaced[4]);
if( nBestHandCardsVal > nBestHandCardsValTemp ){
nBestHandCardsVal = nBestHandCardsValTemp;
arrWinnerCardsIdx[0] = 4; // table card 1 index
arrWinnerCardsIdx[1] = 5; // table card 2 index
arrWinnerCardsIdx[2] = 6; // table card 3 index
arrWinnerCardsIdx[3] = 7; // table card 4 index
arrWinnerCardsIdx[4] = pComb->nHandCardIndex2; // hand card index
arrWinnerCardsIdx[j] = pComb->nHandCardIndex1; // hand card index
}
}
}
}
// 5 table cards.
else{
for( int x=0; x<6; x++){
HandCardsCombination* pComb = &comb[x];
for( int j=0; j<5; j++ ){
for( int k=j+1; k<5; k++ ){
// Copy cards array.
memcpy(arrCardsReplaced, arrCards, sizeof(arrCards));
arrCardsReplaced[j] = pComb->nHandCardVal1;
arrCardsReplaced[k] = pComb->nHandCardVal2;
nBestHandCardsValTemp = GetHandValue(arrCardsReplaced[0], arrCardsReplaced[1], arrCardsReplaced[2], arrCardsReplaced[3], arrCardsReplaced[4]);
if( nBestHandCardsVal > nBestHandCardsValTemp ){
nBestHandCardsVal = nBestHandCardsValTemp;
arrWinnerCardsIdx[0] = 4; // table card 1 index
arrWinnerCardsIdx[1] = 5; // table card 2 index
arrWinnerCardsIdx[2] = 6; // table card 3 index
arrWinnerCardsIdx[3] = 7; // table card 4 index
arrWinnerCardsIdx[4] = 8; // table card 5 index
arrWinnerCardsIdx[j] = pComb->nHandCardIndex1; // hand card index
arrWinnerCardsIdx[k] = pComb->nHandCardIndex2; // hand card index
}
}
}
}
}
_String sClassName;
cardsClass = CardsHandClass(nBestHandCardsVal, &sClassName);
if( cardsClass != PokerHandCardsClass::CardsClass_None ){
arrCardsIdx.Add(arrWinnerCardsIdx[0]);
arrCardsIdx.Add(arrWinnerCardsIdx[1]);
arrCardsIdx.Add(arrWinnerCardsIdx[2]);
arrCardsIdx.Add(arrWinnerCardsIdx[3]);
arrCardsIdx.Add(arrWinnerCardsIdx[4]);
}
return nBestHandCardsVal;
}
示例15: EmbedeedFont
bool
EmbedeedFontMan::AddFont(const CString sFontFolder, const CString sFontName){
CString sDir = sFontFolder;
if( sDir.GetAt(sDir.GetLength() - 1) != '\\' )
sDir += _T("\\");
EmbedeedFont* pFont = new EmbedeedFont();
// Load characters code map. {{
BYTE* lpContent = NULL;
int nSize = 0;
if( Path::ReadFileContent(sDir + _T("codes.txt"), lpContent, nSize) && nSize > 0 ){
CString sContent;
memcpy(sContent.GetBufferSetLength(nSize), lpContent, nSize);
CStringArray arrStrings;
StringHelper::Split(&sContent, _T(";"), arrStrings);
CString sCharCode;
for(int i=0; i<arrStrings.GetCount(); i++){
sCharCode = arrStrings.GetAt(i);
int nCharCode = 0;
// Hex value
if( sCharCode.GetAt(0) == '#' )
nCharCode = StringHelper::HexStringIntoInt(&((TCHAR*)sCharCode.GetBuffer())[1], sCharCode.GetLength() - 1);
else
nCharCode = _ttoi(sCharCode.GetBuffer());
pFont->m_arrCharacters.Add((void*)nCharCode, (void*)i);
}
}
else{
#ifdef _DEBUG
CString sMsg;
sMsg.Format(_T("Couldn't find %s"), sDir + _T("codes.txt"));
AfxMessageBox(sMsg);
#endif
if( lpContent )
delete [] lpContent;
delete pFont;
return false;
}
// }}
if( lpContent ){
delete [] lpContent;
lpContent = NULL;
}
CStringArray arrFileNames;
if( Path::GetFilesByExtention(sDir, _T("*.bmp"), arrFileNames, true) == 0 ){
delete pFont;
return false;
}
for(int i=0; i<arrFileNames.GetCount(); i++){
CString sName = arrFileNames.GetAt(i);
CString sName2 = sName;
CString sFile = sDir + sName;
if( sName.Left(sFontName.GetLength()) != sFontName )
continue; // Skip wrong file name.
sName.Delete (0, sFontName.GetLength());
sName.MakeLower ();
int nIndex = 0;
EmbedeedFontItemInfo* pInfo = new EmbedeedFontItemInfo();
pInfo->ZeroInit();
// Bold
if( sName.GetAt(nIndex) == 'b' ){
pInfo->m_nCharFlags |= EmbedeedFontItemInfo::EMBEDEED_FONT_FLAG_BOLD;
nIndex ++;
}
// Underline
if( sName.GetAt(nIndex) == 'u' ){
pInfo->m_nCharFlags |= EmbedeedFontItemInfo::EMBEDEED_FONT_FLAG_UNDERLINE;
nIndex ++;
}
// Italic
if( sName.GetAt(nIndex) == 'i' ){
pInfo->m_nCharFlags |= EmbedeedFontItemInfo::EMBEDEED_FONT_FLAG_ITALIC;
nIndex ++;
}
// Load characters map image and detect characters left offset and width (in pixels). {{
CImage* pImage = ImageHelper::LoadImage(sFile, -1, -1, false);
if( pImage ){
BITMAP bmImage;
GetObject(*pImage, sizeof(BITMAP), &bmImage);
int nWidthLimit = bmImage.bmWidth;
int nSymbolCt = 0;
BYTE* pBits = (BYTE*)bmImage.bmBits;
int nXOffset = 0;
int nBPP = bmImage.bmBitsPixel/8;
int nSymbolMostLeftOffset = -1;
int nSymbolMostRightOffset = -1;
CDWordArray arrSymbolLeftOffsetAndWidth;
CString sSymbolStartPointAndWidth;
//.........这里部分代码省略.........