当前位置: 首页>>代码示例>>C++>>正文


C++ CList::RemoveHead方法代码示例

本文整理汇总了C++中CList::RemoveHead方法的典型用法代码示例。如果您正苦于以下问题:C++ CList::RemoveHead方法的具体用法?C++ CList::RemoveHead怎么用?C++ CList::RemoveHead使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CList的用法示例。


在下文中一共展示了CList::RemoveHead方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: IsFinished

bool Algorithm::IsFinished(void)
{
    if (m_finished) return true;
    
    while(!m_WaitForCheckList_Row.IsEmpty())
    {
        int row = m_WaitForCheckList_Row.RemoveHead();
        int column = m_WaitForCheckList_Column.RemoveHead();
        if (!m_NeverCheck[row][column])
        {
            int originalcount = 0;
            for (int i = 0; i < 8; ++i)
            {
                int newrow = row + RowOffset[i];
                int newcolumn = column + ColumnOffset[i];
                if (newrow >= 0 && newrow < m_rows && newcolumn >=0 && newcolumn < m_columns)
                    switch (m_MineMatrix[newrow][newcolumn])
                    {
                    case ORIGINAL:
                        ++originalcount; break;
                    }
            }
            if (originalcount)
            {
                trow.AddTail(row); tcolumn.AddTail(column);
            } else
                m_NeverCheck[row][column] = true;
        }
    }

    while (!trow.IsEmpty())
    {
        int row = trow.RemoveHead();
        int column = tcolumn.RemoveHead();
        if (!m_NeverCheck[row][column]) {
            m_WaitForCheckList_Row.AddTail(row);
            m_WaitForCheckList_Column.AddTail(column);
        }
    }
    
    if (m_started && m_WaitForCheckList_Row.IsEmpty())
    {
        int originalcount2 = 0, minecount2 = 0;
        for (int i = 0; i < m_rows; ++i)
            for (int j = 0; j < m_columns; ++j)
                switch (m_MineMatrix[i][j])
                {
                case ORIGINAL:
                    ++originalcount2; break;
                case MINE:
                    ++minecount2; break;
                }
        return originalcount2 == 0 && minecount2 == m_RemainderMines;
    } else return false;
}
开发者ID:kfstorm,项目名称:MinesweeperRobot,代码行数:55,代码来源:Algorithm.cpp

示例2: OnUploadsLaunch

void CUploadsWnd::OnUploadsLaunch()
{
    CSingleLock pLock( &Transfers.m_pSection, TRUE );
    CList<CUploadFile*> pList;

    for ( POSITION pos = UploadFiles.GetIterator() ; pos ; )
    {
        CUploadFile* pFile = UploadFiles.GetNext( pos );
        if ( IsSelected( pFile ) ) pList.AddTail( pFile );
    }

    while ( ! pList.IsEmpty() )
    {
        CUploadFile* pFile = pList.RemoveHead();

        if ( UploadFiles.Check( pFile ) )
        {
            CString strPath = pFile->m_sPath;

            pLock.Unlock();
            if ( ! CFileExecutor::Execute( strPath ) ) break;
            pLock.Lock();
        }
    }
}
开发者ID:ericfillipe1,项目名称:shareaza-code,代码行数:25,代码来源:WndUploads.cpp

示例3: OnSecurityBan

void CUploadsWnd::OnSecurityBan()
{
    CSingleLock pLock( &Transfers.m_pSection, TRUE );
    CList<CUploadFile*> pList;

    for ( POSITION pos = UploadFiles.GetIterator() ; pos ; )
    {
        CUploadFile* pFile = UploadFiles.GetNext( pos );
        if ( IsSelected( pFile ) ) pList.AddTail( pFile );
    }

    while ( ! pList.IsEmpty() )
    {
        CUploadFile* pFile = pList.RemoveHead();

        if ( UploadFiles.Check( pFile ) && pFile->GetActive() != NULL )
        {
            CUploadTransfer* pUpload = pFile->GetActive();

            IN_ADDR pAddress = pUpload->m_pHost.sin_addr;
            pUpload->Remove( FALSE );
            pLock.Unlock();
            Security.Ban( &pAddress, banSession );
            pLock.Lock();
        }
    }
}
开发者ID:ericfillipe1,项目名称:shareaza-code,代码行数:27,代码来源:WndUploads.cpp

示例4: OnUploadsClear

void CUploadsWnd::OnUploadsClear()
{
    CSingleLock pLock( &Transfers.m_pSection, TRUE );
    CList<CUploadFile*> pList;

    for ( POSITION pos = UploadFiles.GetIterator() ; pos ; )
    {
        CUploadFile* pFile = UploadFiles.GetNext( pos );
        if ( IsSelected( pFile ) ) pList.AddTail( pFile );
    }

    while ( ! pList.IsEmpty() )
    {
        CUploadFile* pFile = pList.RemoveHead();

        if ( UploadFiles.Check( pFile ) )
        {
            CUploadTransfer* pUpload = pFile->GetActive();

            if ( pUpload != NULL && pUpload->m_nProtocol == PROTOCOL_ED2K && pUpload->m_nState != upsNull )
            {
                CString strFormat, strMessage;
                LoadString( strFormat, IDS_UPLOAD_CANCEL_ED2K );
                strMessage.Format( strFormat, (LPCTSTR)pUpload->m_sFileName );
                pLock.Unlock();
                UINT nResp = AfxMessageBox( strMessage, MB_ICONQUESTION|MB_YESNOCANCEL|MB_DEFBUTTON2 );
                pLock.Lock();
                if ( nResp == IDCANCEL ) break;
                if ( nResp != IDYES || ! UploadFiles.Check( pFile ) ) continue;
            }

            pFile->Remove();
        }
    }
}
开发者ID:ericfillipe1,项目名称:shareaza-code,代码行数:35,代码来源:WndUploads.cpp

示例5: OnBrowseLaunch

void CUploadsWnd::OnBrowseLaunch()
{
    CSingleLock pLock( &Transfers.m_pSection, TRUE );
    CList<CUploadFile*> pList;

    for ( POSITION pos = UploadFiles.GetIterator() ; pos ; )
    {
        CUploadFile* pFile = UploadFiles.GetNext( pos );
        if ( IsSelected( pFile ) ) pList.AddTail( pFile );
    }

    while ( ! pList.IsEmpty() )
    {
        CUploadFile* pFile = pList.RemoveHead();

        if ( UploadFiles.Check( pFile ) && pFile->GetActive() != NULL )
        {
            CUploadTransfer* pTransfer = pFile->GetActive();
            PROTOCOLID nProtocol = pTransfer->m_nProtocol;
            SOCKADDR_IN pAddress = pTransfer->m_pHost;
            pLock.Unlock();
            new CBrowseHostWnd( nProtocol, &pAddress );
            pLock.Lock();
        }
    }
}
开发者ID:lemonxiao0,项目名称:peerproject,代码行数:26,代码来源:WndUploads.cpp

示例6: OnBnClickedButtonAddA

/**
* @brief 响应鼠标单击按钮;Add
* @note  该函数总是向列表框的后面追加记录。
* @param CBCGPGridCtrl* pGridCtrlEdit 输入行
* @param CBCGPGridCtrl* pGridCtrlList 列表
* @param CList<int, int>* ListNb Nb号队列指针
* @return void
*/
void CGridCtrlOperation::OnBnClickedButtonAddA(CBCGPGridCtrl* pGridCtrlEdit, CBCGPGridCtrl* pGridCtrlList)
{	
    int				i;
    int				iNb;
    COleVariant		oEditVariant;
    CBCGPGridRow*	pRowEdit = NULL;	// 输入行
    CBCGPGridRow*	pRowNew = NULL;	// 新行
    int				iRowID = 0;
    CList<int, int>  ListNb;
    // 得到索引队列,增加操作
    if(false == GetIndexListForAdd(pGridCtrlEdit, &ListNb))
    {
        return;
    }

    pRowEdit = pGridCtrlEdit->GetRow(0);
    
    while(FALSE == ListNb.IsEmpty())
    {
        // 得到索引号
        iNb = ListNb.RemoveHead();
        // 索引号在列表中已经存在
        if(NULL != pGridCtrlList->FindRowByData(iNb))
        {
            continue;
        }
        pRowNew = pGridCtrlList->CreateRow(pGridCtrlList->GetColumnCount());
        pRowNew->SetData(iNb);
        oEditVariant.vt = VT_UI4;
        oEditVariant.ulVal = iNb;
        oEditVariant.ChangeType(VT_BSTR);
        pRowNew->GetItem(0)->SetValue(oEditVariant);
        for(i = 1; i < pGridCtrlList->GetColumnCount(); i++)
        {						
            oEditVariant= pRowEdit->GetItem(i)->GetValue();			
            pRowNew->GetItem(i)->SetValue(oEditVariant);
        }
        pGridCtrlList->AddRow(pRowNew, FALSE);

        /*
        if(iSelectRowIndex == -1)	// 无选中行
        {
            pGridCtrlList->AddRow(pRowNew, FALSE);
        }
        else
        {
            pGridCtrlList->InsertRowAfter(iSelectRowIndex + iRowID, pRowNew, FALSE);
            iRowID++;
        }*/
    }
    pGridCtrlList->AdjustLayout();
}
开发者ID:liquanhai,项目名称:cxm-hitech-matrix428,代码行数:60,代码来源:SetupGridCtrl.cpp

示例7: OnUploadsLaunch

void CUploadsWnd::OnUploadsLaunch()
{
    CSingleLock pTransfersLock( &Transfers.m_pSection );
    if ( ! pTransfersLock.Lock( 500 ) ) return;

    const BOOL bShift = ( GetAsyncKeyState( VK_SHIFT ) & 0x8000 );

    CList<CUploadFile*> pList;

    for ( POSITION pos = UploadFiles.GetIterator() ; pos ; )
    {
        CUploadFile* pFile = UploadFiles.GetNext( pos );
        if ( IsSelected( pFile ) )
            pList.AddTail( pFile );
    }

    pTransfersLock.Unlock();

    while ( ! pList.IsEmpty() )
    {
        pTransfersLock.Lock();
        CUploadFile* pFile = pList.RemoveHead();

        if ( pFile->m_sPath.IsEmpty() )		// Multifile torrent always opens folder?  (ToDo: Update this path assumption when fixed elsewhere)
        {
            const CString strPath = Settings.Downloads.TorrentPath + _T("\\") + pFile->m_sName;		// Try default multifile torrent folder  (Need better detection)
            pTransfersLock.Unlock();
            if ( PathIsDirectory( strPath ) )
                ShellExecute( GetSafeHwnd(), _T("open"), strPath, NULL, NULL, SW_SHOWNORMAL );
        }
        else if ( ! bShift )				// Show in Library by default
        {
            CPeerProjectFile oFile = *pFile;
            pTransfersLock.Unlock();

            CSingleLock pLibraryLock( &Library.m_pSection, TRUE );
            if ( CLibraryFile* pLibFile = LibraryMaps.LookupFileByHash( &oFile ) )
            {
                if ( CLibraryWnd* pLibrary = CLibraryWnd::GetLibraryWindow() )		// (CLibraryWnd*)( pMainWnd->m_pWindows.Open( RUNTIME_CLASS(CLibraryWnd) ) ) )
                {
                    pLibrary->Display( pLibFile );
                }
            }
        }
        else if ( UploadFiles.Check( pFile ) )	// Launch directly with Shift key
        {
            pTransfersLock.Unlock();
            CFileExecutor::Execute( pFile->m_sPath );
        }
    }
}
开发者ID:lemonxiao0,项目名称:peerproject,代码行数:51,代码来源:WndUploads.cpp

示例8: OnBnClickedButtonChangeA

/**
* 响应鼠标单击按钮;Change
* @param CBCGPGridCtrl* pGridCtrlEdit 输入行
* @param CBCGPGridCtrl* pGridCtrlList 列表
* @return void
*/
void CGridCtrlOperation::OnBnClickedButtonChangeA(CBCGPGridCtrl* pGridCtrlEdit, CBCGPGridCtrl* pGridCtrlList)
{
    int				i,iRowIndex;
    COleVariant		oEditVariant ;
    //COleVariant		oListVariant ;
    CString			strData;
    CBCGPGridRow* pRowEdit = NULL;	// 输入行
    CBCGPGridRow* pRowChange = NULL;	// 修改行
    CList<int, int> ListNb;
    // 得到索引队列,修改操作、删除操作、颠倒操作
    if(false == GetIndexListForChangeOrDeleteOrReverse(pGridCtrlEdit, pGridCtrlList, &ListNb))
    {
        return;
    }
    // 得到输入行
    pRowEdit = pGridCtrlEdit->GetRow(0);


    while(FALSE == ListNb.IsEmpty())
    {
        // 得到行索引号
        iRowIndex = ListNb.RemoveHead();
        pRowChange = pGridCtrlList->GetRow(iRowIndex);
        for(i = 1; i < pGridCtrlList->GetColumnCount(); i++)
        {
            oEditVariant= pRowEdit->GetItem(i)->GetValue();			
            if(oEditVariant.vt == VT_BSTR)
            {
                strData = oEditVariant;
                if(strData != _T("/"))
                {
                    pRowChange->GetItem(i)->SetValue(oEditVariant);
                }
            }
            else
            {
                pRowChange->GetItem(i)->SetValue(oEditVariant);
            }			
        }
    
    }
    pGridCtrlList->AdjustLayout();
}
开发者ID:liquanhai,项目名称:cxm-hitech-matrix428,代码行数:49,代码来源:SetupGridCtrl.cpp

示例9: OnBnClickedButtonChangeB

/**
* @brief 响应鼠标单击按钮;Change
* @note	与 OnBnClickedButtonChangeA函数不同,该函数对每一列调用GetValueForTextField进行解析。
* 支持V/i的格式输入。
* @param CBCGPGridCtrl* pGridCtrlEdit 输入行
* @param CBCGPGridCtrl* pGridCtrlList 列表
* @return void
*/
void CGridCtrlOperation::OnBnClickedButtonChangeB(CBCGPGridCtrl* pGridCtrlEdit, CBCGPGridCtrl* pGridCtrlList)
{
    int				nIndex;  // 计数器,计算当前更新的行数
    int				i,iRowIndex;
    COleVariant		oEditVariant ;
    COleVariant		oListVariant ;
    CString			strData;
    CBCGPGridRow* pRowEdit = NULL;	// 输入行
    CBCGPGridRow* pRowChange = NULL;	// 修改行
    CList<int, int> ListNb;
    // 得到索引队列,修改操作、删除操作、颠倒操作
    if(false == GetIndexListForChangeOrDeleteOrReverse(pGridCtrlEdit, pGridCtrlList, &ListNb))
    {
        return;
    }
    // 得到输入行
    pRowEdit = pGridCtrlEdit->GetRow(0);

    nIndex = 0;
    while(FALSE == ListNb.IsEmpty())
    {
        // 得到行索引号
        iRowIndex = ListNb.RemoveHead();
        pRowChange = pGridCtrlList->GetRow(iRowIndex);
        for(i = 1; i < pGridCtrlList->GetColumnCount(); i++)
        {
            oEditVariant= pRowEdit->GetItem(i)->GetValue();
            oListVariant= pRowChange->GetItem(i)->GetValue();
            oListVariant = GetValueForTextField(&oEditVariant,&oListVariant,nIndex);
            if (oEditVariant.vt == VT_BSTR)
            {
                oListVariant.ChangeType(VT_BSTR);
            }			
            pRowChange->GetItem(i)->SetValue(oListVariant);			
        }
        nIndex++;
    }
    pGridCtrlList->AdjustLayout();
}
开发者ID:liquanhai,项目名称:cxm-hitech-matrix428,代码行数:47,代码来源:SetupGridCtrl.cpp

示例10: GetNotCertainOperations

void Algorithm::GetNotCertainOperations(void)
{
    if (!m_WaitForCheckList_Row.IsEmpty())
    {
        int SelectRow = -1, SelectColumn = -1;
        double ExplodeProbility = 1;
        while (!m_WaitForCheckList_Row.IsEmpty())
        {
            int row = m_WaitForCheckList_Row.RemoveHead();
            int column = m_WaitForCheckList_Column.RemoveHead();
            trow.AddTail(row), tcolumn.AddTail(column);
            if (!m_NeverCheck[row][column])
            {
                int minecount = 0, originalcount = 0;
                for (int i = 0; i < 8; ++i)
                {
                    int newrow = row + RowOffset[i];
                    int newcolumn = column + ColumnOffset[i];
                    if (newrow >= 0 && newrow < m_rows && newcolumn >=0 && newcolumn < m_columns)
                        switch (m_MineMatrix[newrow][newcolumn])
                        {
                        case MINE:
                            ++minecount; break;
                        case ORIGINAL:
                            ++originalcount; break;
                        }
                }
                if ((double) (m_MineMatrix[row][column] - minecount) / originalcount < ExplodeProbility)
                {
                    SelectRow = row; SelectColumn = column;
                    ExplodeProbility = (double) (m_MineMatrix[row][column] - minecount) / originalcount;
                }
            }
        }

        while (!trow.IsEmpty())
        {
            int row = trow.RemoveHead();
            int column = tcolumn.RemoveHead();
            if (!m_NeverCheck[row][column]) {
                m_WaitForCheckList_Row.AddTail(row);
                m_WaitForCheckList_Column.AddTail(column);
            }
        }

    if (SelectRow != -1)
        for (int i = 0; i < 8; ++i)
        {
            int newrow = SelectRow + RowOffset[i];
            int newcolumn = SelectColumn + ColumnOffset[i];
            if (newrow >= 0 && newrow < m_rows && newcolumn >=0 && newcolumn < m_columns)
                if (m_MineMatrix[newrow][newcolumn] == ORIGINAL)
                {
                    AddOperation(Operation(Operation::OPEN, newrow, newcolumn));
                    NewWaitForIdentify(newrow, newcolumn);
                    break;
                }
        }

    } else {
        bool flag = false;
        for (int i = 0; i < m_rows; ++i)
        {
            for (int j = 0; j < m_columns; ++j)
            {
                switch (m_MineMatrix[i][j])
                {
                case ORIGINAL:
                    AddOperation(Operation(Operation::OPEN, i, j));
                    NewWaitForIdentify(i, j);
                    flag = true;
                    break;
                }
                if (flag) break;
            }
            if (flag) break;
        }
    }

}
开发者ID:kfstorm,项目名称:MinesweeperRobot,代码行数:80,代码来源:Algorithm.cpp

示例11: GetCertainOperations

void Algorithm::GetCertainOperations(void)
{
    while(!m_WaitForCheckList_Row.IsEmpty())
    {
        int row = m_WaitForCheckList_Row.RemoveHead();
        int column = m_WaitForCheckList_Column.RemoveHead();
        if (!m_NeverCheck[row][column])
        {
            int minecount = 0, originalcount = 0;
            for (int i = 0; i < 8; ++i)
            {
                int newrow = row + RowOffset[i];
                int newcolumn = column + ColumnOffset[i];
                if (newrow >= 0 && newrow < m_rows && newcolumn >=0 && newcolumn < m_columns)
                    switch (m_MineMatrix[newrow][newcolumn])
                    {
                    case MINE:
                        ++minecount; break;
                    case ORIGINAL:
                        ++originalcount; break;
                    }
            }
                
            if (minecount == m_MineMatrix[row][column])
            {
                m_NeverCheck[row][column] = true;
                if (originalcount)
                {
                    AddOperation(Operation(Operation::QUICKOPEN, row, column));
                    for (int i = 0; i < 8; ++i)
                    {
                        int newrow = row + RowOffset[i];
                        int newcolumn = column + ColumnOffset[i];
                        if (newrow >= 0 && newrow < m_rows && newcolumn >=0 && newcolumn < m_columns)
                            if (m_MineMatrix[newrow][newcolumn] == ORIGINAL)
                            {
                                m_MineMatrix[newrow][newcolumn] = ALREADYOPEN;
                                NewWaitForIdentify(newrow, newcolumn);
                            }
                    }
                }
            }
            else if (minecount + originalcount == m_MineMatrix[row][column])
            {
                m_NeverCheck[row][column] = true;
                for (int i = 0; i < 8; ++i)
                    {
                        int newrow = row + RowOffset[i];
                        int newcolumn = column + ColumnOffset[i];
                        if (newrow >= 0 && newrow < m_rows && newcolumn >=0 && newcolumn < m_columns)
                            if (m_MineMatrix[newrow][newcolumn] == ORIGINAL) {
                                m_MineMatrix[newrow][newcolumn] = MINE;
                                AddOperation(Operation(Operation::MARKMINE, newrow, newcolumn));
                            }
                    }
            } else {
                trow.AddTail(row); tcolumn.AddTail(column);
            }

        }
    }

    while (!trow.IsEmpty())
    {
        int row = trow.RemoveHead();
        int column = tcolumn.RemoveHead();
        if (!m_NeverCheck[row][column]) {
            m_WaitForCheckList_Row.AddTail(row);
            m_WaitForCheckList_Column.AddTail(column);
        }
    }

    if (m_OperationList.IsEmpty())
    {
        TRACE(_T("Searching...\n"));
        while(!m_WaitForCheckList_Row.IsEmpty())
        {
            int row = m_WaitForCheckList_Row.RemoveHead();
            int column = m_WaitForCheckList_Column.RemoveHead();
            trow.AddTail(row); tcolumn.AddTail(column);
            if (!m_NeverCheck[row][column])
            {
                Search_Clear();
                Search(1, row, column);
                if (Search_Check()) break;
                //Search_Check();
            }
        }

        while (!trow.IsEmpty())
        {
            int row = trow.RemoveHead();
            int column = tcolumn.RemoveHead();
            if (!m_NeverCheck[row][column]) {
                m_WaitForCheckList_Row.AddTail(row);
                m_WaitForCheckList_Column.AddTail(column);
            }
        }
    }

//.........这里部分代码省略.........
开发者ID:kfstorm,项目名称:MinesweeperRobot,代码行数:101,代码来源:Algorithm.cpp

示例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++;
    }
}
开发者ID:Geosyntec,项目名称:SUSTAIN,代码行数:94,代码来源:Population.cpp

示例13: 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);
}
开发者ID:HackLinux,项目名称:eMule-IS-Mod,代码行数:64,代码来源:Kademlia.cpp

示例14: ASSERT

         // Define myList.
         CList<CString,CString&> myList;

         // Add two elements to the list.
         myList.AddHead(CString(_T("ABC")));
         myList.AddHead(CString(_T("123")));

         // Remove the head element and verify the list.
         // NOTE: once the head is removed, the number of
         // elements in the list will be one.
         CString strHead = myList.RemoveHead();
         ASSERT((CString(_T("123")) == strHead) && (myList.GetCount() == 1) && 
            (CString(_T("ABC")) == myList.GetHead()));      
开发者ID:terryjintry,项目名称:OLSource1,代码行数:13,代码来源:clist-class_19.cpp


注:本文中的CList::RemoveHead方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。