本文整理汇总了C++中CObList::AddHead方法的典型用法代码示例。如果您正苦于以下问题:C++ CObList::AddHead方法的具体用法?C++ CObList::AddHead怎么用?C++ CObList::AddHead使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CObList
的用法示例。
在下文中一共展示了CObList::AddHead方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dlg
LRESULT CNewWindowDlg::OnP4UserList(WPARAM wParam, LPARAM lParam)
{
CCmd_Users *pCmd= (CCmd_Users *) wParam;
if(!pCmd->GetError())
{
SET_APP_HALTED(TRUE);
// Get the column names and count
CStringArray cols;
int nbrcols = MainFrame()->GetUserColNamesAndCount(cols);
CString str;
CString caption = LoadStringResource(IDS_PERFORCE_USERS);
CString subkey = _T("User List");
CObList const *users = pCmd->GetList();
CObList *objs = new CObList;
int index = 0;
for(POSITION pos= users->GetHeadPosition(); pos != NULL; index++)
{
CP4User *user = (CP4User *) users->GetNext(pos);
int subitem;
CP4Object *newObj= new CP4Object();
for (subitem = -1; ++subitem < nbrcols; )
{
switch(subitem)
{
case 0:
str = user->GetUserName();
break;
case 1:
str = user->GetEmail();
break;
case 2:
str = user->GetFullName();
break;
case 3:
str = user->GetLastAccess();
break;
default:
ASSERT(0);
continue;
}
if (!subitem)
newObj->Create(str);
else
newObj->AddField(str);
}
objs->AddHead(newObj);
delete user;
}
if( objs->GetCount() == 0 )
{
CString txt;
txt.FormatMessage(IDS_NO_s_AVAILABLE, caption);
AfxMessageBox(txt, MB_ICONEXCLAMATION);
SET_APP_HALTED(FALSE);
delete objs;
return 0;
}
CString msg;
msg.FormatMessage( IDS_NUMBER_OF_USERS_n, index );
MainFrame()->UpdateStatus( msg );
// Display the dialog box.
CP4ListBrowse dlg(&(MainFrame()->GetUserView()->GetListCtrl()));
dlg.SetP4ObjectFont(GetFont());
dlg.SetP4ObjectType(P4USER_SPEC);
dlg.SetP4ObjectList(objs);
dlg.SetP4ObjectCols(&cols);
dlg.SetP4ObjectCurr(&m_user);
dlg.SetP4ObjectSKey(&subkey);
dlg.SetP4ObjectCaption(&caption);
dlg.SetP4ObjectImage(CP4ViewImageList::VI_USER);
CString old_port;
CString old_user;
if (!m_bSamePort)
{
old_port = GET_P4REGPTR()->GetP4Port();
old_user = GET_P4REGPTR()->GetP4User();
GET_P4REGPTR()->SetP4Port(m_port, TRUE, FALSE, FALSE);
GET_P4REGPTR()->SetP4User(_T(""), TRUE, FALSE, FALSE);
}
int retcode= dlg.DoModal();
if (!m_bSamePort)
{
GET_P4REGPTR()->SetP4Port(old_port, TRUE, FALSE, FALSE);
GET_P4REGPTR()->SetP4User(old_user, TRUE, FALSE, FALSE);
}
SET_APP_HALTED(FALSE);
// Delete the object list
for(POSITION pos=objs->GetHeadPosition(); pos!=NULL; )
delete (CP4Object *) objs->GetNext(pos);
delete objs;
//.........这里部分代码省略.........
示例2: main
int main(){
system("chcp 1251 > nul");
list<double> l1(2);
list<double> l2(4, 5);
list<double> l3(l2);
list<double> l4;
lPrint(l2);
for (int i = 0; i < 6; ++i){
l4.push_back(9.0034 + i);
}
int i = 0;
for (list<double>::iterator it = l4.begin(); it != l4.end(); ++it){
cout << "l(" << i++ << ") = " << *it << endl;
}
cout << endl;
l4.push_front(0.234);
lPrint(l4);
cout << '\n';
LPrint<double>(l4);
cout << endl;
double_list l5;
l5.assign(l4.begin(), l4.end());
lPrint(l5);
cout << endl;
double_list::iterator iter;
iter = l5.begin();
l5.insert(iter, 65.5434);
lPrint(l5);
cout << endl;
l5.erase(iter);
lPrint(l5);
l5.remove(65.5434);
cout << endl;
lPrint(l5);
cout << endl;
l5.remove_if(is_greater_ten);
lPrint(l5);
cout << "\nSorting\n";
l4.sort();
l4.sort(less<double>());
lPrint(l4);
cout << endl;
l4.sort(greater);
lPrint(l4);
cout << "\nIs list empty? " << ((l4.empty()) ? "Yes" : "No") << endl;
l4.clear();
cout << "Is list empty? " << ((l4.empty()) ? "Yes" : "No") << endl;
std::list<Event<>*> myList;
myList.push_back(new Event<>("Тест 1", "Москва", 0, EVENT_TYPE_CONFERENCE));
myList.push_back(new Event<>("Тест 2", "Москва", 0, EVENT_TYPE_CONFERENCE));
myList.reverse();
for (auto i = myList.begin(); i != myList.end(); ++i) {
cout << **i << endl;
}
myList.sort(comp);
myList.remove_if(is_test);
myList.reverse();
myList.insert(myList.begin(), new Event<>("Тест 3", "Москва", 0, EVENT_TYPE_CONFERENCE));
myList.pop_front();
myList.erase(myList.begin());
myList.push_back(new Event<>("Тест 4", "Москва", 0, EVENT_TYPE_CONFERENCE));
myList.clear();
cout << "Is list empty? " << ((myList.empty()) ? "Yes" : "No") << endl;
CObList list;
list.AddTail(new Event<>("Тест 1", "Москва", 0, EVENT_TYPE_CONFERENCE));
list.AddTail(new Event<>("Тест 2", "Москва", 0, EVENT_TYPE_CONFERENCE));
list.AddHead(new Event<>("Тест 3", "Москва", 0, EVENT_TYPE_CONFERENCE));
list.InsertAfter(list.GetHeadPosition(), new Event<>("Тест 4", "Москва", 0, EVENT_TYPE_CONFERENCE));
list.InsertBefore(list.GetTailPosition(), new Event<>("Тест 5", "Москва", 0, EVENT_TYPE_CONFERENCE));
POSITION pos;
for (pos = list.GetHeadPosition(); pos != NULL;)
{
cout << *((Event<>*) list.GetNext(pos)) << endl << endl;
}
for (pos = list.GetTailPosition(); pos != NULL;)
{
cout << *((Event<>*) list.GetPrev(pos)) << endl << endl;
}
//.........这里部分代码省略.........