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


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

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


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

示例1: OnPropDownitem

void CPropertiesWnd::OnPropDownitem()
{
	if (!IsComboType())
	{
		return;
	}

	CMFCPropertyGridProperty *pProp = m_wndPropList.GetCurSel();
	if (pProp && pProp->IsGroup())
	{
		CString strName(pProp->GetName());
		if (strName.CompareNoCase(_T("ITEM")) == 0)
		{
			CMFCPropertyGridProperty *pParentProp = pProp->GetParent();
			if (pProp == pParentProp->GetSubItem(pParentProp->GetSubItemsCount() - 1))
			{
				return;
			}

			int nEnd = 0;
			CList<CMFCPropertyGridProperty*, CMFCPropertyGridProperty*> lstSubItems;
			for (int i = pParentProp->GetSubItemsCount() - 1; i >= nEnd; i--)
			{
				CMFCPropertyGridProperty *pChildProp = pParentProp->GetSubItem(i);
				if (pChildProp)
				{
					if (pChildProp == pProp)
					{
						nEnd = i;
						lstSubItems.InsertAfter(lstSubItems.GetHeadPosition(), pChildProp);
					}
					else
					{
						lstSubItems.AddHead(pChildProp);
					}
					pParentProp->RemoveSubItem(pChildProp, FALSE);
				}
			}

			for (POSITION pos = lstSubItems.GetHeadPosition(); pos != NULL;)
			{
				CMFCPropertyGridProperty* pProp = lstSubItems.GetNext(pos);
				ASSERT_VALID(pProp);

				pParentProp->AddSubItem(pProp);
			}
			m_wndPropList.AdjustLayout();
		}
	}
}
开发者ID:20400992,项目名称:CoolFormat,代码行数:50,代码来源:PropertiesWnd.cpp

示例2: GetNextSelectedFolder

CLibraryFolder* CLibraryFolderCtrl::GetNextSelectedFolder(POSITION& pos) const
{
	CLibraryFolder* pFolder = NULL;

	do
	{
		if ( pos == NULL ) return NULL;

		HTREEITEM hItem = (HTREEITEM)pos;
		pos = (POSITION)GetNextSelectedItem( hItem );

		if ( hItem == m_hRoot ) continue;

		CList< HTREEITEM > pTree;

		while ( hItem != m_hRoot )
		{
			pTree.AddHead( hItem );
			hItem = GetParentItem( hItem );
		}

		CLibraryFolder* pLastFolder = NULL;

		for ( POSITION posTree = pTree.GetHeadPosition() ; posTree ; pLastFolder = pFolder )
		{
			hItem = pTree.GetNext( posTree );
			pFolder = (CLibraryFolder*)GetItemData( hItem );

			if ( pLastFolder )
			{
				if ( pLastFolder->CheckFolder( pFolder ) ) continue;
			}
			else
			{
				if ( LibraryFolders.CheckFolder( pFolder ) ) continue;
			}

			pFolder = NULL;
			break;
		}
	}
	while ( pFolder == NULL );

	return pFolder;
}
开发者ID:ivan386,项目名称:Shareaza,代码行数:45,代码来源:CtrlSharedFolder.cpp

示例3: OnLvnKeyDown

void CPlayerPlaylistBar::OnLvnKeyDown(NMHDR* pNMHDR, LRESULT* pResult)
{
    LPNMLVKEYDOWN pLVKeyDown = reinterpret_cast<LPNMLVKEYDOWN>(pNMHDR);

    *pResult = FALSE;

    CList<int> items;
    POSITION pos = m_list.GetFirstSelectedItemPosition();
    while (pos) {
        items.AddHead(m_list.GetNextSelectedItem(pos));
    }

    if (pLVKeyDown->wVKey == VK_DELETE && items.GetCount() > 0) {
        pos = items.GetHeadPosition();
        while (pos) {
            int i = items.GetNext(pos);
            if (m_pl.RemoveAt(FindPos(i))) {
                ((CMainFrame*)AfxGetMainWnd())->CloseMedia();
            }
            m_list.DeleteItem(i);
        }

        m_list.SetItemState(-1, 0, LVIS_SELECTED);
        m_list.SetItemState(
            max(min(items.GetTail(), m_list.GetItemCount() - 1), 0),
            LVIS_SELECTED, LVIS_SELECTED);

        ResizeListColumn();

        *pResult = TRUE;
    } else if (pLVKeyDown->wVKey == VK_SPACE && items.GetCount() == 1) {
        m_pl.SetPos(FindPos(items.GetHead()));

        ((CMainFrame*)AfxGetMainWnd())->OpenCurPlaylistItem();

        AfxGetMainWnd()->SetFocus();

        *pResult = TRUE;
    }
}
开发者ID:Azpidatziak,项目名称:mpc-hc,代码行数:40,代码来源:PlayerPlaylistBar.cpp

示例4: OnBnClickedButtonReverseA

/**
* 响应鼠标单击按钮;Reverse
* @param CBCGPGridCtrl* pGridCtrlEdit 输入行
* @param CBCGPGridCtrl* pGridCtrlList 列表
* @param CList<int, int>* plsNb Nb号队列指针
* @return void
*/
void CGridCtrlOperation::OnBnClickedButtonReverseA(CBCGPGridCtrl* pGridCtrlEdit, CBCGPGridCtrl* pGridCtrlList)
{
	CList<int, int> ListNb;
	CList<int, int>* plsNb = &ListNb;
	// 得到索引队列,修改操作、删除操作、颠倒操作
	if(false == GetIndexListForChangeOrDeleteOrReverse(pGridCtrlEdit, pGridCtrlList, plsNb))
	{
		return;
	}

	CBCGPGridRow* pRow = NULL;	// 行
	CBCGPGridRow* pRowMax = NULL;	// 排序行	
	CBCGPGridRow* pRowNew = NULL;	// 新行

	CList<int, int> olsNb;
	int iNbStart = -1;
	int iNbEnd = -1;
	int iRowIndex = -1;
	int i, j;

	POSITION posMax;
	POSITION pos;
	int iNbMax;
	int iNb;

	// 得到Nb队列
	for(i = 0; i < plsNb->GetCount(); i++)
	{
		pos = plsNb->FindIndex(i);
		iRowIndex = plsNb->GetAt(pos);
		iNb = pGridCtrlList->GetRow(iRowIndex)->GetData();
		olsNb.AddTail(iNb);
		if(0 == i)
		{
			iNbStart = iNb;
		}
		if((plsNb->GetCount() - 1) == i)
		{
			iNbEnd = iNb;
		}
	}

	// 对Nb排序,由小到大
	for(i = 0; i < olsNb.GetCount(); i++)
	{
		posMax = olsNb.FindIndex(i);
		iNbMax = olsNb.GetAt(posMax);
		for(j = i + 1; j < olsNb.GetCount(); j++)
		{
			pos = olsNb.FindIndex(j);
			iNb = olsNb.GetAt(pos);

			if(iNbStart < iNbEnd)
			{
				if(iNbMax > iNb)
				{
					iNbMax = iNb;
					posMax = pos;
				}
			}
			else
			{
				if(iNbMax < iNb)
				{
					iNbMax = iNb;
					posMax = pos;
				}
			}

		}
		olsNb.RemoveAt(posMax);
		olsNb.AddHead(iNbMax);
	}

	for(i = 0; i < plsNb->GetCount(); i++)
	{
		pos = plsNb->FindIndex(i);
		iRowIndex = plsNb->GetAt(pos);
		pRow = pGridCtrlList->GetRow(iRowIndex);

		posMax = olsNb.FindIndex(i);
		iNbMax = olsNb.GetAt(posMax);
		pRowMax = pGridCtrlList->FindRowByData(iNbMax);

		pRowNew = pGridCtrlList->CreateRow(pGridCtrlList->GetColumnCount());
		pGridCtrlList->AddRow(pRowNew, FALSE);

		pRowNew->SetData(pRow->GetData());
		pRowNew->GetItem(0)->SetValue(pRow->GetItem(0)->GetValue());
		for(int j = 1; j < pGridCtrlList->GetColumnCount(); j++)
		{
			COleVariant oVariant = pRow->GetItem(j)->GetValue();
			pRowNew->GetItem(j)->SetValue(oVariant);
//.........这里部分代码省略.........
开发者ID:liquanhai,项目名称:cxm-hitech-matrix428,代码行数:101,代码来源:SetupGridCtrl.cpp

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

示例6: DetectEvents


//.........这里部分代码省略.........
	String ^msg = gcnew String("");
	do {
			double min_val, max_val;
			CvPoint min_loc, max_loc;
			cl_copy.Copy(cl);
			cvMinMaxLoc(D, &min_val, &max_val, &min_loc, &max_loc);
			if (min_val == FLT_MAX)
				break;
			BodyCluster *b1 = cl[min_loc.x], *b2= cl[min_loc.y];
			// break if no more close bodies
			if (d(b1->bot, b2->bot) > m_maxGroupDiameter )
				break;
			
			// merge
			//doc->Message(String::Concat("Add ", b2->id, " at [", b2->bot.x, ", ", b2->bot.y, "] to ", b1->id, " at [", b1->bot.x, ", ", b1->bot.y, "]"));
			b1->Add(b2);
			//doc->Message(String::Concat("Result at [", b1->bot.x, ", ", b1->bot.y, "] "));
			b2->sub.RemoveAllPointers();

			// change row and col 'min_loc.x'
			for (int i=0;i<N;i++) {
				if (i == min_loc.x)
					continue;
				double dist = ComputeDistance(cl[i], b1);
				cvSetReal2D(D, i, min_loc.x, dist);
				cvSetReal2D(D, min_loc.x, i, dist);
			}

			// erase row and col 'min_loc.y'
			for (int i=0;i<N;i++) {
				cvSetReal2D(D, i, min_loc.y, FLT_MAX);
				cvSetReal2D(D, min_loc.y, i, FLT_MAX);
			}
			msg += String::Format("{0:f2}:{1:f2}  ", isolation, compactness);

			kValidityBefore = kValidityNow;
			kValidityNow = ComputeGroupClusteringValidity(doc, cl, &all, D_elements);
			
			step++;
		} while (kValidityNow > kValidityBefore);
		msg += String::Format("{0:f2}:{1:f2}  ", isolation, compactness);
		//doc->Message(msg);
		
		//doc->Message(String::Format("step={3:d1} {0:f2}+{1:f2}={2:f2}  ", isolation, compactness, kValidityNow, step));




	// (3.0) populate group events array
	int EVENT_FRAME_CONFIDENCE = 100;
	double MAX_EVENT_DISTANCE_TO_MERGE = 0.01; // if some actors are different the distance will usually be > 0.02
	int count = cl_copy.GetCount();
	for (int i=0;i<count;i++) {
		if (cl_copy[i]->sub.GetCount() < 2)
			continue;
		SwarmEvent* ev1 = new SwarmEvent(nFrame, name);
		for (int k=0;k<cl_copy[i]->sub.GetCount();k++)
			ev1->AddActor(cl_copy[i]->sub[k]->id, kValidityNow);

		//// Update a temporary queue of recent events: find the closest existing event with all actors matching, then merge
		//double maxDistance = FLT_MAX; int eid = -1;
		//SwarmEvent* ev2 = NULL, *evMatch = NULL;
		//for (POSITION posE = recentEvents.GetHeadPosition();posE;)
		//{
		//	 ev2 = recentEvents.GetNext(posE);
		//	 // do not merge if too far apart in time (treat as separate events)
		//	 if (ev1->GetAverageFrameDistance(ev2) > EVENT_FRAME_CONFIDENCE)
		//		 break;
		//	double d = ev1->DistanceSQR(ev2);
		//	if (d < maxDistance ) {  // ev2 is the closest to ev1 
		//		maxDistance = d;
		//		evMatch = ev2;
		//	}
		//	//echo(String::Format("dist {0}",ev1->GetAverageFrameDistance(ev2)));
		//}

		//// if found an almost identical event match - merge
		//if (evMatch && maxDistance < MAX_EVENT_DISTANCE_TO_MERGE) {
		//	ev2->Add(ev1);
		//	SwarmEvent::last_id--;
		//}
		//// otherwise, create a new event map entry
		//else
			recentEvents.AddHead(ev1);
	}

	// (4.0) Move events from temporary queue to the events map
	for (POSITION posE = recentEvents.GetHeadPosition();posE;)
	{
		SwarmEvent *ev = recentEvents.GetNext(posE);
		doc->m_ActivityData.sEvent.SetAt(ev->id, ev);
	}
	// (5.0) Cleanup
	cvReleaseMat(&D);
	cvReleaseMat(&D_elements);
	recentEvents.RemoveAll();
	cl.RemoveAll();
	cl_copy.RemoveAll();
	return count;
}
开发者ID:githubbar,项目名称:NewVision,代码行数:101,代码来源:SwarmActivityDetectors.cpp

示例7: CRect

//*********************************************************************************
int CBCGPVisualManagerVS2005::CreateAutoHideButtonRegion (CRect rect, 
								DWORD dwAlignment, LPPOINT& points)
{
	switch (dwAlignment & CBRS_ALIGN_ANY)
	{
	case CBRS_ALIGN_LEFT:
		rect.right--;
		break;

	case CBRS_ALIGN_TOP:
		rect.bottom--;
		break;
	}

	CRect rectOrign = rect;
	DWORD dwAlignmentOrign = dwAlignment;

	if ((dwAlignment & CBRS_ALIGN_ANY) == CBRS_ALIGN_LEFT || 
		(dwAlignment & CBRS_ALIGN_ANY) == CBRS_ALIGN_RIGHT)
	{
		rect = CRect (0, 0, rectOrign.Height (), rectOrign.Width ());
		dwAlignment = (dwAlignment == CBRS_ALIGN_LEFT) ? CBRS_ALIGN_TOP : CBRS_ALIGN_BOTTOM;
	}

	CList<POINT, POINT> pts;

	if (!m_bRoundedAutohideButtons)
	{
		rect.right--;

		pts.AddHead (CPoint (rect.left, rect.top));
		pts.AddHead (CPoint (rect.left, rect.bottom - 2));
		pts.AddHead (CPoint (rect.left + 2, rect.bottom));
		pts.AddHead (CPoint (rect.right - 2, rect.bottom));
		pts.AddHead (CPoint (rect.right, rect.bottom - 2));
		pts.AddHead (CPoint (rect.right, rect.top));
	}
	else
	{
		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));
//.........这里部分代码省略.........
开发者ID:cugxiangzhenwei,项目名称:WorkPlatForm,代码行数:101,代码来源:BCGPVisualManagerVS2005.cpp


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