本文整理汇总了C++中CList::GetAt方法的典型用法代码示例。如果您正苦于以下问题:C++ CList::GetAt方法的具体用法?C++ CList::GetAt怎么用?C++ CList::GetAt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CList
的用法示例。
在下文中一共展示了CList::GetAt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnAllVideoTypes
BOOL CNetClient::OnAllVideoTypes()
{
//CMainFrame *pWnd=(CMainFrame*)AfxGetMainWnd();
//CTypeManager typeMgr(&pWnd->m_adoConnection);
CTypeManager typeMgr(&g_pWnd->m_adoConnection);
CList<CType,CType> lstType;
typeMgr.GetAllType(&lstType);
CType type;
CString strData;
//发送的字符串的格式:"战争片,1,喜剧片,2,古装片,3 "
for (int i=0;i<lstType.GetCount();i++)
{
type=lstType.GetAt(lstType.FindIndex(i));
strData+=type.strTypeName;
strData+=",";
CString strID;
strID.Format("%d,",type.nTypeID);
strData+=strID;
}
//首先发送数据长度,然后发送数据
int nLen=strData.GetLength();
LPSTR pData=(LPSTR)malloc(nLen+1);
memset(pData,0,nLen+1);
strcpy(pData,strData);
SendData(VODNETCMD_TYPES_RET,pData,strData.GetLength());
free(pData);
return TRUE;
}
示例2: GetDelParamlst
int CDlgParamSet::GetDelParamlst(vector<ZTreeParam*> &vecParams,int &nGroupCount)
{
int ncount =0;
ZTreeParam* pParam = NULL;
CBCGPGridItem*pItem = NULL;
CZGridRow *pRow = NULL;
CList <CBCGPGridItem*, CBCGPGridItem*> lstSelected;
m_wndGridTree.GetSelectedItems (lstSelected);
for (POSITION pos = lstSelected.GetHeadPosition(); pos != NULL; )
{
pItem = lstSelected.GetAt(pos);
lstSelected.GetNext(pos);
pRow = (CZGridRow*)pItem->GetParentRow();
pParam = (ZTreeParam*)pRow->GetData();
if (pParam==NULL)
continue;
if (pParam->m_bIsGroup)
nGroupCount++;
ncount++;
vecParams.push_back(pParam);
}
return ncount;
}
示例3: GetNextRowAfterDel
CZGridRow* CDlgParamSet::GetNextRowAfterDel( CZGridRow*pCurItem)
{
CZGridRow* pParaentItem=NULL;
CZGridRow* pNextItem=NULL;
CList<CBCGPGridRow*, CBCGPGridRow*> lst;
//要删除的pRow
//pCurItem = (CZGridRow*)m_wndGridTree.GetRow(nIndex);
//if (pCurItem==NULL) return n;
pParaentItem = (CZGridRow*)pCurItem->GetParent();
pParaentItem->GetSubItems(lst);
POSITION pos =lst.Find(pCurItem);
lst.GetNext (pos);
if (pos==NULL)
pNextItem=pParaentItem;
else
pNextItem=(CZGridRow*)lst.GetAt(pos);
return pNextItem;
}
示例4: InsertNewSelection
//****************************************************************************************
int CBCGPGridSerializeManager::InsertNewSelection (int nInsertPos, CList<CBCGPGridRow*, CBCGPGridRow*> & lst)
{
ASSERT (m_pOwnerGrid != NULL);
int nCount = 0;
for (POSITION pos = lst.GetHeadPosition (); pos != NULL; )
{
POSITION posSave = pos;
CBCGPGridRow* pRow = lst.GetNext (pos);
if (pRow != NULL)
{
ASSERT_VALID (pRow);
//-----------------------------------------
// Insert new row at the specified position
//-----------------------------------------
int nRowIndex = -1;
if (m_pOwnerGrid->GetRowCount () <= nInsertPos + nCount)
{
nRowIndex = m_pOwnerGrid->InsertRowAfter (nInsertPos + nCount, pRow, FALSE);
}
else
{
nRowIndex = m_pOwnerGrid->InsertRowBefore (nInsertPos + nCount, pRow, FALSE);
}
if (nRowIndex >= 0)
{
nCount++;
lst.GetAt (posSave) = NULL;
ASSERT (nRowIndex >= nInsertPos);
ASSERT (nRowIndex <= nInsertPos + nCount);
}
}
}
if (nCount > 0)
{
// Save inserted range
m_InsertRange.SetRows (nInsertPos, nCount, TRUE);
// Shift marked ranges
for (int j = 0; j < m_arrCutRanges.GetSize (); j++)
{
m_arrCutRanges [j].OnInsertRange (nInsertPos, nCount);
}
}
return nCount;
}
示例5: CheckCollision
//碰撞检测
void GameManager::CheckCollision()
{
for (int i = Index_Player; i <= Index_Tool; ++i)//Index_Bomb
{
if (i == Index_Explosion)continue;
CList<GameObject*, GameObject*> *listA = GetList(i);
POSITION posA = listA->GetHeadPosition();
while (posA != NULL)
{
FlyObject* objectA = static_cast<FlyObject*>(listA->GetAt(posA));
for (int j = Index_Player; j <= Index_Tool; ++j)//Index_Bomb
{
if (j == Index_Explosion)continue;
CList<GameObject*, GameObject*> *listB = GetList(j);
POSITION posB = listB->GetHeadPosition();
while (posB != NULL)
{
FlyObject* objectB = static_cast<FlyObject*>(listB->GetAt(posB));
//碰撞检测
if (objectA->Group() == objectB->Group())
{
listB->GetNext(posB);
continue;
}
CPoint leftTop = CPoint(objectA->X() - objectB->Width() / 2, objectA->Y() - objectB->Height() / 2);
CPoint rightBottom = CPoint(objectA->X() + objectA->Width() + objectB->Width() / 2, objectA->Y() + objectA->Height() + objectB->Height() / 2);
CPoint objectCenter = CPoint(objectB->X() + objectB->Width()/2, objectB->Position()->Y() + objectB->Height() / 2);
if (objectCenter.x <= rightBottom.x && objectCenter.y <= rightBottom.y && objectCenter.x >= leftTop.x && objectCenter.y >= leftTop.y)
{
Collision(objectA, objectB);
}
listB->GetNext(posB);
}
}
listA->GetNext(posA);
}
}
}
示例6: while
~tScriptState()
{
int i;
for (i = 0; i < Commands.GetCount(); ++i)
{
tCommand *pCmd = Commands.GetAt(i);
delete pCmd;
}
POSITION pos = Labels.GetHeadPosition();
while (pos)
{
tLabel *pLabel = Labels.GetAt(pos);
delete pLabel;
Labels.GetNext(pos);
}
}
示例7: FindLabelByName
bool tScriptState::FindLabelByName(const tParameter& param, ULONG *pStep)
{
if (param._type != ptString) return FALSE;
if (!param.IsString()) return FALSE;
if (!Labels.GetCount()) return FALSE;
POSITION pos = Labels.GetHeadPosition();
while (pos)
{
tLabel *pLabel = Labels.GetAt(pos);
if (!pLabel->name.CompareNoCase(param.String()))
{
if (pStep) *pStep = pLabel->index;
return TRUE;
}
Labels.GetNext(pos);
}
return FALSE;
}
示例8: OnVideosByTypeID
BOOL CNetClient::OnVideosByTypeID()
{
//接收客户端的数据
GETVIDEOS getVideo;
if (!RecvData(&getVideo,sizeof(getVideo)))
{
return FALSE;
}
//数据库查询指定类型ID的所有视频
//CMainFrame *pWnd=(CMainFrame*)AfxGetMainWnd();
//CVideoManager videoMgr(&pWnd->m_adoConnection);
CVideoManager videoMgr(&g_pWnd->m_adoConnection);
CList<CVideo,CVideo> lstVideo;
videoMgr.GetVideosByTypeID(getVideo.typdID,&lstVideo);
//返回给客户端数据,返回的视频信息的格式,
//"敢死队,1,泰囧,22,西游记,31 "
CVideo v;
CString strData;
for (int i=0;i<lstVideo.GetCount();i++)
{
v=lstVideo.GetAt(lstVideo.FindIndex(i));
strData+=v.strVideoName;
strData+=",";
CString strID;
strID.Format("%d,",v.nVideoID);
strData+=strID;
}
//首先发送数据长度,然后发送数据
int nLen=strData.GetLength();
LPSTR pData=(LPSTR)malloc(nLen+1);
memset(pData,0,nLen+1);
strcpy(pData,strData);
SendData(VODNETCMD_TYPES_RET,pData,strData.GetLength());
free(pData);
return TRUE;
}
示例9: types
void CHello2Dlg::OnProcessSel(int id)
{
int curch = m_chlist.GetCurSel();
if(m_cmdbase == ID_32773) //data operation
{
CList<double,double> *data = &m_ridlgs[curch]->m_data;
if(m_ridlgs[curch]->show_type == SHOW_ORGDATA)
data = &m_ridlgs[curch]->m_output;
if(id == 1) //show converted result
{
m_ridlgs[curch]->show_type = SHOW_MAINDATA;
}
if(id == 2) //show raw result
{
m_ridlgs[curch]->show_type = SHOW_ORGDATA;
}
if(id == 3) //delete the current record
{
int pos = m_history.GetCurSel();
if((pos >= 0) && (data))
{
POSITION p = data->GetHeadPosition();
while(pos-- > 0 )
data->GetNext(p);
data->RemoveAt(p);
}
}
if(id == 4) //delete all the record
{
data->RemoveAll();
}
if(id == 5) //export all the record
{
CFile cf;
if(!cf.Open(DATAOUT_NAME,CFile::modeCreate|CFile::modeWrite))
return;
//write to txt and open with notepad
if(data && (data->GetCount() > 0))
{
POSITION pos = data->GetHeadPosition();
char r[50];
do{
double v = data->GetAt(pos);
sprintf(r,"%8f\r\n",v);
cf.Write(r,strlen(r));
if(pos == data->GetTailPosition())
break;
data->GetNext(pos);
}while(1);
}
cf.Close();
SHELLEXECUTEINFO execInf;
ZeroMemory (&execInf, sizeof (execInf));
execInf.cbSize = sizeof (SHELLEXECUTEINFO);
execInf.fMask = SEE_MASK_NOCLOSEPROCESS;
execInf.nShow = SW_SHOWNORMAL;
execInf.lpFile = _T("\\windows\\pword.exe");
execInf.lpVerb = _T("open");
execInf.lpParameters = DATAOUT_NAME;
ShellExecuteEx (&execInf);
}
}
if(m_cmdbase == ID_32772)
{
if(id == 1)
{
m_ridlgs[curview]->sidedata = NULL;
}else{
m_ridlgs[curview]->sidedata = &m_ridlgs[id-2]->m_data;
m_ridlgs[curview]->side_ch = id-2;
}
m_ridlgs[curview]->SaveLastConfig();
}
if(m_cmdbase == ID_32771) //channel config
{
if(m_cfgtype == CFGTYPE_BORE)
{
CSetting<PROBECFG> prbset;
prbset.InstallFromFile(PRB_DEFINFO);
if(id == 1)//just close it
{
m_ridlgs[curch]->cfg_now = CFGTYPE_NONE;
for(int i=0;i<sizeof(m_ridlgs)/sizeof(CRunitemDialog*);i++){
if((m_ridlgs[i]->cfg_now == CFGTYPE_BORE) && (i != curch) && (m_ridlgs[i]->side_ch == curch))
{
m_ridlgs[i]->sidedata = NULL;
}
}
}else{
m_ridlgs[curch]->m_prbid = prbset.GetNameAt(id-2);
m_ridlgs[curch]->cfg_now = CFGTYPE_BORE;
//.........这里部分代码省略.........
示例10:
void CHello2Dlg::Refresh()
{
int curch = m_chlist.GetCurSel();
if(curch < 0)
return;
int curcfg = m_cfgtype;
//clear the history and graph
while(m_history.GetCount() > 0)
m_history.DeleteString(0);
if(m_ridlgs[curch]->cfg_now != m_cfgtype)
{
m_graph.AssignMainData(NULL);
m_graph.AssignSideData(NULL);
m_graph.Invalidate();
return;
}
//update data shown in graph, (data and text)
m_graph.AssignMainData(&m_ridlgs[curch]->m_data);
m_graph.ch = curch;
m_graph.AssignSideData(m_ridlgs[curch]->sidedata);
m_graph.side_ch = m_ridlgs[curch]->side_ch;
CString dat;
if(m_ridlgs[curch]->cfg_now == CFGTYPE_THMO)
{
m_graph.smalltext.Format(_T("%.4f mV"),CGraph::GetAverage(&m_ridlgs[curch]->m_output));
m_graph.bigtext.Format(_T("%.4f ℃"),CGraph::GetAverage(&m_ridlgs[curch]->m_data));
}else{
if(m_ridlgs[curch]->cfg_now == CFGTYPE_RESI)
{
m_graph.smalltext.Format(_T("%.4f Ω"),CGraph::GetAverage(&m_ridlgs[curch]->m_output));
m_graph.bigtext.Format(_T("%.4f ℃"),CGraph::GetAverage(&m_ridlgs[curch]->m_data));
}else{
m_graph.smalltext = m_ridlgs[curch]->m_smalltxt;
m_graph.bigtext = m_ridlgs[curch]->m_bigtxt;
}
}
m_graph.ch = curview;
m_graph.Invalidate();
//add data to history listbox
CList<double,double> *data = &m_ridlgs[curch]->m_data;
if(m_ridlgs[curch]->show_type == SHOW_ORGDATA)
data = &m_ridlgs[curch]->m_output;
if(data && (data->GetCount() > 0))
{
POSITION pos = data->GetHeadPosition();
do{
double v = data->GetAt(pos);
CString r;
r.Format(_T("%8f"),v);
m_history.AddString(r);
if(pos == data->GetTailPosition())
break;
data->GetNext(pos);
}while(1);
if(m_history.GetCount() > 0)
m_history.SetCaretIndex(m_history.GetCount()-1,0);
}
}
示例11: CalculateKadUsersNew
uint32_t CKademlia::CalculateKadUsersNew(){
// the idea of calculating the user count with this method is simple:
// whenever we do search for any NodeID (except in certain cases were the result is not usable),
// we remember the distance of the closest node we found. Because we assume all NodeIDs are distributed
// equally, we can calcualte based on this distance how "filled" the possible NodesID room is and by this
// calculate how many users there are. Of course this only works if we have enough samples, because
// each single sample will be wrong, but the average of them should produce a usable number. To avoid
// drifts caused by a a single (or more) really close or really far away hits, we do use median-average instead through
// doesnt works well if we have no files to index and nothing to download and the numbers seems to be a bit too low
// compared to out other method. So lets stay with the old one for now, but keeps this here as alternative
if (m_liStatsEstUsersProbes.GetCount() < 10)
return 0;
uint32_t nMedian = 0;
CList<uint32_t, uint32_t> liMedian;
for (POSITION pos1 = m_liStatsEstUsersProbes.GetHeadPosition(); pos1 != NULL; )
{
uint32_t nProbe = m_liStatsEstUsersProbes.GetNext(pos1);
bool bInserted = false;
for (POSITION pos2 = liMedian.GetHeadPosition(); pos2 != NULL; liMedian.GetNext(pos2)){
if (liMedian.GetAt(pos2) > nProbe){
liMedian.InsertBefore(pos2, nProbe);
bInserted = true;
break;
}
}
if (!bInserted)
liMedian.AddTail(nProbe);
}
// cut away 1/3 of the values - 1/6 of the top and 1/6 of the bottom to avoid spikes having too much influence, build the average of the rest
int32_t nCut = liMedian.GetCount() / 6;
for (int i = 0; i != nCut; i++){
liMedian.RemoveHead();
liMedian.RemoveTail();
}
uint64_t nAverage = 0;
for (POSITION pos1 = liMedian.GetHeadPosition(); pos1 != NULL; )
nAverage += liMedian.GetNext(pos1);
nMedian = (uint32_t)(nAverage / liMedian.GetCount());
// LowIDModififier
// Modify count by assuming 20% of the users are firewalled and can't be a contact for < 0.49b nodes
// Modify count by actual statistics of Firewalled ratio for >= 0.49b if we are not firewalled ourself
// Modify count by 40% for >= 0.49b if we are firewalled outself (the actual Firewalled count at this date on kad is 35-55%)
const float fFirewalledModifyOld = 1.20F;
float fFirewalledModifyNew = 0;
if (CUDPFirewallTester::IsFirewalledUDP(true))
fFirewalledModifyNew = 1.40F; // we are firewalled and get get the real statistic, assume 40% firewalled >=0.49b nodes
else if (GetPrefs()->StatsGetFirewalledRatio(true) > 0) {
fFirewalledModifyNew = 1.0F + (CKademlia::GetPrefs()->StatsGetFirewalledRatio(true)); // apply the firewalled ratio to the modify
ASSERT( fFirewalledModifyNew > 1.0F && fFirewalledModifyNew < 1.90F );
}
float fNewRatio = CKademlia::GetPrefs()->StatsGetKadV8Ratio();
float fFirewalledModifyTotal = 0;
if (fNewRatio > 0 && fFirewalledModifyNew > 0) // weigth the old and the new modifier based on how many new contacts we have
fFirewalledModifyTotal = (fNewRatio * fFirewalledModifyNew) + ((1 - fNewRatio) * fFirewalledModifyOld);
else
fFirewalledModifyTotal = fFirewalledModifyOld;
ASSERT( fFirewalledModifyTotal > 1.0F && fFirewalledModifyTotal < 1.90F );
return (uint32_t)((float)nMedian*fFirewalledModifyTotal);
}
示例12: AssignRankAndCrowdingDistance
void CPopulation::AssignRankAndCrowdingDistance()
{
ASSERT(individuals != NULL);
ASSERT(pProblem != NULL);
int front_size = 0;
int rank = 1;
int orig_index, cur_index;
POSITION pos1, pos2, tmp_pos;
CList<int, int> orig;
CList<int, int> cur;
for (int i=0; i<pProblem->popsize; i++)
orig.AddTail(i);
while (!orig.IsEmpty())
{
pos1 = orig.GetHeadPosition();
orig_index = orig.GetNext(pos1);
if (pos1 == NULL)
{
individuals[orig_index].rank = rank;
individuals[orig_index].crowd_dist = INF;
break;
}
cur.AddHead(orig_index);
front_size = 1;
orig.RemoveHead();
pos1 = orig.GetHeadPosition();
while (pos1 != NULL)
{
int flag = -1;
orig_index = orig.GetAt(pos1);
pos2 = cur.GetHeadPosition();
while (pos2 != NULL)
{
cur_index = cur.GetAt(pos2);
flag = individuals[orig_index].CheckDominance(individuals[cur_index]);
if (flag == 1)
{
orig.AddHead(cur_index);
front_size--;
tmp_pos = pos2;
cur.GetNext(pos2);
cur.RemoveAt(tmp_pos);
}
else if (flag == 0)
{
cur.GetNext(pos2);
}
else if (flag == -1)
{
break;
}
}
if (flag != -1)
{
cur.AddHead(orig_index);
front_size++;
tmp_pos = pos1;
orig.GetNext(pos1);
orig.RemoveAt(tmp_pos);
}
else
{
orig.GetNext(pos1);
}
}
pos2 = cur.GetHeadPosition();
while (pos2 != NULL)
{
cur_index = cur.GetNext(pos2);
individuals[cur_index].rank = rank;
}
AssignCrowdingDistanceList((void*) &cur, front_size);
cur.RemoveAll();
rank++;
}
}
示例13: FilterDuplicateList
int CFileSizeFilter::FilterDuplicateList( CList<CFileInfo*,CFileInfo*> & FileList)
{
int Count = 0;
bool FilterIt = false;
int Iteration = 0;
POSITION xPos;
// update status and log
g_DupeFileFind.m_DuffStatus.Lock();
g_DupeFileFind.m_DuffStatus.CurrentTaskInfo = m_sName;
g_DupeFileFind.m_DuffStatus.SubProgress2.Min = 0;
g_DupeFileFind.m_DuffStatus.SubProgress2.Max = FileList.GetCount();
g_DupeFileFind.m_DuffStatus.Unlock();
//
//for (i = 0; i < FileList.GetSize(); i++)
xPos = FileList.GetHeadPosition();
while (xPos)
{
switch(m_FilterType)
{
case FT_NOT_EQUAL: // not equal
FilterIt = ( FileList.GetAt(xPos)->Size == m_Value1 );
break;
case FT_EQUAL: // equal
FilterIt = ( FileList.GetAt(xPos)->Size != m_Value1 );
break;
case FT_GREATER_THAN: // greater
FilterIt = ( FileList.GetAt(xPos)->Size <= m_Value1 );
break;
case FT_LESS_THAN: // less
FilterIt = ( FileList.GetAt(xPos)->Size >= m_Value1 );
break;
case FT_BETWEEN: // between
FilterIt = ( FileList.GetAt(xPos)->Size < m_Value1 || FileList.GetAt(xPos)->Size > m_Value2 );
break;
case FT_NOT_BETWEEN: // not between
FilterIt = ( FileList.GetAt(xPos)->Size >= m_Value1 && FileList.GetAt(xPos)->Size <= m_Value2 );
break;
default:
return 0;
}
if (FilterIt)
{
//FileList.ElementAt(i)->Unaccessible = true;
POSITION Pos2 = xPos;
FileList.GetNext(Pos2);
delete FileList.GetAt(xPos);
FileList.RemoveAt(xPos);
//i--;
xPos = Pos2;
Count++;
}
else
{
FileList.GetNext(xPos);
}
Iteration ++;
// update status and log
if ( g_DupeFileFind.m_DuffStatus.LockIfUnlocked() )
{
g_DupeFileFind.m_DuffStatus.SubProgress2.Pos = Iteration;
g_DupeFileFind.m_DuffStatus.Unlock();
}
//
}
return Count;
}
示例14: ProcessFiles
void CFileMoveProcess::ProcessFiles ( CList<CFileInfo *, CFileInfo *> & FileList)
{
CString Msg;
SHFILEOPSTRUCT fos;
TCHAR pDirBuffer[MAX_PATH];
TCHAR pFilenameBuffer[MAX_PATH];
CFileInfo * pFileInfo;
POSITION ListPos;
// setup to directory buffer
// pDirBuffer = new TCHAR[m_Dir.GetLength()+2];
strcpy( pDirBuffer, (LPCSTR) m_Dir);
pDirBuffer[m_Dir.GetLength()] = '\0';
pDirBuffer[m_Dir.GetLength()+1] = '\0';
//
// setup struct
fos.hwnd = AfxGetMainWnd()->m_hWnd;
fos.wFunc= FO_MOVE;
fos.pTo = pDirBuffer;
fos.fFlags = FOF_ALLOWUNDO | FOF_NOERRORUI;
fos.lpszProgressTitle = "NULL";
//
// set confirmation flag
if ( m_YesToAll ) fos.fFlags |= FOF_NOCONFIRMATION;
//
/* for ( int i = 0; i < FileList.GetSize(); i++)
{
//if ( ((CDuffDlg*)GetParent()->GetParent())->m_DuplicatePage.m_DupeList.GetCheck(i) == BST_CHECKED )
//{
Temp = FileList.ElementAt(i).m_Filename;
//TotalLength += Temp.GetLength() +1;
FilesToDelete.Add(Temp);
//}
}
*/
// update progress information
pDuffStatus->Lock();
pDuffStatus->CurrentTaskStr = "Moving selected duplicate files...";
pDuffStatus->CurrentTaskInfo = "";
pDuffStatus->SubProgress1.Min = 0;
pDuffStatus->SubProgress1.Pos = 0;
pDuffStatus->SubProgress1.Max = FileList.GetCount();
pDuffStatus->Unlock();
//
ListPos = FileList.GetHeadPosition();
while (ListPos)
{
pFileInfo = FileList.GetAt(ListPos);
// process only the selected files
if ( pFileInfo->Selected)
{
if ( ! (pFileInfo->Attributes & FILE_ATTRIBUTE_READONLY) || m_MoveReadOnly )
{
/* // remove read-only attribute
if ( FileList.ElementAt(i)->ReadOnly )
{
DWORD FileAttributes;
FileAttributes = GetFileAttributes( FileList.ElementAt(i)->Filename )
FileAttributes ^= FILE_ATTRIBUTE_READONLY;
SetFileAttributes(FileList.ElementAt(i)->Filename,FileAttributes );
}*/
_tcscpy(pFilenameBuffer, pFileInfo->GetFullName() );
UINT Length = _tcslen( pFilenameBuffer );
// for (int x = 0; x < FileList.ElementAt(i)->Filename.GetLength(); x++)
// {
// pFilenameBuffer[x] = FileList.ElementAt(i)->Filename.GetAt(x);
// }
pFilenameBuffer[Length] = 0;
pFilenameBuffer[Length+1] = 0;
fos.pFrom = pFilenameBuffer;
// g_DupeFileFind.GetDuffDlg()->m_CurrentTaskInfoText.SetWindowText(FileList.ElementAt(i)->GetFullName());
// g_DupeFileFind.GetDuffDlg()->m_CurrentTaskInfoText.RedrawWindow();
// update progress information
pDuffStatus->Lock();
pDuffStatus->CurrentTaskInfo = pFileInfo->GetFullName();
pDuffStatus->SubProgress1.Pos++;
pDuffStatus->Unlock();
//
/*
//.........这里部分代码省略.........
示例15: crossoveroperator
//current 变化后,以上没有问题了。
void Genetic::crossoveroperator()
{
//非均匀算术线性交叉,浮点数适用,alpha ,beta是(0,1)之间的随机数
//对种群中两两交叉的个体选择也是随机选择的。也可取beta=1-alpha;
//current的变化会有一些改变。
int i,j;
double alpha,beta;
CList <int,int> index;
int point,temp;
double p;
// srand( (unsigned)time( NULL ) );
for (i=0;i<popsize;i++)//生成序号
{
index.InsertAfter (index.FindIndex(i),i);
}
for (i=0;i<popsize;i++)//打乱序号
{
point=rand()%(popsize-1);
temp=index.GetAt(index.FindIndex(i));
index.SetAt(index.FindIndex(i),
index.GetAt(index.FindIndex(point)));
index.SetAt(index.FindIndex(point),temp);
}
for (i=0;i<popsize-1;i+=2)
{
//按顺序序号,按序号选择两个母体进行交叉操作。
p=double(rand()%10000)/10000.0;
if (p<crossoverrate)
{
alpha=double(rand()%10000)/10000.0;
beta=double(rand()%10000)/10000.0;
current=population.GetAt(population.FindIndex(index.GetAt(index.FindIndex(i))));
current1=population.GetAt(population.FindIndex(index.GetAt(index.FindIndex(i+1))));//临时使用
current1代替
for(j=0;j<variablenum;j++)
{
//交叉
double sign;
sign=rand()%2;
if(sign)
{
current.chromosome[j]=(1-alpha)*current.chromosome[j]+
beta*current1.chromosome[j];
}
else
{
current.chromosome[j]=(1-alpha)*current.chromosome[j]-
beta*current1.chromosome[j];
}
if (current.chromosome[j]>variabletop[j]) //判断是否超界.
{
current.chromosome[j]=double(rand()%10000)/10000*(variabletop[j]-variablebottom[j])+
variablebottom[j];
}
if (current.chromosome[j]<variablebottom [j])
{
current.chromosome[j]=double(rand()%10000)/10000*(variabletop[j]-variablebottom[j])+
variablebottom[j];
}
if(sign)
{
current1.chromosome[j]=alpha*current.chromosome[j]+
(1- beta)*current1.chromosome[j];
}
else
{
current1.chromosome[j]=alpha*current.chromosome[j]-
(1- beta)*current1.chromosome[j];
}
if (current1.chromosome[j]>variabletop[j])
{
current1.chromosome[j]=double(rand()%10000)/10000*(variabletop[j]-variablebottom[j])+
variablebottom[j];
}
if (current1.chromosome[j]<variablebottom [j])
{
current1.chromosome[j]=double(rand()%10000)/10000*(variabletop[j]-variablebottom[j])+
variablebottom[j];
}
}
//回代
}
newpopulation.InsertAfter (newpopulation.FindIndex(i),current);
newpopulation.InsertAfter (newpopulation.FindIndex(i),current1);
}