list&list模拟

  • 1.list使用
  • 2、list模拟
  • 附录

1.list使用

 list常见接口不做介绍,跟前面vector有相似之处,跟数据结构list基本一样。
alt
 因为list使用带头的双向循环链表实现的,不能用小标访问,只能用迭代器或范围for访问
alt

 list有成员函数sort,来实现排序
alt
 void unique(),去重,去重先先要排序

void test_list1()
{list<int> lt1 = { 10,2,3,3,4,5,6 };list<int> ::iterator it = lt1.begin();while (it != lt1.end()){cout << *it << " ";it++;}cout << endl;//list不支持sort//sort(lt1.begin(), lt1.end(), greater<int>());//list有自己的排序算法lt1.sort();it = lt1.begin();while (it != lt1.end()){cout << *it << " ";it++;}cout << endl;lt1.sort(greater<int>());it = lt1.begin();while (it != lt1.end()){cout << *it << " ";it++;}cout << endl;//unique 去重//先排序,在去重lt1.unique();for (auto e : lt1){cout << e << " ";  //10 6 5 4 3 2}cout << endl;
}

alt
 splice粘接
 void splice(const _iterator position,list& x);把x粘接到pos位置。

void test_list2()
{//splice:粘接std::list<int> mylist1, mylist2;std::list<int>::iterator it;// set some initial values:for (int i = 1; i <= 4; ++i)mylist1.push_back(i);      // mylist1: 1 2 3 4for (int i = 1; i <= 3; ++i)mylist2.push_back(i * 10);   // mylist2: 10 20 30it = mylist1.begin();++it;                         // points to 2mylist1.splice(it, mylist2); // mylist1: 1 10 20 30 2 3 4// mylist2 (empty)// "it" still points to 2 (the 5th element
}

void splice(const_iterator position,list& x,const_itrator i);
把list的第i个位置的数粘接到position位置.

void test_list3()
{list<int> mylist;for (int i = 1; i <= 4; i++){mylist.push_back(i);  //mylist:   1 2 3 4} //想把3转移到头list<int>::iterator  it = find(mylist.begin(), mylist.end(), 3);//void splice (const_iterator position, list& x, const_iterator i);//把list的第i个位置的数粘接到position位置mylist.splice(mylist.begin(), mylist, it);
}

2、list模拟

 先写申请一个节点的类,把节点弄成一个类,相当与搞了一个新的数据类型。

//这是第一个类 ListNode
//所谓的类就是把成员对象和成员函数封装在一起.
//这个全部弄成共有
//供后面存储数据来用
template<class T>
struct ListNode
{ListNode<T>* _next;ListNode<T>* _prev;T _data;//const T& data是接受常量//不能权限放大,会报错ListNode(const T& data = T()):_next(nullptr),_prev(nullptr),_data(data){}
};

 先写list的大框架

template<class T>
class list
{typedef ListNode<T> Node;
public://无参构造函数就是默认构造list(){_head = new Node;_head->_prev = _head;_head->_next = _head;}void push_back(const T& data){//...}
private:Node* _head;
};

 写push_back()先跑通框架

void push_back(const T& data)
{Node* newnode = new Node(data);Node* tail = _head->_prev;//tail newnode  _headtail->_next = newnode;newnode->_prev = tail;newnode->_next = _head;_head->_prev = newnode;
}

alt
 带头双向循环链表,非常简单,写尾插即可,通过_head->_prev找到尾巴,尾巴,新节点,头插入即可。


 然后把节点封装成迭代器。把节点写成一个类,封装成迭代器所具有的属性,即可。先写·迭代器的行为,在进行封装。

void list_test1()
{list<int> lt1;lt1.push_back(1);lt1.push_back(2);lt1.push_back(3);lt1.push_back(4);list<int>::iterator it = lt1.begin();while (it != lt1.end()){cout << (*it) << " ";++it;}
}

 通过iterator it = it1.begin(),定义一个对象it,把it初始化为第一个节点的位置,然后进行以下运算符重载,!=,前置++,*就可以了。

template<class T>
class ListIterator
{typedef ListIterator<T> Self;typedef ListNode<T> Node;
public:ListIterator(Node* node = T()){_node = node;}//拷贝构造不要//赋值也不要T& operator*(){return _node->_data;}bool operator!=(const Self& it){return _node != it._node;}Self& operator++(){_node = _node->_next;return *this;}
public:Node* _node;
};

 const_iterator可以通过*的运算符重载的返回值+const实现,具体在增加一个模版参数即可,不过多叙述

//Ref引用
//Ptr指针
template<class T,class Ref,class Ptr>
struct  ListIterator
{typedef ListNode<T> Node;typedef ListIterator<T,Ref,Ptr> Self;public:Node* _node;ListIterator(Node* node):_node(node){}//拷贝构造和赋值写也可以,不写也可以//这儿是浅拷贝ListIterator(const Self& it){_node = it._node;}//++itSelf& 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;}//T* operator->()//{//	return &(_node->_data);//}Ptr operator->(){return &(_node->_data);}////这个是前置//T& operator*()//{//	return _node->_data;//}//这个是前置Ref operator*(){return _node->_data;}bool operator!=(const Self& it){return _node != it._node;}bool operator==(const Self& it){return _node == it._node;}
};

 写insert,iterator insert(iterator pos,const T& x);
在pos前面插入,返回的是x所在节点的位置

//在pos前面插入
//没有迭代器失效
iterator insert(iterator pos, const T& x)
{Node* next = pos._node;Node* newnode = new Node(x);Node* prev = next->_prev;prev->_next = newnode;newnode->_prev = prev;newnode->_next = next;next->_prev = newnode;return iterator(newnode);
}

 写erase,iterator erase(iterator pos),防止迭代器失效,返回的是pos的下一个位置

//erase后pos失效了,pos指向节点被释放了
iterator erase(iterator pos)
{assert(pos != end());Node* cur = pos._node;Node* next = cur->_next;Node* prev = cur->_prev;prev->_next = next;next->_prev = prev;delete cur;return iterator(next);
}

 写void clear(),清空,只剩头结点

void clear()
{list<T>::iterator it = begin();while (it != end()){//防止迭代器失效it = erase(it);}
}

 写~list(),先clear,在释放头节点

~list()
{//Node* cur = _head->_next;//while (cur != _head)//{//	Node* next = cur->_next;//	delete cur;//	cur = next;//}//delete _head;//_head = nullptr;clear();delete _head;_head = nullptr;
}

 写voId init_empty()保证有头结点,在后面插入数据

void empty_init()
{_head = new Node;_head->_next = _head;_head->_prev = _head;
}

 写拷贝构造,initializer_list< T >为参数的构造函数

//拷贝构造
//lt2(lt1)
list(const list<T>& lt)
{//引入这个是弄个头结点empty_init();for (const auto& e : lt){push_back(e);}
}list(initializer_list<T>il)
{empty_init();for (const auto& e : il){push_back(e);}
}
//lt1 = lt3
//lt所在的
list<T>& operator= (list<T>lt)
{std :: swap(_head,lt._head);return *this;
}

 再说一下list& operator= (listlt),注意形参是拷贝构造的一份,和赋值_head,把头地址交换即可,lt在栈桢销毁时,就会销毁交换的那个_head.

附录

#define  _CRT_SECURE_NO_WARNINGS 1
#pragma once
#include <iostream>
#include <list>
#include <algorithm>
#include <assert.h>
using namespace std;namespace wyj
{//这是第一个类 ListNode//所谓的类就是把成员对象和成员函数封装在一起.//这个全部弄成共有//供后面存储数据来用template<class T>struct ListNode{ListNode<T>* _next;ListNode<T>* _prev;T _data;//const T& data是接受常量//不能权限放大,会报错ListNode(const T& data = T()):_next(nullptr),_prev(nullptr),_data(data){}};//Ref引用//Ptr指针template<class T,class Ref,class Ptr>struct  ListIterator{typedef ListNode<T> Node;typedef ListIterator<T,Ref,Ptr> Self;public:Node* _node;ListIterator(Node* node):_node(node){}//拷贝构造和赋值写也可以,不写也可以//这儿是浅拷贝ListIterator(const Self& it){_node = it._node;}//++itSelf& 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;}//T* operator->()//{//	return &(_node->_data);//}Ptr operator->(){return &(_node->_data);}////这个是前置//T& operator*()//{//	return _node->_data;//}//这个是前置Ref operator*(){return _node->_data;}bool operator!=(const Self& it){return _node != it._node;}bool operator==(const Self& it){return _node == it._node;}};//template<class T>//class ListConstIterator//{//	typedef ListNode<T> Node;//	typedef ListConstIterator<T> Self;//	Node* _node;//public://	ListConstIterator(Node* node)//		:_node(node)//	{}//	//拷贝构造和赋值写也可以,不写也可以//	//这儿是浅拷贝//	ListConstIterator(const Self& it)//	{//		_node = it._node;//	}//	//++it//	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;//	}//	const T* operator->()//	{//		return &(_node->_data);//	}//	//这个是前置//	const T& operator*()//	{//		return _node->_data;//	}//	bool operator!=(const Self& it)//	{//		return _node != it._node;//	}//	bool operator==(const Self& it)//	{//		return _node == it._node;//	}//};template<class T >class list{//封装成私有,只能list内部用typedef ListNode<T> Node;public://ListIterator通过传节点对节点进一步处理//typedef ListIterator<T> iterator;//typedef ListConstIterator<T> const_iterator;typedef ListIterator<T,T&,T*> iterator;typedef ListIterator<T,const T&,const T*> const_iterator;iterator begin(){//iterator it(_head->_next);//return it;//匿名对象//iterator这个类把这个节点封装了,通过传这个节点给iterator//调用iterator的构造函数,把节点给iterator中的_nodereturn iterator(_head->_next);}iterator end(){return iterator(_head);}const_iterator begin()  const{//iterator it(_head->_next);//return it;//匿名对象return const_iterator(_head->_next);}const_iterator end()  const{return const_iterator(_head);}void empty_init(){_head = new Node;_head->_next = _head;_head->_prev = _head;}list(){_head = new Node;_head->_next = _head;_head->_prev = _head;// empty_init()}//拷贝构造//lt2(lt1)list(const list<T>& lt){//引入这个是弄个头结点empty_init();for (const auto& e : lt){push_back(e);}}list(initializer_list<T>il){empty_init();for (const auto& e : il){push_back(e);}}//lt1 = lt3//lt所在的list<T>& operator= (list<T>lt){std :: swap(_head,lt._head);return *this;}~list(){//Node* cur = _head->_next;//while (cur != _head)//{//	Node* next = cur->_next;//	delete cur;//	cur = next;//}//delete _head;//_head = nullptr;clear();delete _head;_head = nullptr;}void clear(){list<T>::iterator it = begin();while (it != end()){//防止迭代器失效it = erase(it);}}void push_back(const T& x){//Node* newnode = new Node(x);//Node* tail = _head->_prev;////tail->_next = newnode;//newnode->_prev = tail;//newnode->_next = _head;//_head->_prev = newnode;insert(end(), x);}void pop_back(){erase(--end());}void push_front(const T& x){insert(begin(), x);}void pop_front(){erase(begin());}//在pos前面插入//没有迭代器失效iterator insert(iterator pos, const T& x){Node* next = pos._node;Node* newnode = new Node(x);Node* prev = next->_prev;prev->_next = newnode;newnode->_prev = prev;newnode->_next = next;next->_prev = newnode;return iterator(newnode);}//erase后pos失效了,pos指向节点被释放了iterator erase(iterator pos){assert(pos != end());Node* cur = pos._node;Node* next = cur->_next;Node* prev = cur->_prev;prev->_next = next;next->_prev = prev;delete cur;return iterator(next);}private:Node* _head;};void func(const list<int>& lt){list<int>::const_iterator it = lt.begin();while (it != lt.end()){cout << (*it) << " ";++it;}cout << endl;}void test_list1(){list<int>l1;l1.push_back(1);l1.push_back(2);l1.push_back(3);l1.push_back(4);l1.push_back(5);//调用begin,把节点给iterator,用iterator来接受list<int>::iterator it = l1.begin();while (it != l1.end()){cout << (*it) << " ";*it += 10;++it;}cout << endl;for (auto e : l1){cout << e << " ";++it;}cout << endl;}struct Pos{Pos(int row =0,int col = 0):_row(row),_col(col){}int _row;int _col; };void test_list2(){list<Pos>lt1;lt1.push_back(Pos(100, 100));lt1.push_back(Pos(200, 200));lt1.push_back(Pos(300, 400));list<Pos>::iterator it = lt1.begin();while (it != lt1.end()){//为了可读性,省略了一个箭头cout << it->_row << ":"<<it->_col<<endl;//cout << it.operator->()->_row << ":" << it.operator->()->_col << endl;++it;}}void test_list3(){list<int>l1;l1.push_back(1);l1.push_back(2);l1.push_back(3);l1.push_back(4);l1.push_back(5);func(l1);cout << endl;l1.push_front(10);l1.push_front(10);l1.push_front(10);func(l1);cout << endl;l1.pop_front();l1.pop_front();func(l1);cout << endl;l1.pop_back();l1.pop_back();func(l1);cout << endl;}void test_list4(){list<int>lt1;lt1.push_back(1);lt1.push_back(2);lt1.push_back(3);lt1.push_back(4);lt1.push_back(5);func(lt1);list<int> lt2(lt1);func(lt2);list<int> lt3;lt3 = lt1;func(lt2);}void test_list5(){list<int> lt1 = { 1,2,3,4,5,6 };func(lt1);}
}
#include "list.h"
#include "list1.h"
void test_list1()
{list<int> lt1 = { 10,2,3,3,4,5,6 };list<int> ::iterator it = lt1.begin();while (it != lt1.end()){cout << *it << " ";it++;}cout << endl;//list不支持sort//sort(lt1.begin(), lt1.end(), greater<int>());//list有自己的排序算法lt1.sort();it = lt1.begin();while (it != lt1.end()){cout << *it << " ";it++;}cout << endl;lt1.sort(greater<int>());it = lt1.begin();while (it != lt1.end()){cout << *it << " ";it++;}cout << endl;//unique 去重//先排序,在去重lt1.unique();for (auto e : lt1){cout << e << " ";  //10 6 5 4 3 2}cout << endl;
}void test_list2()
{//splice:粘接std::list<int> mylist1, mylist2;std::list<int>::iterator it;// set some initial values:for (int i = 1; i <= 4; ++i)mylist1.push_back(i);      // mylist1: 1 2 3 4for (int i = 1; i <= 3; ++i)mylist2.push_back(i * 10);   // mylist2: 10 20 30it = mylist1.begin();++it;                         // points to 2mylist1.splice(it, mylist2); // mylist1: 1 10 20 30 2 3 4// mylist2 (empty)// "it" still points to 2 (the 5th element
}void test_list3()
{list<int> mylist;for (int i = 1; i <= 4; i++){mylist.push_back(i);  //mylist:   1 2 3 4} //想把3转移到头list<int>::iterator  it = find(mylist.begin(), mylist.end(), 3);//void splice (const_iterator position, list& x, const_iterator i);//把list的第i个位置的数粘接到position位置mylist.splice(mylist.begin(), mylist, it);
}int main()
{//wyj::test_list5();//test_list1();bit::list_test1();return 0;
} 

 /*****************************************************/

 /*****************************************************/

 下来练习代码

#define  _CRT_SECURE_NO_WARNINGS 1
#pragma once
#include <iostream>
#include <assert.h>
using namespace std;//先定义一个节点类
//所谓的类就是把成员变量和成员方法封装在一起
//例如这个节点类
//成员变量是指定义节点的变量,方法是指操作这个节点的方法
//那么通过成员变量和成员方法把这个节点类封装好之后,外面该怎么用呢?
//类可以理解为就是个新定义的数据类型,那么其它类使用,则在另一个类
//中定义这个类来使用
//比如:在另一个类中使用这个节点类,则在这个类中定义即可,并且你在
//这个类中定义一个节点类,会自动初始化,销毁,这是类的一个特性namespace wyj
{template<class T>struct ListNode{//定义数据ListNode<T>*  _prev;ListNode<T>*  _next;T _data;//初始化ListNode(const T& data = T()):_prev(nullptr),_next(nullptr),_data(data){}//拷贝构造ListNode(const ListNode& node){_prev = node._prev;_next = node._next;_data = node._data;}//赋值ListNode& operator=(const ListNode& node){_prev = node._prev;_next = node._next;_data = node._data;return *this;}};//在这儿,把ListNode要封装一下,符合iterator的特性template<class T,class Ref>class ListIterator{//要封装节点,首先要把节点引进进来typedef ListNode<T> Node;typedef ListIterator<T, Ref> Self;public://ListIterator(Node* node = nullptr):_node(node){}ListIterator(const Self& iterator){_node = iterator._node;}ListIterator& operator=(const Self& iterator){_node = iterator._node;return *this;}ListIterator& operator++(){_node = _node->_next;return *this;}ListIterator operator++(int){ListIterator tmp = *this;_node = _node->_next;return tmp;}ListIterator& operator--(){_node = _node->_prev;return *this;}ListIterator operator--(int){ListIterator tmp = *this;_node = _node->_prev;return tmp;}Ref operator*()  {return _node->_data;}bool operator!=(const Self& iterator){return  _node != iterator._node;}bool operator==(const Self& iterator){return  _node == iterator._node;}//private:public:Node* _node;};template<class T>class list{private://这儿把封装好的ListNode重命名//ListNode可以理解为一种新的数据类型typedef ListNode<T> Node;public:typedef ListIterator<T,T&> iterator;typedef ListIterator<T,const T&> const_iterator;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);}//写构造函数list(){//调用了Node的构造函数_head = new Node;_head->_prev = _head;_head->_next = _head;}template<class InputIterator>list(InputIterator first, InputIterator last){init_empty();while (first != last){push_back(*first);first++;}}list(initializer_list<T> il){init_empty();for (const auto& e : il){push_back(e);}}void init_empty(){_head = new Node;_head->_prev = _head;_head->_next = _head;}list(const list<T>& lt){init_empty();for (auto& e : lt){push_back(e);}}~list(){clear();delete _head;_head = nullptr;}//犯了一个错误,要加换了,还const//list& operator=(const list lt)list<T>& operator=(list<T> lt){swap(_head,lt._head);return *this;}void clear(){iterator it = begin();while (it != end()){it = erase(it);}}//插入void push_back(const T& data ){Node* newnode = new Node(data);Node* tail = _head->_prev;//  tail newnode _headtail->_next = newnode;newnode->_prev = tail;newnode->_next = _head;_head->_prev = newnode;//insert(end(), data);}void pop_back(){erase(--end());}void push_front(const T& data){insert(begin(),data);}void pop_front(){erase(begin());}//在pos前面插入void insert(iterator pos, const T& data){Node* newnode = new Node(data);Node* cur = pos._node;Node* prev = cur->_prev;//prev  newnode curprev->_next = newnode;newnode->_prev = prev;newnode->_next = cur;cur->_prev = newnode;}iterator erase(iterator pos){assert(pos != end());Node* cur = pos._node;Node* prev = cur->_prev;Node* next = cur->_next;prev->_next = next;next->_prev = prev;delete cur;return iterator(next);}private:Node* _head;};void list_test1(){list<int> lt1;lt1.push_back(1);lt1.push_back(2);lt1.push_back(3);lt1.push_back(4);list<int>::iterator it = lt1.begin();for (auto e : lt1){cout << e << " ";}cout << endl;while (it != lt1.end()){(*it) += 10;it++;}for (auto e : lt1){cout << e << " ";}}void Func(const list<int>& lt){list<int>::const_iterator it = lt.begin();while (it != lt.end()){cout << (*it) << " ";it++;}cout << endl;}void list_test2(){list<int> lt1;lt1.push_back(1);lt1.push_back(2);lt1.push_back(3);lt1.push_back(4);lt1.push_back(5);Func(lt1);lt1.push_front(10);lt1.push_front(20);lt1.push_front(30);Func(lt1);lt1.pop_front();lt1.pop_front();Func(lt1);lt1.pop_back();lt1.pop_back();Func(lt1);lt1.pop_back();lt1.pop_back();lt1.pop_back();lt1.pop_back();//lt1.pop_back();Func(lt1);}void list_test3(){//构造函数list<int> lt1 = { 1,2,3,4,5,6,7,8 };for (auto& e : lt1){cout << e << " ";}cout << endl;list<int> lt2 = lt1;for (auto& e : lt1){cout << e << " ";}cout << endl;list<int>lt3;lt3 = lt1;for (auto& e : lt1){cout << e << " ";}cout << endl;}
}




本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如若转载,请注明出处:http://www.pswp.cn/pingmian/92757.shtml
繁体地址,请注明出处:http://hk.pswp.cn/pingmian/92757.shtml
英文地址,请注明出处:http://en.pswp.cn/pingmian/92757.shtml

如若内容造成侵权/违法违规/事实不符,请联系英文站点网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

在CentOS 7上将PostgreSQL数据库从默认路径迁移到自定义目录

在CentOS 7上将PostgreSQL数据库从默认路径迁移到自定义目录&#xff0c;需遵循以下步骤。假设原数据目录为“/var/lib/pgsql/12/data”&#xff0c;目标目录为“/new/path/pgdata”。 1、步骤概览 停止PostgreSQL服务创建新目录并设置权限复制数据文件&#xff08;保留权限&am…

C语言基础06——结构体(struct)

一、结构体的概念结构体&#xff08;struct&#xff09;是 C 语言中一种自定义数据类型&#xff0c;它允许你将不同类型的数据项组合在一起&#xff0c;形成一个新的复合数据类型。想象一下&#xff1a;如果要表示一个 "学生"&#xff0c;需要包含姓名&#xff08;字…

小白入门指南:Edge SCDN 轻松上手

在互联网飞速发展的当下&#xff0c;网站性能与安全至关重要。对于小白而言&#xff0c;Edge SCDN 可能是个陌生概念&#xff0c;但它却能极大助力网站运营。本文将用简单易懂的语言&#xff0c;带大家了解 Edge SCDN&#xff0c;探讨其运用方法。​一、Edge SCDN 是什么&#…

探秘酵母单杂交技术:解锁基因调控的密码

在生命科学研究领域&#xff0c;基因的表达调控机制一直是科学家们关注的焦点。为了深入探究这一复杂过程&#xff0c;众多先进技术应运而生&#xff0c;酵母单杂交技术便是其中极具价值的一项&#xff0c;它为研究 DNA 与蛋白质之间的相互作用提供了独特视角与有效手段。酵母单…

大模型备案要点一次过【附材料清单详解】

最近&#xff0c;广东省公布了最新一批的大模型备案&#xff08;登记&#xff09;名单&#xff0c;很多准备要做大模型备案的企业都在纷纷咨询&#xff1a;“大模型备案的周期是多久&#xff1f;”“做大模型备案有什么要求&#xff1f;”“做大模型备案一共需要准备多少材料&a…

启保停-----------单相照明灯的接法

一.单相照明灯-K21使用的器材,单相电能表,空开,插座,开关,灯泡二.启 保 停1.需要用到的器材1.空开2.三相电机3.接触器4.熔断器5.按钮2.电路的作用按按钮 运转 在按按钮 停止运转3.电动4.加上辅助触点 控制电路5.在加上按钮 停止电路

TF-IDF:信息检索与文本挖掘的统计权重基石

本文由「大千AI助手」原创发布&#xff0c;专注用真话讲AI&#xff0c;回归技术本质。拒绝神话或妖魔化。搜索「大千AI助手」关注我&#xff0c;一起撕掉过度包装&#xff0c;学习真实的AI技术&#xff01; 1. 背景与定义 TF-IDF 是一种统计加权方法&#xff0c;用于衡量词语在…

[论文阅读] (41)JISA24 物联网环境下基于少样本学习的攻击流量分类

《娜璋带你读论文》系列主要是督促自己阅读优秀论文及听取学术讲座&#xff0c;并分享给大家&#xff0c;希望您喜欢。由于作者的英文水平和学术能力不高&#xff0c;需要不断提升&#xff0c;所以还请大家批评指正&#xff0c;非常欢迎大家给我留言评论&#xff0c;学术路上期…

react中父子数据流动和事件互相调用(和vue做比较)

前言&#xff1a;react中父子数据流动和事件互相调用&#xff0c;父组件给子组件数据&#xff0c;父组件调用子组件的事件&#xff0c;同理&#xff0c;子也可以调用父的数据和传值。react是单向数据流&#xff0c;具体使用跟vue是不同的。1、父组件的数据传给子组件&#xff0…

杰理手表-增加提示音-提示音音量调整--使用提示音

本章节非常详细的介绍这个提示音的增加-调整-使用&#xff0c;其余耳机包之类的也是差不多的&#xff01;&#xff01; 目录 1.添加自己需要用的提示音 2.根据添加的提示音-代码中配置 1.在tone_player.h中枚举里添加本次提示音的名称 2.把定义好的提示音放到tone_player.…

数据库的基本操作(视图,存储,触发器)

1、视图&#xff08;1&#xff09;什么是视图视图是虚拟表&#xff0c;是基于查询结果的可视化表&#xff0c;视图的作用有&#xff1a;①简化复杂查询 ②限制数据访问 ③提供数据独立性 ④汇总数据&#xff08;2&#xff09;怎么创建视图创建视图 CREATE OR REPLACE VIEW 视图…

Pytest项目_day13(usefixture方法、params、ids)

usefixture 我们还可以使用mark.usefixtures来调用fixture 这样相比在传入参数处调用fixture&#xff0c;会更加直接 但是如果我们在一个测试用例中使用了多个usefixtures&#xff0c;那么测试用例会先调用离他最近的那个fixtureparams fixture中还可以带参数 当我们用request.…

Rust 异步生态实战:Tokio 调度、Pin/Unpin 与零拷贝 I/O

&#x1f31f; Hello&#xff0c;我是蒋星熠Jaxonic&#xff01; &#x1f308; 在浩瀚无垠的技术宇宙中&#xff0c;我是一名执着的星际旅人&#xff0c;用代码绘制探索的轨迹。 &#x1f680; 每一个算法都是我点燃的推进器&#xff0c;每一行代码都是我航行的星图。 &#x…

通用 maven 私服 settings.xml 多源配置文件(多个仓库优先级配置)

<?xml version"1.0" encoding"UTF-8"?> <settings xmlns"http://maven.apache.org/SETTINGS/1.0.0"xmlns:xsi"http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation"http://maven.apache.org/SETTINGS/1.0.…

AT F-Intervals 题解

简化题意&#xff1a; 有 nnn 个区间&#xff0c;保证所有区间同时覆盖一个点&#xff0c;每次将区间平移一个单位&#xff0c;问使得区间两两不交的最小操作数&#xff08;端点处可重叠&#xff09;。n≤5000。l,r≤231−1n\leq 5000。l,r\leq 2^{31}-1n≤5000。l,r≤231−1。…

《飞算Java AI:从安装到需求转实战项目详细教学》

前引&#xff1a;在当今快速发展的技术环境中&#xff0c;人工智能&#xff08;AI&#xff09;与编程语言的结合为开发者提供了前所未有的便利。飞算Java AI作为一款智能化编程工具&#xff0c;能够显著提升Java开发效率&#xff0c;减少重复性工作&#xff0c;并帮助开发者更专…

6深度学习Pytorch-神经网络--过拟合欠拟合问题解决(Dropout、正则化、早停法、数据增强)、批量标准化

过拟合、欠拟合 在机器学习和深度学习中&#xff0c;过拟合&#xff08;Overfitting&#xff09;和欠拟合&#xff08;Underfitting&#xff09;是模型训练过程中常见的两种问题&#xff0c;直接影响模型的泛化能力&#xff08;即对未见过的数据的预测能力&#xff09;。 1. 欠…

新手向:Python编写简易翻译工具

Python 编写简易翻译工具&#xff1a;从零开始入门指南对于刚接触编程的新手来说&#xff0c;编写一个实用的工具是快速入门的好方法。本文将详细介绍如何用 Python 编写一个简易的翻译工具&#xff0c;帮助理解基础编程概念和实际应用。无需任何编程基础&#xff0c;只需按照步…

爬虫与数据分析结和

任务描述 爬取目标&#xff1a;高三网中国大学排名一览表&#xff0c;网址为 2021中国的大学排名一览表_高三网。爬取内容&#xff1a;学校名称、总分、全国排名、星级排名、办学层级。数据存储&#xff1a;爬取后的数据保存在 CSV 文件中。 代码实现&#xff08;爬取&#xff…

linux下安装php

1.php官网下载所需要的php版本 下载php 2.将下载好的压缩包上传至linux服务器&#xff0c;解压并配置 tar -xzvf php-8.4.11.tar.gz cd php-8.4.11 ./configure --prefix/home/admintest/php/php-8.4.11 # 配置安装路径和选项 make sudo make install3.使用make命令编译完成…