c++中的list容器讲解

2023-11-09

1. list的介绍及使用

1.1 list的介绍

list的文档介绍

  1. list是可以在常数范围内在任意位置进行插入和删除的序列式容器,并且该容器可以前后双向迭代。
  2. list的底层是双向链表结构,双向链表中每个元素存储在互不相关的独立节点中,在节点中通过指针指向
    其前一个元素和后一个元素。
  3. list与forward_list非常相似:最主要的不同在于forward_list是单链表,只能朝前迭代,已让其更简单高
    效。
  4. 与其他的序列式容器相比(array,vector,deque),list通常在任意位置进行插入、移除元素的执行效率
    更好。
  5. 与其他序列式容器相比,list和forward_list最大的缺陷是不支持任意位置的随机访问,比如:要访问list
    的第6个元素,必须从已知的位置(比如头部或者尾部)迭代到该位置,在这段位置上迭代需要线性的时间
    开销;list还需要一些额外的空间,以保存每个节点的相关联信息(对于存储类型较小元素的大list来说这
    可能是一个重要的因素)

1.2 list的使用

list中的接口比较多,此处类似,只需要掌握如何正确的使用,然后再去深入研究背后的原理,已达到可扩展
的能力。以下为list中一些常见的重要接口

1.2.1 list的构造

构造函数( ( (constructor))) 接口说明
list (size_type n, const value_type& val = value_type()) 构造的list中包含n个值为val的元素
list() 构造空的list
list (const list& x) 拷贝构造函数
list (InputIterator first, InputIterator last) 用[first, last)区间中的元素构造list

1.2.2 list iterator的使用

此处,大家可暂时将迭代器理解成一个指针,该指针指向list中的某个节点。

函数声明 接口说明
begin +end 返回第一个元素的迭代器+返回最后一个元素下一个位置的迭代器
rebegin +rend 返回第一个元素的reverse_iterator,即end位置,返回最后一个元素下一个位置的reverse_iterator,即begin位置

【注意】:

  1. begin与end为正向迭代器,对迭代器执行++操作,迭代器向后移动
  2. rbegin(end)与rend(begin)为反向迭代器,对迭代器执行++操作,迭代器向前移动

1.2.3 list capacity

函数说明 接口说明
empty 检测list是否为空,是返回true,否则返回false
size 返回list中有效节点的个数

1.2.4 list element access

函数说明 接口说明
push_front 在list首元素前插入值为val的元素
pop_front 删除list中第一个元素
push_back 在list尾部插入值为val的元素
pop_back 删除list中最后一个元素
insert 在list position 位置中插入值为val的元素
erase 删除list position位置的元素
swap 交换两个list中的元素
clear 清空list中的有效元素

list中还有一些操作,需要用到时大家可参阅list的文档说明。

1.2.6 list的迭代器失效

前面说过,此处大家可将迭代器暂时理解成类似于指针,迭代器失效即迭代器所指向的节点的无效,即该节
点被删除了。因为list的底层结构为带头结点的双向循环链表,因此在list中进行插入时是不会导致list的迭代
器失效的,只有在删除时才会失效,并且失效的只是指向被删除节点的迭代器,其他迭代器不会受到影响。
list的各个接口代码,演示:

#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<list>
#include<vector>

using namespace std;

//list的构造
void constructor()
{
	/*list<int> l1();*/
	list<int> l2(4, 100);
	list<int> l3(l2.begin(), l2.end());
	list<int> l4(l3);
	int array[5] = { 1,2,3,4,5 };
	list<int> l5(array, array+sizeof(array) / sizeof(array[0]));
	list<int> l6{ 9,8,7,6,5,4 };
	
	// 用迭代器方式打印l5中的元素
	list<int>::iterator it = l5.begin();
	for (; it != l5.end(); ++it)
	{
		cout << *it << " ";
	}
	cout << endl;

	for (auto e : l5)
	{
		cout << e << " ";
	}
	cout << endl;
}


// list迭代器的使用
// 注意:遍历链表只能用迭代器和范围for

void Printlist(const list<int>& l)
{
	// 注意这里调用的是list的 begin() const,返回list的const_iterator对象
	for (list<int>::const_iterator it = l.begin(); it != l.end(); ++it)
	{
		cout << *it << " ";
	}
	cout << endl;
	/*std::list<int> mylist;
	for (int i = 1; i <= 5; ++i) mylist.push_back(i);

	std::cout << "mylist backwards:";
	for (std::list<int>::reverse_iterator rit = mylist.rbegin(); rit != mylist.rend(); ++rit)
		std::cout << ' ' << *rit;

	std::cout << '\n';*/

}

void TestList2()
{
	int array[10] = { 1,2,3,4,5,6,7,8,9,10 };
	list<int> ls(array, array + sizeof(array) / sizeof(array[0]));
	for (auto e : ls)
	{
		cout << e << " ";
	}
	cout << endl;
}

void test3()
{
	
	list<int> lt{ 9,8,7,6,5,4 };
	int sz = lt.size();
	list<int>::iterator it = lt.begin();
	for (int i = 0; i < sz; ++i)
	{
		cout << *it << " ";
		++it;
	}
	cout << endl;
}

// list插入和删除
// push_back/pop_back/push_front/pop_front
void TestList3()
{
	int array[] = { 1,2,3 };
	list<int> L(array, array + sizeof(array) / sizeof(array[0]));

	L.push_back(4);
	L.push_front(0);
	Printlist(L);
	L.pop_back();
	L.pop_front();
	Printlist(L);
}

void TestList4()
{
	int array1[] = { 1,2,3 };
	list<int> L(array1, array1 + sizeof(array1) / sizeof(array1[0]));
	auto pos = ++L.begin();
	cout << *pos << endl;

	L.insert(pos, 5, 5);
	Printlist(L);

	vector<int> v{ 7,8,9 };
	L.insert(pos, v.begin(), v.end());
	Printlist(L);

	L.erase(pos);
	Printlist(L);
	L.erase(L.begin(), L.end());
	Printlist(L);
}

void TestList5()
{
	// 用数组来构造list
	int array1[] = { 1, 2, 3 };
	list<int> l1(array1, array1 + sizeof(array1) / sizeof(array1[0]));
	Printlist(l1);

	// 交换l1和l2中的元素
	list<int> l2;
	l1.swap(l2);
	Printlist(l1);
	Printlist(l2);

	// 将l2中的元素清空
	l2.clear();
	cout << l2.size() << endl;
}

void Testiterator()
{
	int array[10] = { 1,2,3,4,5,6,7,8,9,10 };
	list<int> l1(array, array + sizeof(array) / sizeof(array[0]));
	auto it = l1.begin();
	while (it != l1.end())
	{
		l1.erase(it);
		++it;
	}
}

// 改正
void TestListIterator()
{
	int array[] = { 1,2,3,4,5,6,7,8 };
	list<int> l(array, array + sizeof(array) / sizeof(array[0]));
	auto it = l.begin();
	while (it != l.end())
	{
		l.erase(it++);//erase后it的所指的被删除位置的迭代器失效,通过it++来解决,
		//因为失效的只是指向被删除节点的迭代器,其他迭代器不会受到影响
	}
}

int main()
{
	constructor();
	cout << endl;
	list<int> l1{ 1,2,3,45 };
	Printlist(l1);
	cout << endl;
	TestList2();
	cout << endl;
	test3();
	cout << endl;
	TestList3();
	cout << endl;
	TestList4();
	cout << endl;
	TestList5();
	cout << endl;
	//Testiterator();
	//cout << endl;
	TestListIterator();
	cout << endl;

	return 0;
}

在这里插入图片描述

2. list的模拟实现

2.1 模拟实现list

要模拟实现list,必须要熟悉list的底层结构以及其接口的含义,通过上面的学习,这些内容已基本掌握,现
在我们来模拟实现list。
list.h

#pragma once
#include<iostream>
#include<assert.h>

using namespace std;

namespace hcm
{
	template<class T>
	struct ListNode
	{
		ListNode(const T& val = T())
			:_prev(nullptr)
			, _next(nullptr)
			, _val(val)
		{}

		ListNode<T>* _prev;
		ListNode<T>* _next;
		T _val;
	};

	template<class T,class Ref,class Ptr>
	class ListIterator
	{
		typedef ListNode<T> Node;
		typedef ListIterator<T, Ref, Ptr> Self;
	public:
		typedef Ref Ref;
		typedef Ptr Ptr;
	public:
		//
		// 构造
		ListIterator(Node* node = nullptr)
			:_node(node)
		{}
		// 具有指针类似行为
		Ref operator*()
		{
			return _node->_val;
		}
		Ptr operator->()
		{
			return &(operator*());
		}
		// 迭代器支持移动
		Self& operator++()
		{
			_node = _node->_next;
			return *this;
		}
		Self& operator++(int)
		{
			Self tmp(*this);
			_node = _node->_next;
			return tmp;
		}
		Self& operator--()
		{
			_node = _node->_prev;
			return *this;
		}
		Self& operator--(int)
		{
			Self& tmp(*this);
			_node = _node->_prev;
			return tmp;
		}
		// 迭代器支持比较
		bool operator!=(const Self& l) const
		{
			return _node != l._node;
		}
		bool operator == (const Self& l) const
		{
			return _node == l._node;
		}

		Node* _node;
	};
	template<class Iterator>
	class ReverseListIterator
	{
// 注意:此处typename的作用是明确告诉编译器,Ref是Iterator类中的一个类型,
// 而不是静态成员变量
// 否则编译器编译时就不知道Ref是Iterator中的类型还是静态成员变量
// 因为静态成员变量也是按照 类名::静态成员变量名 的方式访问的
	public:
		typedef typename Iterator::Ref Ref;
		typedef typename Iterator::Ptr Ptr;
		typedef ReverseListIterator<Iterator> Self;
	public:
		ReverseListIterator(Iterator it)
			:_it(it)
		{}
		// 具有指针类似行为
		Ref operator*()
		{
			Iterator temp(_it);
			--temp;
			return *temp;
		}
		Ptr operator->()
		{
			return &(operator*());
		}
		// 迭代器支持移动
		Self& operator++()
		{
			--_it;
			return *this;
		}
		Self& operator++(int)
		{
			Self temp(*this);
			--_it;
			return temp;
		}
		Self& operator--()
		{
			++_it;
			return *this;
		}
		Self& operator--(int)
		{
			Self temp(*this);
			++_it;
			return temp;
		}
		// 迭代器支持比较
		bool operator!=(const Self& l)const
		{
			return _it != l._it;
		}
		bool operator ==(const Self& l) const
		{
			return _it == l._it;
		}

		Iterator _it;
	};

	template<class T>
	class list
	{
		typedef ListNode<T> Node;

	public:
		// 正向迭代器
		typedef ListIterator<T, T&, T*> iterator;
		typedef ListIterator<T, const T&, const T&> const_iterator;

		// 反向迭代器
		typedef ReverseListIterator<iterator> reverse_iterator;
		typedef ReverseListIterator<const_iterator> const_reverse_iterator;
	public:
		///
		// List的构造
		list()
		{
			CreateHead();
		}

		list(int n, const T& value = T())
		{
			CreateHead();
			for (int i = 0; i < n; ++i)
				push_back(value);
		}

		template <class Iterator>
		list(Iterator first, Iterator last)
		{
			CreateHead();
			while (first != last)
			{
				push_back(*first);
				++first;
			}
		}

		list(const list<T>& l)
		{
			CreateHead();

			// 用l中的元素构造临时的temp,然后与当前对象交换
			list<T> temp(l.begin(), l.end());
			this->swap(temp);
		}

		list<T>& operator=(list<T> l)
		{
			this->swap(l);
			return *this;
		}

		~list()
		{
			clear();
			delete _head;
			_head = nullptr;
		}

		///
		// List的迭代器
		iterator begin()
		{
			return iterator(_head->_next);
		}

		iterator end()
		{
			return iterator(_head);
		}

		const_iterator begin()const
		{
			return const_iterator(_head->_next);
		}

		const_iterator end()const
		{
			return const_iterator(_head);
		}

		reverse_iterator rbegin()
		{
			return reverse_iterator(end());
		}

		reverse_iterator rend()
		{
			return reverse_iterator(begin());
		}

		const_reverse_iterator rbegin()const
		{
			return const_reverse_iterator(end());
		}

		const_reverse_iterator rend()const
		{
			return const_reverse_iterator(begin());
		}

		///
		// List的容量相关
		size_t size()const
		{
			Node* cur = _head->_next;
			size_t count = 0;
			while (cur != _head)
			{
				count++;
				cur = cur->_next;
			}

			return count;
		}

		bool empty()const
		{
			return _head->_next == _head;
		}

		void resize(size_t newsize, const T& data = T())
		{
			size_t oldsize = size();
			if (newsize <= oldsize)
			{
				// 有效元素个数减少到newsize
				while (newsize < oldsize)
				{
					pop_back();
					oldsize--;
				}
			}
			else
			{
				while (oldsize < newsize)
				{
					push_back(data);
					oldsize++;
				}
			}
		}
		
		// List的元素访问操作
		// 注意:List不支持operator[]
		T& front()
		{
			return _head->_next->_val;
		}

		const T& front()const
		{
			return _head->_next->_val;
		}

		T& back()
		{
			return _head->_prev->_val;
		}

		const T& back()const
		{
			return _head->_prev->_val;
		}

		
		// List的插入和删除
		void push_back(const T& val)
		{
			insert(end(), val);
		}

		void pop_back()
		{
			erase(--end());
		}

		void push_front(const T& val)
		{
			insert(begin(), val);
		}

		void pop_front()
		{
			erase(begin());
		}

		// 在pos位置前插入值为val的节点
		iterator insert(iterator pos, const T& val)
		{
			Node* pNewNode = new Node(val);
			Node* pCur = pos._node;
			// 先将新节点插入
			pNewNode->_prev = pCur->_prev;
			pNewNode->_next = pCur;
			pNewNode->_prev->_next = pNewNode;
			pCur->_prev = pNewNode;
			return iterator(pNewNode);
		}

		// 删除pos位置的节点,返回该节点的下一个位置
		iterator erase(iterator pos)
		{
			// 找到待删除的节点
			Node* pDel = pos._node;
			Node* pRet = pDel->_next;

			// 将该节点从链表中拆下来并删除
			pDel->_prev->_next = pDel->_next;
			pDel->_next->_prev = pDel->_prev;
			delete pDel;

			return iterator(pRet);
		}

		void clear()
		{
			Node* cur = _head->_next;

			// 采用头删除删除
			while (cur != _head)
			{
				_head->_next = cur->_next;
				delete cur;
				cur = _head->_next;
			}

			_head->_next = _head->_prev = _head;
		}

		void swap(hcm::list<T>& l)
		{
			std::swap(_head, l._head);
		}

	private:
		void CreateHead()
		{
			_head = new Node;
			_head->_prev = _head;
			_head->_next = _head;
		}
	private:
		Node* _head;
	};

}

template<class T>
void PrintList(const hcm::list<T>& l)
{
	auto it = l.begin();
	while (it != l.end())
	{
		cout << *it << " ";
		++it;
	}
	cout << endl;
}

list.cpp

#include"list.h"

// 测试List的构造
void TestList1()
{
	hcm::list<int> l1;
	hcm::list<int> l2(10, 5);
	PrintList(l2);
	int array[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 };
	hcm::list<int> l3(array, array + sizeof(array) / sizeof(array[0]));
	PrintList(l3);
	hcm::list<int> l4(l3);
	PrintList(l4);

	l1 = l4;
	PrintList(l1);

}
// PushBack()/PopBack()/PushFront()/PopFront()
void TestBiteList2()
{
	hcm::list<int> lt;
	lt.push_back(1);
	lt.push_back(2);
	lt.push_back(10);
	PrintList(lt);
	lt.pop_back();
	PrintList(lt);
	lt.push_front(0);
	PrintList(lt);
	lt.pop_front();
	PrintList(lt);

}

// 测试insert和erase
void TestBiteList3()
{
	int array[] = { 1, 2, 3, 4, 5 };
	hcm::list<int> l(array, array + sizeof(array) / sizeof(array[0]));

	auto pos = l.begin();
	l.insert(l.begin(), 0);
	PrintList(l);

	++pos;
	l.insert(pos, 2);
	PrintList(l);

	l.erase(l.begin());
	l.erase(pos);
	PrintList(l);

	// pos指向的节点已经被删除,pos迭代器失效
	cout << *pos << endl;

	auto it = l.begin();
	while (it != l.end())
	{
		it = l.erase(it);
	}
	cout << l.size() << endl;
}

// 测试反向迭代器
void TestBiteList4()
{
	int array[] = { 1, 2, 3, 4, 5 };
	hcm::list<int> l(array, array + sizeof(array) / sizeof(array[0]));

	auto rit = l.rbegin();
	while (rit != l.rend())
	{
		cout << *rit << " ";
		++rit;
	}
	cout << endl;

	const hcm::list<int> cl(l);
	auto crit = l.rbegin();
	while (crit != l.rend())
	{
		cout << *crit << " ";
		++crit;
	}
	cout << endl;
}

int main()
{
	TestList1();
	TestBiteList2();
	TestBiteList3();
	TestBiteList4();

	return 0;
}

运行结果如下:
在这里插入图片描述

3. list与vector的对比

vector与list都是STL中非常重要的序列式容器,由于两个容器的底层结构不同,导致其特性以及应用场景不
同,其主要不同如下:

vector list
底层结构:动态顺序表,一段连续空间 底层结构:带头结点的双向循环链表
随机访问:支持随机访问,访问某个元素效率O(1) 不支持随机访问,访问某个元素效率O(N)
插入和删除:任意位置插入和删除效率低,需要搬移元素,时间复杂度为O(N),插入时有可能需要增容,增容:开辟新空间,拷贝元素,释放旧空间,导致效率更低 任意位置插入和删除效率高,不需要搬移元素,时间复杂度为O(1)
空间利用率:底层为连续空间,不容易造成内存碎片,空间利用率高,缓存利用率高 底层节点动态开辟,小节点容易造成内存碎片,空间利用率低,缓存利用率低
迭代器:原生态指针 对原生态指针(节点指针)进行封装
迭代器失效:在插入元素时,要给所有的迭代器重新赋值,因为插入元素有可能会导致重新扩容,致使原来迭代器失效,删除时,当前迭代器需要重新赋值否则会失效 插入元素不会导致迭代器失效,删除元素时,只会导致当前迭代器失效,其他迭代器不受影响
使用场景:需要高效存储,支持随机访问,不关心插入删除效率 大量插入和删除操作,不关心随机访问
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

c++中的list容器讲解 的相关文章

  • OpenCv读/写视频色差

    我试图简单地使用 openCV 打开视频 处理帧并将处理后的帧写入新的视频文件 我的问题是 即使我根本不处理帧 只是打开视频 使用 VideoCapture 读取帧并使用 VideoWriter 将它们写入新文件 输出文件看起来比输入更 绿
  • 为什么大多数 C 开发人员使用 Define 而不是 const? [复制]

    这个问题在这里已经有答案了 在许多程序中 define与常量具有相同的用途 例如 define FIELD WIDTH 10 const int fieldWidth 10 我通常认为第一种形式优于另一种形式 它依赖于预处理器来处理基本上是
  • 按元组分隔符拆分列表

    我有清单 print L I WW am XX newbie YY ZZ You WW are XX cool YY ZZ 我想用分隔符将列表拆分为子列表 ZZ print new L I WW am XX newbie YY ZZ You
  • C++:重写已弃用的虚拟方法时出现弃用警告

    我有一个纯虚拟类 它有一个纯虚拟方法 应该是const 但不幸的是不是 该接口位于库中 并且该类由单独项目中的其他几个类继承 我正在尝试使用这个方法const不会破坏兼容性 至少在一段时间内 但我找不到在非常量方法重载时产生警告的方法 以下
  • 构造函数中显式关键字的使用

    我试图了解 C 中显式关键字的用法 并查看了这个问题C 中的explicit关键字是什么意思 https stackoverflow com questions 121162 但是 那里列出的示例 实际上是前两个答案 对于用法并不是很清楚
  • 显示异常时的自定义错误消息:从客户端检测到潜在危险的 Request.Form 值

    我在我的 Web 应用程序中使用 ASP NET 的登录控件 当发生此异常时 我想在标签上显示一种有趣的错误类型System Web HttpRequestValidationException A potentially dangerou
  • 从多个类访问串行端口

    我正在尝试使用串行端口在 arduino 和 C 程序之间进行通信 我对 C 编程有点陌生 该程序有多种用户控制形式 每一个都需要访问串口来发送数据 我需要做的就是从每个类的主窗体中写入串行端口 我了解如何设置和写入串行端口 这是我的 Fo
  • 暂停下载线程

    我正在用 C 编写一个非常简单的批量下载程序 该程序读取要下载的 URL 的 txt 文件 我已经设置了一个全局线程和委托来更新 GUI 按下 开始 按钮即可创建并启动该线程 我想要做的是有一个 暂停 按钮 使我能够暂停下载 直到点击 恢复
  • 如何识别 WPF 文本框中的 ValidationError 工具提示位置

    我添加了一个箭头来指示工具提示中的文本框 当文本框远离屏幕边缘时 这非常有效 但是当它靠近屏幕边缘时 工具提示位置发生变化 箭头显示在左侧 Here is the Image Correct as expected since TextBo
  • 如何从网站下载 .EXE 文件?

    我正在编写一个应用程序 需要从网站下载 exe 文件 我正在使用 Visual Studio Express 2008 我正在使用以下代码 private void button1 Click object sender EventArgs
  • C 语言中 =+(等于加)是什么意思?

    我碰到 与标准相反 今天在一些 C 代码中 我不太确定这里发生了什么 我在文档中也找不到它 In ancientC 版本 相当于 它的残余物与最早的恐龙骨头一起被发现 例如 B 引入了广义赋值运算符 使用x y to add y to x
  • 通过 NHibernate 进行查询,无需 N+1 - 包含示例

    我有一个 N 1 问题 我不知道如何解决它 可以在这个问题的底部找到完全可重复的样本 因此 如果您愿意 请创建数据库 设置 NUnit 测试和所有附带的类 并尝试在本地消除 N 1 这是我遇到的真实问题的匿名版本 众所周知 这段代码对于帮助
  • 将构建日期放入“关于”框中

    我有一个带有 关于 框的 C WinForms 应用程序 我使用以下方法将版本号放入 关于 框中 FileVersionInfo GetVersionInfo Assembly GetExecutingAssembly Location F
  • 当“int”处于最大值并使用 postfix ++ 进行测试时,代码定义良好吗?

    示例 未定义行为的一个示例是整数溢出的行为 C11dr 3 4 3 3 int溢出是未定义的行为 但这是否适用于存在循环的以下内容 并且不使用现在超出范围的副作用i 特别是 这是否后缀增量规格帮助 结果的值计算在副作用之前排序 更新操作数的
  • System.Runtime.InteropServices.COMException(0x80040154):[关闭]

    Closed 这个问题不符合堆栈溢出指南 help closed questions 目前不接受答案 我在 C 项目中遇到异常 System Runtime InteropServices COMException 0x80040154 检
  • 结构体指针的动态数组

    我必须使用以下代码块来完成学校作业 严格不进行任何修改 typedef struct char firstName char lastName int id float mark pStudentRecord pStudentRecord
  • 我在在线程序挑战编译器中遇到演示错误

    include
  • 使用 C# 从 DateTime 获取日期

    愚蠢的问题 给定日期时间中的日期 我知道它是星期二 例如我如何知道它的 tue 2 和 mon 1 等 Thanks 您正在寻找星期几 http msdn microsoft com en us library system datetim
  • 实例化 Microsoft.Office.Interop.Excel.Application 对象时出现错误:800700c1

    实例化 Microsoft Office Interop Excel Application 以从 winforms 应用程序生成 Excel 时 出现以下错误 这之前是有效的 但突然间它停止工作了 尽管代码和 Excel 版本没有变化 我
  • 匿名结构体作为返回类型

    下面的代码编译得很好VC 19 00 23506 http rextester com GMUP11493 标志 Wall WX Za 与VC 19 10 25109 0 标志 Wall WX Za permissive 这可以在以下位置检

随机推荐

  • WSL——Kali子系统安装及其相关配置

    Kali子系统安装及其相关配置 一 WSL简介 二 开启WSL功能 三 安装kali子系统 四 安装Windows Terminal 五 对Kali的设置 1 更换更新源 2 安装完整版Kali 六 配置图形化桌面并连接 1 下载 X410
  • mac下编译安装php7.4.5及相关扩展安装

    php7 4 5下载地址 https www php net distributions php 7 4 5 tar gz MAC版本 macOS catalina 10 15 4 编译参数 configure prefix Users m
  • 【ML】对数据处理的几种方法

    数据处理的几种方式 1 All in 2 Backward Elimination 后退梯度 3 Forward Elimination 前进梯度 4 Bidirectional Elimination 比较梯度 5 Score Compa
  • gin框架27--自定义 HTTP 配置

    gin框架27 自定义 HTTP 配置 介绍 案例 说明 介绍 本文主要介绍如何自定义HTTP配置 在gin框架中可以直接使用 http ListenAndServe 来实现 案例 源码 package main import github
  • react中,useState异步更新带来的问题,怎么解决

    React 的 useState 是异步更新状态的 但是有时候我们需要在状态更新后执行一些操作 如果直接使用 setState 可能会导致状态的更新不及时 此时可以使用以下几种解决方案 使用 useEffect 来监听状态的变化 并在其中执
  • WeOpen Good 开源公益计划正式启动!聚开源智慧·行科技向善

    PART 1 缘起和初心 8 15 20 当看到这些数字 你第一时间会想到什么 少 不足一提 亦或是什么呢 1 我们生活的地球上 有超过 70 亿人口 其中 10 亿以上的人 也就是相当于总人口约 15 的人有某种形式的残疾 2 世界范围内
  • linux的自旋锁struct spinlock_t的使用

    在linux中提供了一些机制用来避免竞争条件 最简单的一个种就是自旋锁 例如 当一个临界区的数据在多个函数之间被调用时 为了保护数据不被破坏 可以采用spinlock来保护临界区的数据 当然还有一个就是信号量也是可以实现临界区数据的保护的
  • 直接把软件界面做成游戏界面。CEGUI 专用游戏界面开发库。

    下载 http www cegui org uk wiki index php Downloads 更多中文教程 http www ispinel com 2010 05 26 971 首先感谢李素颙同学的热心和耐心指导 做游戏或者计算机图
  • 对应用数据开发还有疑惑?看这篇就够了!数据存储、管理,通通掌握!

    原文 对应用数据开发还有疑惑 看这篇就够了 数据存储 管理 通通掌握 点击链接查看更多技术内容 数据管理可以做什么 应用数据的持久化怎么实现 如何实现数据库加密 在开发应用进行应用数据的处理时 您是否也会有这些疑问呢 现在 我们推出了更为清
  • Access Token(访问令牌)学习

    Access Token 访问令牌 是一种用于身份验证和授权的令牌 在软件开发中 访问令牌通常用于访问受限资源或执行特定操作 Access Token 通常由身份验证服务器颁发 以授权客户端应用程序代表用户访问受保护的资源 当用户进行身份验
  • opencv笔记之--图片模糊操作和锐化操作

    一 模糊操作 usr bin env python coding utf 8 import cv2 as cv import numpy as np def blur demo image dst cv blur image 15 1 cv
  • go换源

    Windows 版本 SETX GO111MODULE on go env w GOPROXY https goproxy cn direct SETX GOPROXY https goproxy cn direct Linux 版本 ec
  • 部署Zabbix企业级分布式监控

    1 定义 1 1 监控定义 通过一个友好的界面进行浏览整个网站所有的服务器状态 可以在Web前端方便的查看监控数据 可以回溯寻找事故发生时系统的问题和报警情况 分类 传统 zabbix nagois 云原生 prometheus 1 2 z
  • 基于tcpdump实例讲解TCP/IP协议

    前言 虽然网络编程的socket大家很多都会操作 但是很多还是不熟悉socket编程中 底层TCP IP协议的交互过程 本文会一个简单的客户端程序和服务端程序的交互过程 使用tcpdump抓包 实例讲解客户端和服务端的TCP IP交互细节
  • 【深度】谭铁牛院士谈人工智能发展新动态

    来源 Frontiers 11月25日 模式识别与人工智能学科前沿研讨会在自动化所召开 会上 谭铁牛院士做 人工智能新动态 报告 回顾了近代以来历次科技革命及其广泛影响 并根据科学技术发展的客观规律解释了当前人工智能备受关注的深层原因 报告
  • Git工作流程:如何在团队中协作?

    前言 作者主页 雪碧有白泡泡 个人网站 雪碧的个人网站 推荐专栏 java一站式服务 前端炫酷代码分享 uniapp 从构建到提升 从0到英雄 vue成神之路 解决算法 一个专栏就够了 架构咱们从0说 数据流通的精妙之道 文章目录 前言 G
  • 《Happy Birthday》游戏开发记录(送给朋友的小礼物)

    游戏开发的学习记录 项目 Happy Birthday 一个小小小游戏 基于unity给朋友做的一个生日小礼物 之前都是礼物加信 今年想用自己的技能 把信的内容以另一种方式送给她 但在做这个的时候 也学到一些新的东西 所以把这个也记录下来了
  • ieee-explore/springer文献免费下载办法

    http ieeexplore ieee org document xxxxxxx 改为 http ieeexplore ieee org sci hub tw document xxxxxxx 即可免费下载 是哈萨克斯坦女黑客搞的 见下文
  • 一文带你看懂 MySQL 存储引擎

    本文目录 1 MySQL体系结构 2 存储引擎介绍 3 MySQL 存储引擎特性 4 MySQL 有哪些存储引擎 5 了解 MySQL 数据存储方式 6 MySQL存储引擎介绍 6 1 CSV存储引擎 6 1 1 CSV介绍 6 1 2 使
  • c++中的list容器讲解

    文章目录 1 list的介绍及使用 1 1 list的介绍 1 2 list的使用 1 2 1 list的构造 1 2 2 list iterator的使用 1 2 3 list capacity 1 2 4 list element ac