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


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

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


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

示例1: CalculateKadUsersNew

uint32 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 nMedian = 0;

	CList<uint32, uint32> liMedian;
	for (POSITION pos1 = m_liStatsEstUsersProbes.GetHeadPosition(); pos1 != NULL; )
	{
		uint32 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 
	sint32 nCut = liMedian.GetCount() / 6;
	for (int i = 0; i != nCut; i++){
		liMedian.RemoveHead();
		liMedian.RemoveTail();
	}
	uint64 nAverage = 0;
	for (POSITION pos1 = liMedian.GetHeadPosition(); pos1 != NULL; )
		nAverage += liMedian.GetNext(pos1);
	nMedian = (uint32)(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)((float)nMedian*fFirewalledModifyTotal);
}
开发者ID:brolee,项目名称:EMule-GIFC,代码行数:64,代码来源:Kademlia.cpp

示例2: CRect


//.........这里部分代码省略.........
	{
		POSITION posLeft = pts.AddHead (CPoint (rect.left, rect.top));
		posLeft = pts.InsertAfter (posLeft, CPoint (rect.left, rect.top + 2));

		POSITION posRight = pts.AddTail (CPoint (rect.right, rect.top));
		posRight = pts.InsertBefore (posRight, CPoint (rect.right, rect.top + 2));

		int xLeft = rect.left + 1;
		int xRight = rect.right - 1;

		int y = 0;

		BOOL bIsHorz =
			(dwAlignmentOrign & CBRS_ALIGN_ANY) == CBRS_ALIGN_LEFT || 
			(dwAlignmentOrign & CBRS_ALIGN_ANY) == CBRS_ALIGN_RIGHT;

		for (y = rect.top + 2; y < rect.bottom - 4; y += 2)
		{
			posLeft = pts.InsertAfter (posLeft, CPoint (xLeft, y));
			posLeft = pts.InsertAfter (posLeft, CPoint (xLeft, y + 2));

			posRight = pts.InsertBefore (posRight, CPoint (xRight, y));
			posRight = pts.InsertBefore (posRight, CPoint (xRight, y + 2));

			xLeft++;
			xRight--;
		}

		if ((dwAlignmentOrign & CBRS_ALIGN_ANY) == CBRS_ALIGN_BOTTOM && !bIsHorz)
		{
			xLeft--;
			xRight++;
		}

		if (bIsHorz)
		{
			xRight++;
		}
	
		for (;y < rect.bottom - 1; y++)
		{
			posLeft = pts.InsertAfter (posLeft, CPoint (xLeft, y));
			posLeft = pts.InsertAfter (posLeft, CPoint (xLeft + 1, y + 1));

			posRight = pts.InsertBefore (posRight, CPoint (xRight, y));
			posRight = pts.InsertBefore (posRight, CPoint (xRight - 1, y + 1));

			if (y == rect.bottom - 2)
			{
				posLeft = pts.InsertAfter (posLeft, CPoint (xLeft + 1, y + 1));
				posLeft = pts.InsertAfter (posLeft, CPoint (xLeft + 3, y + 1));

				posRight = pts.InsertBefore (posRight, CPoint (xRight, y + 1));
				posRight = pts.InsertBefore (posRight, CPoint (xRight - 2, y + 1));
			}

			xLeft++;
			xRight--;
		}

		posLeft = pts.InsertAfter (posLeft, CPoint (xLeft + 2, rect.bottom));
		posRight = pts.InsertBefore (posRight, CPoint (xRight - 2, rect.bottom));
	}

	points = new POINT [pts.GetCount ()];

	int i = 0;

	for (POSITION pos = pts.GetHeadPosition (); pos != NULL; i++)
	{
		points [i] = pts.GetNext (pos);

		switch (dwAlignmentOrign & CBRS_ALIGN_ANY)
		{
		case CBRS_ALIGN_BOTTOM:
			points [i].y = rect.bottom - (points [i].y - rect.top);
			break;

		case CBRS_ALIGN_RIGHT:
			{
				int x = rectOrign.right - points [i].y;
				int y = rectOrign.top + points [i].x;

				points [i] = CPoint (x, y);
			}
			break;

		case CBRS_ALIGN_LEFT:
			{
				int x = rectOrign.left + points [i].y;
				int y = rectOrign.top + points [i].x;

				points [i] = CPoint (x, y);
			}
			break;
		}
	}

	return (int) pts.GetCount ();
}
开发者ID:iclosure,项目名称:jframework,代码行数:101,代码来源:BCGPVisualManagerVS2005.cpp

示例3: Run

int CAICHSyncThread::Run()
{
	//MORPH START SLUGFILLER: SafeHash
	CReadWriteLock lock(&theApp.m_threadlock);
	if (!lock.ReadLock(0))
		return 0;
	// MORPH END SLUGFILLER: SafeHash
	if ( !theApp.emuledlg->IsRunning() )
		return 0;
	// we need to keep a lock on this file while the thread is running
	CSingleLock lockKnown2Met(&CAICHRecoveryHashSet::m_mutKnown2File);
	lockKnown2Met.Lock();
	
	CSafeFile file;
	bool bJustCreated = ConvertToKnown2ToKnown264(&file);
	
	// we collect all masterhashs which we find in the known2.met and store them in a list
	CList<CAICHHash> liKnown2Hashs;
	CString fullpath = thePrefs.GetMuleDirectory(EMULE_CONFIGDIR);
	fullpath.Append(KNOWN2_MET_FILENAME);
	
	CFileException fexp;
	uint32 nLastVerifiedPos = 0;

	if (!bJustCreated && !file.Open(fullpath,CFile::modeCreate|CFile::modeReadWrite|CFile::modeNoTruncate|CFile::osSequentialScan|CFile::typeBinary|CFile::shareDenyNone, &fexp)){
		if (fexp.m_cause != CFileException::fileNotFound){
			CString strError(_T("Failed to load ") KNOWN2_MET_FILENAME _T(" file"));
			TCHAR szError[MAX_CFEXP_ERRORMSG];
			if (fexp.GetErrorMessage(szError, ARRSIZE(szError))){
				strError += _T(" - ");
				strError += szError;
			}
			LogError(LOG_STATUSBAR, _T("%s"), strError);
		}
		return false;
	}
	try {
		if (file.GetLength() >= 1){
			uint8 header = file.ReadUInt8();
			if (header != KNOWN2_MET_VERSION){
				AfxThrowFileException(CFileException::endOfFile, 0, file.GetFileName());
			}
			//setvbuf(file.m_pStream, NULL, _IOFBF, 16384);
			uint32 nExistingSize = (UINT)file.GetLength();
			uint32 nHashCount;
			while (file.GetPosition() < nExistingSize){
				liKnown2Hashs.AddTail(CAICHHash(&file));
				nHashCount = file.ReadUInt32();
				if (file.GetPosition() + nHashCount*CAICHHash::GetHashSize() > nExistingSize){
					AfxThrowFileException(CFileException::endOfFile, 0, file.GetFileName());
				}
				// skip the rest of this hashset
				file.Seek(nHashCount*CAICHHash::GetHashSize(), CFile::current);
				nLastVerifiedPos = (UINT)file.GetPosition();
			}
		}
		else
			file.WriteUInt8(KNOWN2_MET_VERSION);
	}
	catch(CFileException* error){
		if (error->m_cause == CFileException::endOfFile){
			LogError(LOG_STATUSBAR,GetResString(IDS_ERR_MET_BAD), KNOWN2_MET_FILENAME);
			// truncate the file to the size to the last verified valid pos
			try{
				file.SetLength(nLastVerifiedPos);
				if (file.GetLength() == 0){
					file.SeekToBegin();
					file.WriteUInt8(KNOWN2_MET_VERSION);
				}
			}
			catch(CFileException* error2){
				error2->Delete();
			}
		}
		else{
			TCHAR buffer[MAX_CFEXP_ERRORMSG];
			error->GetErrorMessage(buffer, ARRSIZE(buffer));
			LogError(LOG_STATUSBAR,GetResString(IDS_ERR_SERVERMET_UNKNOWN),buffer);
		}
		error->Delete();
		return false;
	}
	
	// now we check that all files which are in the sharedfilelist have a corresponding hash in out list
	// those who don'T are added to the hashinglist
	CList<CAICHHash> liUsedHashs;	
	CSingleLock sharelock(&theApp.sharedfiles->m_mutWriteList);
	sharelock.Lock();

	bool bDbgMsgCreatingPartHashs = true;
	for (int i = 0; i < theApp.sharedfiles->GetCount(); i++){
		CKnownFile* pCurFile = theApp.sharedfiles->GetFileByIndex(i);
		if (pCurFile != NULL && !pCurFile->IsPartFile() )
		{
			if (theApp.emuledlg==NULL || !theApp.emuledlg->IsRunning()) // in case of shutdown while still hashing
				return 0;
			if (pCurFile->GetFileIdentifier().HasAICHHash()){
				bool bFound = false;
				for (POSITION pos = liKnown2Hashs.GetHeadPosition();pos != 0;)
				{
//.........这里部分代码省略.........
开发者ID:e1z0,项目名称:sMule,代码行数:101,代码来源:AICHSyncThread.cpp

示例4: 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

示例5: 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;
}
开发者ID:GerHobbelt,项目名称:duff,代码行数:74,代码来源:FilterFileSize.cpp

示例6: 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();
		  //

			
		 	/*	
//.........这里部分代码省略.........
开发者ID:GerHobbelt,项目名称:duff,代码行数:101,代码来源:FileMoveProcess.cpp

示例7: DoExport

void CExport::DoExport(bool previewMode, const CString& pathName, bool bApp, int layoutid)
{
	// Progress dialog is going from 10% to 100% in this function

	// Make the DLL list
	CList<CString, CString&> dllList;

	CPath path;
	path.SetToCurrentDirectory();

	// Allocate some initial space for the binary blocks
	imageBlock.allocate(20000);			// 20kb initial image buffer
	eventBlock.allocate(5000);			// 5kb initial event buffer
	LayoutBlock.allocate(5000);			// 5kb initial frame buffer
	appBlock.allocate(1000);			// 1kb initial app buffer
	hlslBlock.allocate(5000);			// 5kb initial hlsl buffer
	menuBlock.allocate(1000);

	// Generate
	GenerateLayout(dllList);	// also loads DLLs to dllList
	ProgressDlg.SetProgress(15);
	GenerateEvents();
	ProgressDlg.SetProgress(20);
	GenerateApplicationData(layoutid);
	ProgressDlg.SetProgress(25);
	GenerateImages();				// Longest job, use 25-80%
	ProgressDlg.SetProgress(80);

	// Open the file for addition of file data in resource
	m_UpdateHandle = BeginUpdateResource(pathName, FALSE);

	// Do python
	GeneratePython();

	// HLSL
	UpdateResource(m_UpdateHandle, "HLSL", MAKEINTRESOURCE(994), MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL),
					hlslBlock.ptr(), hlslBlock.size());

	ProgressDlg.SetProgress(81);

	// Images
	UpdateResource(m_UpdateHandle, "IMAGEBLOCK", MAKEINTRESOURCE(995), MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL),
					imageBlock.ptr(), imageBlock.size());

	ProgressDlg.SetProgress(82);

	// Application settings
	UpdateResource(m_UpdateHandle, "APPBLOCK", MAKEINTRESOURCE(997), MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL),
					appBlock.ptr(), appBlock.size());

	ProgressDlg.SetProgress(83);

	// Layouts
	UpdateResource(m_UpdateHandle, "LEVELBLOCK", MAKEINTRESOURCE(998), MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL),
					LayoutBlock.ptr(), LayoutBlock.size());

	ProgressDlg.SetProgress(84);

	// Events
	UpdateResource(m_UpdateHandle, "EVENTBLOCK", MAKEINTRESOURCE(999), MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL),
					eventBlock.ptr(), eventBlock.size());

	ProgressDlg.SetProgress(85);

	// Number of DLLs
	long c = dllList.GetCount();
	CString ibuf;
	long te = c;
	te += MvtLookup.size();
	ibuf.Format("%d", te);
	int ilen = 0;

	// Make string of DLL count in to resource string format
	wchar_t* resString = AllocStringResourceFormat(ibuf, 1, &ilen);

	// String of DLL count is a string at resource 1
	UpdateResource(m_UpdateHandle, RT_STRING, MAKEINTRESOURCE(1), MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL),
					resString, ilen);

	// AllocStringResourceFormat makes a new string
	delete [] resString;

	CString dll;
	POSITION pos4 = dllList.GetHeadPosition();

	int d = 0;
		
	for (d = 1000; d < (1000 + c); d++)
	{
		// In preview mode, we only put the string of the plugin name in the resources
		if (previewMode) {
			dll = dllList.GetNext(pos4);

			ilen = 0;

			// Make string of DLL count in to resource string format
			wchar_t* resString = AllocStringResourceFormat(dll, 1, &ilen);

			UpdateResource(m_UpdateHandle, RT_STRING, MAKEINTRESOURCE(d), MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL),
								resString, ilen);
//.........这里部分代码省略.........
开发者ID:segafan,项目名称:Construct-classic,代码行数:101,代码来源:Export.cpp


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