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


C++ LinkList类代码示例

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


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

示例1: main

int main(int argc, char* argv[])
{
	LinkList<Node> linklist;

	Node* a1 = new Node;
	a1->a = 1;
	linklist.Push_Back(a1);
	
	Node* a2 = new Node;
	a2->a = 2;
	linklist.Push_Back(a2);

	Node* a3 = new Node;
	a3->a = 3;
	linklist.Push_Back(a3);

	Node* a4 = new Node;
	a4->a = 4;
	linklist.Push_Back(a4);

	Node* a5 = new Node;
	a5->a = 5;
	linklist.Push_Back(a5);

	while(!linklist.IsEmpty())
	{
		printf("dump:%d\n", linklist.Dump());
		Node* temp = linklist.Front();
		printf("value:%d\n", temp->a);
		linklist.Pop_Front();
	}

	printf("end\n");
	return 0;
}
开发者ID:exile223001,项目名称:net,代码行数:35,代码来源:linklist.cpp

示例2: Display

void Display(LinkList<T> &list)
{
    cout << list.Count() << " element(s): ";
    for (int i = 1; i <= list.Count(); i++)
    {
        cout << list.Get(i) << " ";
    }
    cout << endl;
}
开发者ID:fanjeffrey,项目名称:axiom.master,代码行数:9,代码来源:test_linklist.cpp

示例3: fill_maps

static void fill_maps(LinkList& hl, LinkMap& to, LinkMap& from) 
{
    for(LinkList_iter hl_iter = hl.begin(); hl_iter != hl.end(); hl_iter++) {
	if(hl_iter->a->unknown)
	    to[hl_iter->b].push_back(hl_iter->a);

	if(hl_iter->b->unknown)
	    from[hl_iter->a].push_back(hl_iter->b);
    }
}
开发者ID:drurowin,项目名称:netmap,代码行数:10,代码来源:hostclass.c

示例4: test_deleteDuplicates

void test_deleteDuplicates(){
    LinkList link;
    int arr[] = {1, 1, 1, 1};
    vector<int> ivec(arr, arr+4);
    ListNode *p1 = link.createListNode(ivec);
    link.printListNode(p1);
    p1 = link.deleteDuplicates(p1);
    link.printListNode(p1);
    cout<<endl; 
}
开发者ID:duchangtuan,项目名称:Basic_Algorithm,代码行数:10,代码来源:main.cpp

示例5: main

int main()
{
	LinkList<int> intlinklist;
	for (int i = 0; i < 5; i++)
	{
		intlinklist.Insert(i, i);
	}
	intlinklist.PrintList();
	system("pause");
}
开发者ID:HScarb,项目名称:Data-Structure-Learn,代码行数:10,代码来源:Source.cpp

示例6: test4

void test4()
{
	LinkList list;
	list.PushBack(4);
	list.PushBack(1);
	list.PushBack(3);
	list.PushBack(2);
	cout << list << endl;
	list.BubbleSort();
	cout << list << endl;

}
开发者ID:XHfight,项目名称:CPP-Language,代码行数:12,代码来源:test.cpp

示例7: console_blit_completion

int console_blit_completion(ContextPtr env, char *cmd) {
    if(!cmd) return 0;

    ViewPortPtr screen = getSelectedScreen();
    if(!screen) {
        ::error("no screen currently selected");
        return 0;
    }

    // Find completions
    BlitPtr exactBlit;
    LinkList<Blit> retList;
    LinkList<Blit> &list = screen->getBlitter()->getBlits();
    std::string cmdString(cmd);
    std::transform(cmdString.begin(), cmdString.end(), cmdString.begin(), ::tolower);
    std::copy_if(list.begin(), list.end(), retList.begin(), [&] (BlitPtr blit) {
                     std::string name = blit->getName();
                     std::transform(name.begin(), name.end(), name.begin(), ::tolower);
                     if(name == cmdString) {
                         exactBlit = blit;
                     }
                     return name.compare(cmdString) == 0;
                 });

    if(retList.empty()) return 0;

    if(exactBlit != NULL) {
        snprintf(cmd, MAX_CMDLINE, "%s = ", exactBlit->getName().c_str());
        return 1;
    }

    if(cmdString.empty()) {
        notice("List available blits");
    } else {
        notice("List available blits starting with \"%s\"", cmd);
    }

    int c = 0;
    char tmp[256];
    std::for_each(retList.begin(), retList.end(), [&] (BlitPtr b) {
                      if(c % 4 == 0) {
                          if(c != 0) {
                              ::act("%s", tmp);
                          }
                          tmp[0] = '\0';
                      }
                      strncat(tmp, "\t", sizeof(tmp) - 1);
                      strncat(tmp, b->getName().c_str(), sizeof(tmp) - 1);
                      ++c;
                  });
    return c;
}
开发者ID:diorcety,项目名称:FreeJ,代码行数:52,代码来源:console_calls_ctrl.cpp

示例8: host_count

//gives a weigth for a node
int HostClass::host_count() const
{
    //kick out doubles
    network.sort(); network.unique();

    //run through network and count the number of occurences
    int hit_count = 0;
    for(LinkList_iter li = network.begin(); li != network.end(); li++) 
	if(li->a->ip == ip || li->b->ip == ip)
	    hit_count++;

    return hit_count;
}   
开发者ID:drurowin,项目名称:netmap,代码行数:14,代码来源:hostclass.c

示例9: TEST

TEST(rearrangeTest, rearrage){
    LinkList* lst = new LinkList();
    int input[] = {9,3,7,1,6,5,2,8};
    int result[] = {2,1,3,9,7,6,5,8};
    for (int i = 0; i < 8; i++){
        lst->addToTail(input[i]);
    }
    rearrange(lst, 4);
    for (int i = 0; i < lst->length; i++){
        EXPECT_EQ(result[i], lst->getAtIndex(i));
    }
    
}
开发者ID:wen1,项目名称:CTCI5e,代码行数:13,代码来源:rearrageTest.cpp

示例10: test2

void test2()
{
	LinkList list;
	list.PushBack(1);
	list.PushBack(2);
	list.PushBack(3);
	list.PushBack(4);
	cout << list << endl;
	list.PopBack();
	cout << list << endl;
	list.PopFront();
	cout << list << endl;

}
开发者ID:XHfight,项目名称:CPP-Language,代码行数:14,代码来源:test.cpp

示例11:

const LinkList<T> & LinkList<T>::operator =(const LinkList<T> &rhs)
//PreCondition: rhs != this
//PostCondition: rhs is copyed into this
{
	if(this!=&rhs)
	{
		resize(rhs.length());
		for(int i=0;i<rhs.length();i++)
		{
			at(i)=rhs.atc(i);
		}
	}
	return *this;
}
开发者ID:holtsoftware,项目名称:potential-octo-wallhack,代码行数:14,代码来源:LinkList.cpp

示例12: test1

void test1()
{
	LinkList list;
	list.PushBack(1);
	list.PushBack(2);
	list.PushBack(3);
	list.PushBack(4);
	cout << list << endl;
	LinkList l2(list);
	cout << l2 << endl;
	list.PushFront(0);
	cout << list << endl;

}
开发者ID:XHfight,项目名称:CPP-Language,代码行数:14,代码来源:test.cpp

示例13: main

int main()
{
	int num;
	cin >> num;

	long long *Hash1 = new long long[num];           //哈希表1
	long long *Hash2 = new long long[num];           //哈希表2
	LinkList *NumList = new LinkList[Prime];         //储存相同字符串序号
	string *str = new string[num];                   //储存输入字符串
	int *list = new int[Prime];                      //作比较时用
	for (int i = 0; i < Prime; ++i)
		list[i] = -2;

	for (int i = 0; i < num; ++i)                    //每输入一个字符串,对应得到两个哈希值
	{
		cin >> str[i];
		Hash1[i] = BKDRHash(str[i], str[i].length());
		Hash2[i] = RSHash(str[i], str[i].length());
		if (list[Hash1[i]] == -2)                    //哈希值1还没有出现过
		{
			list[Hash1[i]] = i;
			//设置头结点
			NumList[list[Hash1[i]]].setNum(list[Hash1[i]]);
		}
		else if (Hash2[list[Hash1[i]]] == Hash2[i])  //哈希值2相等
			NumList[list[Hash1[i]]].add(i);          //加点
	}

	bool output = false;                             //判断是否有相同字符串
	LinkList *p;
	for (int i = 0; i < Prime; ++i)
	{
		p = &NumList[i];
		if (p->NextNode() != NULL)
		{
			output = true;                           //有相同字符串
			for (; p != NULL; p = p->NextNode())
			{
				p->outputNum();                      //输出
				cout << " ";
			}
			cout << endl;
		}
	}

	if (!output)                                     //没有相同字符串
		cout << -1;
	return 0;
}
开发者ID:ShowLo,项目名称:Data-and-Algorithm,代码行数:49,代码来源:Hash.cpp

示例14: test1

void test1()
{
	LinkList mylist;
	mylist.push_back(1);
	mylist.push_back(2);
	mylist.push_back(3);
	LinkList mylist2(mylist);
	LinkList mylist3;
	mylist3 = mylist2;
	cout << mylist2 << endl;
	cout << mylist << endl;
	cout << mylist3 << endl;


}
开发者ID:wsy081414,项目名称:CPP-practice,代码行数:15,代码来源:CPP实现链表.cpp

示例15: console_filter_completion

int console_filter_completion(ContextPtr env, char *cmd) {
    if(!cmd) return 0;

    // Find completions
    FilterPtr exactFilter;
    LinkList<Filter> retList;
    LinkList<Filter> &list = env->getFilters();
    std::string cmdString(cmd);
    std::transform(cmdString.begin(), cmdString.end(), cmdString.begin(), ::tolower);
    std::copy_if(list.begin(), list.end(), retList.begin(), [&] (FilterPtr filter) {
                     std::string name = filter->getName();
                     std::transform(name.begin(), name.end(), name.begin(), ::tolower);
                     if(name == cmdString) {
                         exactFilter = filter;
                     }
                     return name.compare(cmdString) == 0;
                 });

    if(retList.empty()) return 0;

    if(exactFilter != NULL) {
        ::notice("%s :: %s", exactFilter->getName().c_str(), exactFilter->getDescription().c_str());
        snprintf(cmd, MAX_CMDLINE, "%s", exactFilter->getName().c_str());
        return 1;
    }

    if(cmdString.empty()) {
        notice("List available filters");
    } else {
        notice("List available filters with \"%s\"", cmd);
    }

    int c = 0;
    char tmp[256];
    std::for_each(retList.begin(), retList.end(), [&] (FilterPtr f) {
                      if(c % 4 == 0) {
                          if(c != 0) {
                              ::act("%s", tmp);
                          }
                          tmp[0] = '\0';
                      }
                      strncat(tmp, "\t", sizeof(tmp) - 1);
                      strncat(tmp, f->getName().c_str(), sizeof(tmp) - 1);
                      ++c;
                  });
    return c;
}
开发者ID:diorcety,项目名称:FreeJ,代码行数:47,代码来源:console_calls_ctrl.cpp


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