本文整理汇总了C++中CList::InsertAfter方法的典型用法代码示例。如果您正苦于以下问题:C++ CList::InsertAfter方法的具体用法?C++ CList::InsertAfter怎么用?C++ CList::InsertAfter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CList
的用法示例。
在下文中一共展示了CList::InsertAfter方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
}
}
示例2: 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);
}
示例3: 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));
//.........这里部分代码省略.........