本文整理汇总了C++中CList::RemoveTail方法的典型用法代码示例。如果您正苦于以下问题:C++ CList::RemoveTail方法的具体用法?C++ CList::RemoveTail怎么用?C++ CList::RemoveTail使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CList
的用法示例。
在下文中一共展示了CList::RemoveTail方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnBnClickedButtonDeleteA
/**
* 响应鼠标单击按钮;Delete
* @param CBCGPGridCtrl* pGridCtrlEdit 输入行
* @param CBCGPGridCtrl* pGridCtrlList 列表
* @return void
*/
void CGridCtrlOperation::OnBnClickedButtonDeleteA(CBCGPGridCtrl* pGridCtrlEdit, CBCGPGridCtrl* pGridCtrlList)
{
CList<int, int> ListNb;
// 得到索引队列,修改操作、删除操作、颠倒操作
if(false == GetIndexListForChangeOrDeleteOrReverse(pGridCtrlEdit, pGridCtrlList, &ListNb))
{
return;
}
while(FALSE == ListNb.IsEmpty())
{
// 得到行索引号
int iRowIndex = ListNb.RemoveTail();
pGridCtrlList->RemoveRow(iRowIndex);
}
pGridCtrlList->AdjustLayout();
}
示例2: DoParse
//************************************************************************************
void CBCGPOutlineParser::DoParse (const CString& strBuffer,
const int nStartOffset, const int nEndOffset,
CObList& lstResults)
{
ASSERT (nStartOffset >= 0);
ASSERT (nEndOffset < strBuffer.GetLength ());
ASSERT (nStartOffset <= nEndOffset);
m_strOut.Empty ();
CList <Lexeme, Lexeme&> lstStack;
Lexeme lexemStackTop (0, LT_Eps, 0, 0);
lstStack.AddTail (lexemStackTop);
int nOffset = nStartOffset;
while (nOffset <= nEndOffset)
{
// Get next lexem:
Lexeme lexemNext = GetNext (strBuffer, nOffset, nEndOffset);
Lexeme lexemTop = lstStack.GetTail ();
if (lexemNext.m_nType == LT_EndOfText)
{
break;
}
// Parser logic:
switch (lexemNext.m_nType)
{
case LT_BlockStart:
lstStack.AddTail (lexemNext);
break;
case LT_BlockEnd:
if (lexemTop.m_nType == LT_BlockStart &&
lexemTop.m_nBlockType == lexemNext.m_nBlockType)
{
// Push Block:
lstStack.RemoveTail ();
Lexeme lexemRes (lexemTop.m_nBlockType, LT_CompleteBlock, lexemTop.m_nStart, lexemNext.m_nEnd);
PushResult (lexemRes, lstResults);
}
else
{
lstStack.AddTail (lexemNext);
}
break;
case LT_CompleteBlock:
{
// Push Comment:
PushResult (lexemNext, lstResults);
}
break;
case LT_CustomBlock:
break;
}
}
// Finish parsing:
while (!lstStack.IsEmpty ())
{
Lexeme lexem = lstStack.RemoveTail ();
PushResult (lexem, lstResults);
}
}
示例3: Output
void CRemote::Output(LPCTSTR pszName)
{
if ( _tcsstr( pszName, L".." ) || _tcschr( pszName, L'/' ) ) return;
CString strValue = Settings.General.Path + L"\\Remote\\" + pszName + L".html";
CFile hFile;
if ( ! hFile.Open( strValue, CFile::modeRead ) ) return;
int nBytes = (int)hFile.GetLength();
CAutoVectorPtr< BYTE > pBytes( new BYTE[ nBytes ] );
hFile.Read( pBytes, nBytes );
hFile.Close();
LPCSTR pBody = (LPCSTR)(BYTE*)pBytes;
if ( nBytes > 3 && pBytes[0] == 0xEF && pBytes[1] == 0xBB && pBytes[2] == 0xBF )
{
// Skip BOM
pBody += 3;
nBytes -= 3;
}
CString strBody = UTF8Decode( pBody, nBytes );
CList<BOOL> pDisplayStack;
for ( BOOL bDisplay = TRUE; ; )
{
int nStart = strBody.Find( L"<%" );
if ( nStart < 0 )
{
if ( bDisplay )
m_sResponse += strBody;
break;
}
else if ( nStart >= 0 )
{
if ( bDisplay && nStart > 0 )
m_sResponse += strBody.Left( nStart );
strBody = strBody.Mid( nStart + 2 );
}
int nEnd = strBody.Find( L"%>" );
if ( nEnd < 0 ) break;
CString strKey = strBody.Left( nEnd );
strBody = strBody.Mid( nEnd + 2 );
strKey.Trim();
ToLower( strKey );
if ( strKey.IsEmpty() )
{
// Nothing
}
else if ( strKey.GetAt( 0 ) == L'=' && bDisplay )
{
strKey = strKey.Mid( 1 );
strKey.Trim();
if ( m_pKeys.Lookup( strKey, strValue ) )
m_sResponse += strValue;
}
else if ( strKey.GetAt( 0 ) == L'?' )
{
strKey = strKey.Mid( 1 );
strKey.Trim();
if ( strKey.IsEmpty() )
{
if ( ! pDisplayStack.IsEmpty() )
bDisplay = pDisplayStack.RemoveTail();
}
else
{
if ( strKey.GetAt( 0 ) == L'!' )
{
strKey = strKey.Mid( 1 );
strKey.Trim();
if ( ! m_pKeys.Lookup( strKey, strValue ) ) strValue.Empty();
pDisplayStack.AddTail( bDisplay );
bDisplay = bDisplay && strValue.IsEmpty();
}
else
{
if ( ! m_pKeys.Lookup( strKey, strValue ) ) strValue.Empty();
pDisplayStack.AddTail( bDisplay );
bDisplay = bDisplay && ! strValue.IsEmpty();
}
}
}
}
}
示例4: 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);
}
示例5: ParseHelper
//.........这里部分代码省略.........
{
// If we're in nested false conditionals, then ignore.
if (nestedFalseConditionals > 0)
{
SkipToEol(codePtr);
nestedFalseConditionals--;
continue;
}
}
}
if (stricmp(command, "if") == 0 ||
stricmp(command, "elif") == 0)
{
// Our CondInfo structure.
CondInfo condInfo;
// If the command is an elif, then pop the old state.
if (tolower(command[0]) == 'e')
{
// The conditional stack can't be empty on an elif.
if (conditionalStack.IsEmpty())
{
CString err;
err.Format("!!elif used with no preceding !!if.");
throw TException(TException::CONDSTACK_EMPTY, err);
}
// Get the current conditionalStack state. We are most
// interested in retaining the m_thisLevelTrue variable.
condInfo = conditionalStack.GetTail();
// Remove the old state, because it was false.
conditionalStack.RemoveTail();
}
// if and elif are setup in this format:
// !!if var [cond] [condCheck]
// condCheck is only optional if cond doesn't exist.
// var is required.
// Get the requested dictionary entry name.
CString var = ParseToken(codePtr, &helper);
/* if (var.IsEmpty())
{
CString err;
err.Format("The variable is missing.");
throw TException(TException::IF_VAR_MISSING, err);
}
*/
CString cond = ParseToken(codePtr, &helper);
CString condCheck = ParseToken(codePtr, &helper);
/* if (!cond.IsEmpty() && condCheck.IsEmpty())
{
CString err;
err.Format("The conditional is missing.");
throw TException(TException::IF_COND_CHECKVAR_MISSING, err);
}
*/
// Check for a ! symbol.
bool isNot = false;
if (!var.IsEmpty() && var[0] == '!')
{
isNot = true;
var = var.Mid(1);
}
示例6: CalcButtonLocations
//.........这里部分代码省略.........
else // usual button
{
if (stripe.breadth + szButton.cx <= nMaxSize)
{
stripe.breadth += szButton.cx;
stripe.buttonCount ++;
if (szButton.cy > stripe.size)
stripe.size = szButton.cy;
}
else
{
if (stripe.buttonCount > 0)
{
listStripes.AddTail (stripe);
}
stripe.buttonCount = 1;
stripe.breadth = szButton.cx; // cy for horz.
stripe.size = szButton.cy; // cx for horz.
}
}
}
bPrevSeparator = bSep;
}
if (stripe.buttonCount > 0)
{
listStripes.AddTail (stripe);
}
if (listStripes.IsEmpty ())
{
return CSize (0, 0);
}
if (listStripes.GetTail ().breadth == 0) // last item is separator
{
listStripes.RemoveTail ();
}
// Now calculate total size
int totalLength = m_nCaptionHeight + 4;
int maxBreadth = nMaxSize;
POSITION posStripes = listStripes.GetHeadPosition ();
while (posStripes != NULL)
{
stripe = listStripes.GetNext (posStripes);
ASSERT (stripe.buttonCount > 0);
totalLength += stripe.size;
if (stripe.breadth > maxBreadth)
{
maxBreadth = stripe.breadth;
}
}
if (!bCalcOnly)
{
CPoint ptButtonPos = rectClient.TopLeft ();
posStripes = listStripes.GetHeadPosition ();
stripe = ButtonStripe();
for (POSITION pos = m_Buttons.GetHeadPosition (); pos != NULL;)
{
pButton = (CBCGPToolbarButton*)m_Buttons.GetNext (pos);
if (pButton == NULL)
{
break;
}