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


C++ List::Delete方法代码示例

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


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

示例1: main

int main() {

	// New list
    List<int> list;

    // Append nodes to the list
    list.Append(100);
    list.Print();
    list.Append(200);
    list.Print();
    list.Append(300);
    list.Print();
    list.Append(400);
    list.Print();
    list.Append(500);
    list.Print();

    // Delete nodes from the list
    list.Delete(400);
    list.Print();
    list.Delete(300);
    list.Print();
    list.Delete(200);
    list.Print();
    list.Delete(500);
    list.Print();
    list.Delete(100);
    list.Print();

	return 0;
}
开发者ID:syvjohan,项目名称:cppFun,代码行数:31,代码来源:main.cpp

示例2:

TEST(List, can_delete) { //
	List<int> list;
	list.AddToHead(1);
	list.AddToHead(2);//2,1
	list.AddElementOrdered(3);
	ASSERT_NO_THROW(list.Delete());
}
开发者ID:SemenBevzuk,项目名称:Disjoint_set,代码行数:7,代码来源:test_list.cpp

示例3: main

// Тестовый пример
void main()
{
    // Создаем объект класса List
    List lst;

    // Тестовая строка
    char s[] = "Hello, World !!!\n";
    // Выводим строку
    cout << s << "\n\n";
    // Определяем длину строки
    int len = strlen(s);
    // Загоняем строку в список
    for(int i = 0; i < len; i++)
        lst.Add(s[i]);
    // Распечатываем содержимое списка
    lst.Print();
    // Удаляем три элемента списка
    lst.Del();
    lst.Del();
    lst.Del();
    //Распечатываем содержимое списка
    lst.Print();

    //Вставляем 3-й символ, согласно нумерации массива с нуля
    lst.Insert('+',2);
    lst.Print();

    //удаляем 3-й символ
    lst.Delete(2);
    lst.Print();

    //находим позицию элемента 'l'
    cout<<"First position of 'l': "<<lst.Search('l')<<endl<<endl;
}
开发者ID:ShinShil,项目名称:new_dz_IT_Step,代码行数:35,代码来源:dz27_1.cpp

示例4: test

void test(){
	List * Head = new List(2);
	Head->Insert(2);
	Head->Insert(2);
	Head->Insert(15);
	Head->Insert(7);
	Head->Insert(15);
	Head->Insert(5);
	Head->Insert(5);
	Head->Print();
	Head->Delete(5);
	Head->Delete(5);
	Head->Delete(5);
	Head->Delete(7);
	Head->Print();
}
开发者ID:Incairne,项目名称:CSLabs,代码行数:16,代码来源:LabCh6.cpp

示例5: Concat

//------------------------------------------------------------------------------
//Функция объединения двух упорядоченных списков с сохранением порядка
List Concat(List list1,List list2)
{
    if (list1.root==NULL || list2.root==NULL)
    {
        cout <<"Concat2:error: one or more lists is empty\n";
    }
    TNode *temp1,*temp2;
    temp1=list1.last;
    temp2=list2.root;
    while (temp2!=NULL)
    {
        for (;;)
        {
            if ( (temp1->data < temp2->data) || (temp1->prev==NULL) ) break;
            temp1=temp1->prev;
        }
        if ( (temp1==list1.root) && (temp1->data > temp2->data) )
            list1.AddBefore(temp1,temp2->data);
        else
            list1.AddAfter(temp1,temp2->data);
        temp1=list1.last;
        if (temp2->next==NULL) break;
        temp2=temp2->next;
        list2.Delete(list2.root);
    }
    return list1;
}
开发者ID:scorpion235,项目名称:Archive,代码行数:29,代码来源:task2.cpp

示例6: main

int main( )
{
	// New list
	List list;

	// Append nodes to the list
	list.Append( 100 );
	list.Print( );
	list.Append( 200 );
	list.Print( );
	list.Append( 300 );
	list.Print( );
	list.Append( 400 );
	list.Print( );
	list.Append( 500 );
	list.Print( );

	// Delete nodes from the list
	list.Delete( 400 );
	list.Print( );
	list.Delete( 300 );
	list.Print( );
	list.Delete( 200 );
	list.Print( );
	list.Delete( 500 );
	list.Print( );
	list.Delete( 100 );
	list.Print( );


	std::list<int> myList;
	myList.push_back( 5 );
	myList.push_front( 3 );
	myList.push_back( 9 );
	myList.remove( 5 );


	for ( auto it = myList.begin(); it != myList.end(); it++ )
		cout << ( *it ) << endl;


	return 0;
}
开发者ID:M0eB3,项目名称:cpp-practice,代码行数:43,代码来源:linked-list.cpp

示例7: refresh_processes

void refresh_processes ( List &black_list , List &black_list_checks , List &processes )
{
  unsigned int cont;

/* Walking the list */
  for ( cont = 0 ; cont < black_list.Len () ; cont ++ )
  {
  /* If the process DIED */
    if ( processes.Find ( black_list.Get ( cont ) ) == FALSE )
    {
    /* Deleting this OLD PID */
      black_list.Delete ( cont );
      black_list_checks.Delete ( cont );

    /* Compensating the element extraction */
      cont --;
    }
  }
}
开发者ID:CoreSecurity,项目名称:Embarcadero-Workaround,代码行数:19,代码来源:Embarcadero-Workaround.cpp

示例8: ListUnitTest

    bool ListUnitTest()
    {
        List *t = new List();
        List *s = NULL;
        List *u = NULL;

        List::Add(&t, new List());
        List::Add(&t, new List());
        List::Add(&t, new List());

        t->Delete(&t);
        t->Delete(&t);
        t->Delete(&t);

        List::Add(&t, new List());
        List::Add(&t, new List());

        s = t->head->Extract();
        u = t->tail->Extract();

        return true;
    }
开发者ID:default0,项目名称:zeldablackmagic,代码行数:22,代码来源:List.cpp

示例9: main

void main() 
{ 
	List t; 
	int n; 
	do{ 
		cout<<"\n***********************主菜单*****************************";
		cout<<"\n\n************** 1.增加城市;            *******************"; 
		cout<<"\n\n************** 2.删除城市;            *******************"; 
		cout<<"\n\n************** 3.查询城市信息;        *******************"; 
		cout<<"\n\n************** 4.修改城市信息;        *******************"; 
		cout<<"\n\n************** 5.查询某坐标附近的城市;*******************";
		cout<<"\n\n************** 6.其他按键退出程序;    *******************";
		cout<<"\n\n**********************************************************"<<endl;
		cout<<"\n请输入你的选择操作:"; 
		cin>>n; 
		switch(n) {		 
			case 1:
				t.Insert();//1.增加城市
				cout<<"\n按任意键返回菜单>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>";
				_getch();
				cout<<"\n";
				break; 
			case 2:
				t.Delete(); //2.删除城市
				cout<<"\n按任意键返回菜单>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>";
				_getch();
				cout<<"\n";
				break; 
			case 3:
				t.Search(); //3.查询城市信息
				cout<<"\n按任意键返回菜单>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>";
				_getch();
				cout<<"\n";
				break; 
			case 4:
				t.Change();//4.修改城市信息
				cout<<"\n按任意键返回菜单>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>";
				_getch();
				cout<<"\n";
				break; 
			case 5:
				t.Nearcity();//5.查询某点附近的城市
				cout<<"\n按任意键返回菜单>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>";
				_getch();
				cout<<"\n";
			    break; 
			default:
				break; //6.其他按键退出程序
	    } 
	}while(n>0&&n<6);  
} 
开发者ID:linjinze999,项目名称:CollegeProjects,代码行数:51,代码来源:main.cpp

示例10: main

int main() 
{ 

   List<int> list; 
   for(int i=0;i<10;i++) list.Insert(i+1,i*(1+i)); 
   int a[10],b[10]; 
   for(int i=0;i<list.Length();i++) cout<<list.GetElem(1+i,a[i])<<endl; 
  
   cout<<list.Length()<<endl; 
   cout<<list.LocateElem(90)<<endl; 
   list.NextElem(0,b[0]); 
   cout<<b[0]<<endl; 
   cout<<list.Delete(4,b[1])<<endl; 
   for(int i=0;i<list.Length();i++) cout<<list.GetElem(1+i,a[i])<<endl; 

  
    return 0; 
} 
开发者ID:JohnnyXq,项目名称:Algorithm,代码行数:18,代码来源:TListTest.cpp

示例11: menu

void menu(){
	List * intList = new List;
	int choice=0;
	enum menuChoices {PRINT, INSERT, DELETE, EXIT};
	cout << "Lab exercise for Chapter 6 Lists" << endl;
	while(choice!=4){
		cout << "Please pick from the following options:" << endl;
		cout << "[1] Print current list" << endl;
		cout << "[2] Insert integer to list" << endl;
		cout << "[3] Delete integer from list" << endl;
		cout << "[4] Exit" << endl << endl;
		choice = getInt();
		cout << endl;
		switch(choice-1){
			case PRINT:
				intList->Print();
				break;
			case INSERT:
				int newInt;
				cout << "Enter the new integer to be added" << endl << endl;
				newInt = getInt();
				cout << endl;
				intList->Insert(newInt);
				break;
			case DELETE: 
				int tarInt;
				cout << "Enter the integer to be deleted" << endl << endl;
				tarInt = getInt();
				cout << endl;
				intList->Delete(tarInt);
				break;
			case EXIT:
				cout << "Goodbye." << endl << endl;
				delete intList;
				break;
			default:
				cout << "Please enter a valid option." << endl << endl;
		}
	}

}
开发者ID:LPAMNijoel,项目名称:CSLabs,代码行数:41,代码来源:Ch6Lab+Enhanced.cpp

示例12: WillAccept

int GWindow::WillAccept(List<char> &Formats, GdcPt2 Pt, int KeyState)
{
	int Status = DROPEFFECT_NONE;
	
	for (char *f=Formats.First(); f; )
	{
		if (stricmp(f, LGI_FileDropFormat) == 0)
		{
			f = Formats.Next();
			Status = DROPEFFECT_COPY;
		}
		else
		{
			Formats.Delete(f);
			DeleteArray(f);
			f = Formats.Current();
		}
	}
	
	return Status;
}
开发者ID:FEI17N,项目名称:Lgi,代码行数:21,代码来源:GWindow.cpp

示例13: main

int main(){
	//read("in.txt");
	List l;
	int x,c;
	do{
		c = prompt();
		switch(c){
			case 1:
				cout << "Please, Enter the number to be Inserted : \n";
				cin >> x;
				l.Insert(x);
				break;
			case 2:
				cout << "Please, Enter the number to be Deleted : \n";
				cin >> x;
				x = l.Delete(x);
				if (x == -1)
					cout << "Element not found!\n";
				break;
			case 3:
				l.Print();
				cout << "\n";
				break;
			case 4:
				l.PrintRev();
				cout << "\n";
				break;
			case 5:
				cout << "Please, Enter the index of the element to be swapped with it's successor : \n";
				cin >> x;
				l.Swap(x);
				break;
			case 6:
				l.Reverse();
				break;
			default:
				return 0;
		}
	}while(c < 7);
}
开发者ID:AhMeDz333,项目名称:List-Implementation,代码行数:40,代码来源:test.cpp

示例14:

void operator delete[](void* p)throw()
{
	if(p == NULL) return;
	MemManager.Delete(Node(reinterpret_cast<long>(p)));
	free(p);
}
开发者ID:Mosquitooo,项目名称:MemManager,代码行数:6,代码来源:MemTrace.cpp

示例15: main

int main(){
    // New list
    List list;
	Node *answer;
    // Add_End nodes to the list
    list.Add_End(111);
    list.Print();
    list.Add_End(222);
    list.Print();
    list.Add_End(333);
    list.Print();
    list.Add_End(444);
    list.Print();
    list.Add_End(555);
    list.Print();
	cout << endl << endl;

    // Delete nodes from the list
    list.Delete(444);
    list.Print();
//    list.Delete(333);
//    list.Print();
//    list.Delete(222);
//    list.Print();
//    list.Delete(555);
//    list.Print();
//    list.Delete(111);
//    list.Print();
//    cout<<endl<<endl;
//	
//	cout << "Testing Add_Front: and others"<<endl;
//    list.Add_Front(888);
//    list.Print();
//	list.Add_Front(999);
//	list.Print();
//	list.Add_Front(49);
//	list.Print();
//	cout<<endl<<endl;
	
//	cout << "Checking find function"<<endl;
//	answer = list.Find(888);
//	cout<<"Value for node returned by find function call with 888 is "<<answer->Data()<<"."<<endl;
//	cout<<"Checking find function"<<endl;
//	answer = list.Find(999);
//	cout<<"Value for node returned by find function call with 888 is "<<answer->Data()<<"."<<endl;
//	
//	cout<<"Checking find function"<<endl;
//	answer = list.Find(49);
//	cout<<"Value for node returned by find function call with 888 is "<<answer->Data()<<"."<<endl;
//	cout<<"Call find function with value not in list."<<endl;
//	answer = list.Find(7);
//    if(answer == NULL)
//	{
//		cout<<"returned null pointer since 7 not found"<<endl;
//       	
//	}
//	else
//	{
//	   	cout<< "in else of answer == NULL where Value for node returned by find function call with 7 is "<<answer->Data()<<"."<<endl;
//	}
//	
//	cout<<"testing delete_front: "<<endl;
//	list.Delete_Front();
//	list.Print();
//	cout<<"testing delete_end: "<<endl;
//	
//	list.Delete_End();
//	list.Print();
	
    return 0;
}
开发者ID:rikhily,项目名称:LearningToCode,代码行数:71,代码来源:LinkedList.cpp


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