C++初阶-list类的模拟实现

list类的模拟实现

  • 一、基本框架
    • 1.1 节点类
    • 1.2 迭代器类
    • 1.3 list类
  • 二、构造函数和析构函数
    • 2.1 构造函数
    • 2.2 析构函数
  • 三、operator=的重载和拷贝构造
    • 3.1 operator=的重载
    • 3.2 拷贝构造
  • 四、迭代器的实现
    • 4.1 迭代器类中的各种操作
    • 4.1 list类中的迭代器
  • 五、list的增容和删除
    • 5.1 尾插尾删
    • 5.2 头插头删
    • 5.3 任意位置的插入和删除
  • 六、完整代码
    • 6.1 list.h
    • 6.2 test.cpp

一、基本框架

list的底层和vector和string不同,实现也有所差别,特别是在迭代器的设计上,本文讲介绍list的简单模拟实现。
list底层是一个带头双向循环链表,在节点上变化不大。
list整体由三个类组成
1.节点类(封装一个节点)
2.迭代器类
3.list类

1.1 节点类

list节点类是一个模板类以适合于任何类型的ist对象,封装了一个节点需要的基本成员
成员变量
前驱指针 _prev
后继指针 _next
数据存储_data

成员函数
只有一个构造函数,用于初始化节点data数据和置空指针,构造函数的x参数是缺省参数,适应不同场景。
注意节点类不需要拷贝构造和析构函数,对于节点的拷贝构造在list中只需要浅拷贝即可,节点的释放也不在节点类中进行!

template<class T>
struct list_node
{
	list_node<T>* _next;
	list_node<T>* _prev;
	T _data;
};

1.2 迭代器类

  迭代器类也是封装节点,但是迭代器类不会构造节点,只会利用现有节点构造一个迭代器,在迭代器内部通过各种运算符重载对节点的状态做修改!
  其次,会涉及返回节点指针或数据data的引用,所以需要在构造对象时将list数据类型的指针和引用类型传给迭代器对象!
  迭代器在不访问data的情况下返回的都是迭代器,将声明本迭代器类型self,在函数操作完成时返回self(迭代器)即可!

//1、迭代器要么就是原生指针
//2、迭代器要么就是自定义类型对原生指针的封装,模拟指针的行为
template<class T,class Ref,class Ptr>
struct __list_iterator
{
	typedef list_node<T> node;
	typedef __list_iterator<T,Ref,Ptr> self;
	node* _node;
};

迭代器对象不会凭空创造节点,只会利用现有的节点(迭代器节点类型与list节点类型相同),所以不需要拷贝构造和析构函数,浅拷贝足以!

1.3 list类

list类中包含一个头节点和迭代器以及各种操作函数!

template<class T>
class list
{
	typedef list_node<T> node;
public:
	typedef __list_iterator<T,T&,T*> iterator;
	typedef __list_iterator<T,const T&,const T*>const_iterator;
private:
	node* _head;
};

二、构造函数和析构函数

2.1 构造函数

节点类的构造
将节点进行初始化

template<class T>
struct list_node
{
	list_node<T>* _next;
	list_node<T>* _prev;
	T _data;

	list_node(const T& x=T())
		:_next(nullptr)
		,_prev(nullptr)
		,_data(x)
	{}
};

迭代器的构造
成员变量只有结点node,对结点进行初始化

template<class T,class Ref,class Ptr>
struct __list_iterator
{
	typedef list_node<T> node;
	typedef __list_iterator<T,Ref,Ptr> self;
	node* _node;

	__list_iterator(node* n)
		:_node(n)
	{}
};

list类的构造
因为是带头的链表,所以在实例化时必须事先申请一个头结点,所以所有的构造函数都会在操作前申请一个头结点,为了避免代码的冗余,我们将头节点的创建封装为一个函数,在构造函数初始化时调用创建头结点。
当我们需要构造空链表时,直接调用empty_init();函数即可
迭代器区间构造也是调用push_back进行尾插

template<class T>
class list
{
		typedef list_node<T> node;
	public:
		typedef __list_iterator<T,T&,T*> iterator;
		typedef __list_iterator<T,const T&,const T*> const_iterator;
		
		void empty_init()
		{
			_head = new node;
			_head->_next = _head;
			_head->_prev = _head;
		}

		list()
		{
			/*_head = new node;
			_head->_next = _head;
			_head->_prev = _head;*/

			empty_init();
		}

		template <class Iterator>
		list(Iterator first, Iterator last)
		{
			empty_init();

			while (first != last)
			{
				push_back(*first);
				++first;
			}
		}
	private:
		node* _head;
};

2.2 析构函数

析构函数需要释放所有结点以及头结点,在释放前需要判断当前链表是否为空,如果为空直接置空头节点

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

void clear()
{
	iterator it = begin();
	while (it != end())
	{
		//it = erase(it);
		erase(it++);
	}
}

三、operator=的重载和拷贝构造

3.1 operator=的重载

对于赋值重载,与拷贝构造相似,但是赋值重载在传递参数时使用传值传参,这样就自动帮我们构造了一个临时对象,我们只需要swap一下临时对象的头节点即可,将我们现在的链表交给临时对象销毁,这样就完成了赋值。有时可能需要连等,所以需要返回对象的引用。

//lt1=lt3
list<T>& operator=(list<T> lt)
{
	swap(lt);
	return *this;
}

3.2 拷贝构造

拷贝构造最好采用现代写法,构造临时对象使用swap交换,在此之前,因为是构造函数所以需要创造头结点,调用empty_init()函数,再进行拷贝

//lt2(lt1) 拷贝构造传统写法
/*list(const list<T>& lt)
{
	empty_init();
	for (auto e : lt)
	{
		push_back(e);
	}
}*/

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

//现代写法
list(const list<T>& lt)
{
	empty_init();

	list<T> tmp(lt.begin(), lt.end());
	swap(tmp);
}

四、迭代器的实现

4.1 迭代器类中的各种操作

const类型的对象只能使用const类型的迭代器,那么const类型的迭代器如何实现呢、需要再重新封装吗,像上面那样。可以,但是没有必要,因为那样代码的冗余度就会很高,我们只需要给模板增加两个参数就可以了。即template<class T,class Ref,class Ptr>
在这里插入图片描述

//1、迭代器要么就是原生指针
//2、迭代器要么就是自定义类型对原生指针的封装,模拟指针的行为
template<class T,class Ref,class Ptr>
struct __list_iterator
{
	typedef list_node<T> node;
	typedef __list_iterator<T,Ref,Ptr> self;
	node* _node;

	__list_iterator(node* n)
		:_node(n)
	{}

	Ref& operator*()
	{
		return _node->_data;
	}

	Ptr operator->()    //it->_a1  it->->_a1  本来应该是两个->,但是为了增强可读性,省略了一个->
	{
		return &_node->_data;
	}

	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& s)
	{
		return _node != s._node;
	}

	bool operator==(const self& s)
	{
		return _node == s._node;
	}
};

4.1 list类中的迭代器

	template<class T>
	class list
	{
		typedef list_node<T> node;
	public:
		typedef __list_iterator<T,T&,T*> iterator;
		typedef __list_iterator<T,const T&,const T*> const_iterator;

		//typedef __list_const_iterator<T> const_iterator;

		iterator begin()
		{
			//iterator it(_head->_next);
			//return it;
			return iterator(_head->_next);
		}

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

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

		const_iterator end() const
		{
			//iterator it(_head);
			//return it;
			return const_iterator(_head);
		}

五、list的增容和删除

5.1 尾插尾删

尾插结点需要修改_head和tail的连接关系,链入新节点
1.根据参数创建一个新节点new_node
2.记录原尾结点tail
3.修改_head和tail之间的链接关系,再其中链入new_node
在这里插入图片描述

直接复用insert即可

void push_back(const T& x=T())
{
	/*node* tail = _head->_prev;
	node* new_node = new node(x);

	tail->_next = new_node;
	new_node->_prev = tail;
	new_node->_next = _head;
	_head->_prev = new_node;*/

	insert(end(), x);
}

直接复用erase即可

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

5.2 头插头删

直接复用insert即可

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

直接复用erase即可

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

5.3 任意位置的插入和删除

任意位置插入是在pos迭代器位置前插入一个结点,并返回这个结点的迭代器!
1.检查pos迭代器中结点但是否正常
2.获取pos位置的当前结点pos._node,获取pos位置的前驱结点cur->_prev
3.根据参数申请一个新节点new_node
4.将新节点new_node链入pos结点与pos前驱结点之间
5.链入成功后返回新插入结点的迭代器

在这里插入图片描述

iterator insert(iterator pos, const T& x)
{
	assert(pos._node);
	node* cur = pos._node;
	node* prev = cur->_prev;

	node* new_node = new node(x);

	prev->_next = new_node;
	new_node->_prev = prev;
	new_node->_next = cur;
	cur->_prev = new_node;

	return iterator(new_node);
}

在这里插入图片描述
任意位置删除时删除pos迭代器位置的结点,并返回删除结点的下一个结点的迭代器
1.检查链表是否为空且pos迭代器中结点是否正常
2.获取pos结点的前驱结点pos._node->_prev
3.获取pos结点的后继结点pos._node->_next
4.链接pos._node->_prev和pos._node->_next结点,剥离pos结点
5.删除pos结点
6.返回pos._node->_next结点的迭代器(即pos的下一个结点的迭代器)

iterator erase(iterator pos)
{
	assert(pos != end());
	node* prev = pos._node->_prev;
	node* next = pos._node->_next;

	prev->_next = next;
	next->_prev = prev;
	delete pos._node;

	return iterator(next);
}

六、完整代码

6.1 list.h

#pragma once
#include<assert.h>

namespace zl
{
	template<class T>
	struct list_node
	{
		list_node<T>* _next;
		list_node<T>* _prev;
		T _data;

		list_node(const T& x=T())
			:_next(nullptr)
			,_prev(nullptr)
			,_data(x)
		{}
	};

	//1、迭代器要么就是原生指针
	//2、迭代器要么就是自定义类型对原生指针的封装,模拟指针的行为
	template<class T,class Ref,class Ptr>
	struct __list_iterator
	{
		typedef list_node<T> node;
		typedef __list_iterator<T,Ref,Ptr> self;
		node* _node;

		__list_iterator(node* n)
			:_node(n)
		{}

		Ref& operator*()
		{
			return _node->_data;
		}

		Ptr operator->()    //it->_a1  it->->_a1  本来应该是两个->,但是为了增强可读性,省略了一个->
		{
			return &_node->_data;
		}

		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& s)
		{
			return _node != s._node;
		}

		bool operator==(const self& s)
		{
			return _node == s._node;
		}
	};


	/*template<class T>
	struct __list_const_iterator
	{
		typedef list_node<T> node;
		typedef __list_const_iterator<T> self;
		node* _node;

		__list_const_iterator(node* n)
			:_node(n)
		{}

		const T& operator*()
		{
			return _node->_data;
		}

		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& s)
		{
			return _node != s._node;
		}

		bool operator==(const self& s)
		{
			return _node == s._node;
		}
	};*/
	

	template<class T>
	class list
	{
		typedef list_node<T> node;
	public:
		typedef __list_iterator<T,T&,T*> iterator;
		typedef __list_iterator<T,const T&,const T*> const_iterator;

		//typedef __list_const_iterator<T> const_iterator;

		iterator begin()
		{
			//iterator it(_head->_next);
			//return it;
			return iterator(_head->_next);
		}

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

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

		const_iterator end() const
		{
			//iterator it(_head);
			//return it;
			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();
		}

		template <class Iterator>
		list(Iterator first, Iterator last)
		{
			empty_init();

			while (first != last)
			{
				push_back(*first);
				++first;
			}
		}

		//lt2(lt1) 拷贝构造传统写法
		/*list(const list<T>& lt)
		{
			empty_init();
			for (auto e : lt)
			{
				push_back(e);
			}
		}*/

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

		//现代写法
		list(const list<T>& lt)
		{
			empty_init();

			list<T> tmp(lt.begin(), lt.end());
			swap(tmp);
		}

		//lt1=lt3
		list<T>& operator=(list<T> lt)
		{
			swap(lt);
			return *this;
		}

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

		void clear()
		{
			iterator it = begin();
			while (it != end())
			{
				//it = erase(it);
				erase(it++);
			}
		}

		void push_back(const T& x=T())
		{
			/*node* tail = _head->_prev;
			node* new_node = new node(x);

			tail->_next = new_node;
			new_node->_prev = tail;
			new_node->_next = _head;
			_head->_prev = new_node;*/

			insert(end(), x);
		}

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

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

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

		void insert(iterator pos, const T& x)
		{
			node* cur = pos._node;
			node* prev = cur->_prev;

			node* new_node = new node(x);

			prev->_next = new_node;
			new_node->_prev = prev;
			new_node->_next = cur;
			cur->_prev = new_node;
		}

		iterator erase(iterator pos)
		{
			assert(pos != end());
			node* prev = pos._node->_prev;
			node* next = pos._node->_next;

			prev->_next = next;
			next->_prev = prev;
			delete pos._node;

			return iterator(next);
		}

	private:
		node* _head;
	};

	void print_list(const list<int>& lt)
	{
		list<int>::const_iterator it = lt.begin();
		while (it != lt.end())
		{
			//(*it) *= 2;
			cout << *it << " ";
			++it;
		}
		cout << endl;
	}

	void test_list1()
	{
		list<int> lt;
		lt.push_back(1);
		lt.push_back(2);
		lt.push_back(3);
		lt.push_back(4);

		list<int>::iterator it = lt.begin();
		while (it != lt.end())
		{
			cout << *it << " ";
			++it;
		}
		cout << endl;

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

		print_list(lt);
	}


	struct AA
	{
		int _a1;
		int _a2;

		AA(int a1=0,int a2=0)
			:_a1(a1)
			,_a2(a2)
		{}
	};

	void test_list2()
	{
		list<AA> lt;
		lt.push_back(AA(1, 1));
		lt.push_back(AA(2, 2));
		lt.push_back(AA(3, 3));

		//AA* ptr
		list<AA>::iterator it = lt.begin();
		while (it != lt.end())
		{
			//cout << (*it)._a1 << (*it)._a2 << endl;
			cout << it->_a1 << it->_a2 << endl;
			//cout << it.operator->()->_a1 << ":" << it.operator->()->_a1 << endl;
			++it;
		}
		cout << endl;
	}


	void test_list3()
	{
		list<int> lt;
		lt.push_back(1);
		lt.push_back(2);
		lt.push_back(3);
		lt.push_back(4);

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

		auto pos = lt.begin();
		++pos;
		lt.insert(pos, 20);

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

		lt.push_back(100);
		lt.push_front(1000);

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

		lt.pop_back();
		lt.pop_front();

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

	void test_list4()
	{
		list<int> lt;
		lt.push_back(1);
		lt.push_back(2);
		lt.push_back(3);
		lt.push_back(4);

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

		lt.clear();

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

		lt.push_back(10);
		lt.push_back(20);
		lt.push_back(30);
		lt.push_back(40);

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

	void test_list5()
	{
		list<int> lt;
		lt.push_back(1);
		lt.push_back(2);
		lt.push_back(3);
		lt.push_back(4);

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

		list<int> lt2(lt);

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

		list<int> lt3;
		lt3.push_back(10);
		lt3.push_back(20);
		lt3.push_back(30);
		lt3.push_back(40);
		lt3.push_back(50);

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

		lt = lt3;

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

6.2 test.cpp

#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<vector>
#include<list>
using namespace std;
#include "list.h"


int main()
{
	//zl::test_list1();
	//zl::test_list2();
	//zl::test_list3();
	//zl::test_list4();
	zl::test_list5();


	//std::vector<int>::iterator it;
	//cout << typeid(it).name() << endl;

	return 0;
}

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

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

爬虫工作量由小到大的思维转变---<第十一章 Scrapy之sqlalchemy模版和改造(番外)>

前言: 正常的pymysql当然问题不大,但是我个人还是建议:sqlalchemy! 因为他更能让我们把精力放在表单设计上,而不执着于代码本身了. (-----版权所有。未经作者书面同意&#xff0c;不得转载或用于任何商业用途!----) 正文: 先提供一个基础模版: 表图: 创建表的sql: CREA…

软件设计师——法律法规(三)

&#x1f4d1;前言 本文主要是【法律法规】——软件设计师——法律法规的文章&#xff0c;如果有什么需要改进的地方还请大佬指出⛺️ &#x1f3ac;作者简介&#xff1a;大家好&#xff0c;我是听风与他&#x1f947; ☁️博客首页&#xff1a;CSDN主页听风与他 &#x1f304…

《科技风》期刊发表投稿方式、收稿方向

《科技风》杂志是经国家新闻出版总署批准&#xff0c;河北省科学技术协会主管&#xff0c;河北省科技咨询服务中心主办的国内公开发行的大型综合类科技期刊。 该刊集科技性、前瞻性、创新性和专业性于一体&#xff0c;始终以“把脉科技创新 引领发展风尚”为办刊宗旨&#xff…

ES-脚本

脚本 简单使用 POST product/_update/2 {"script": {"source": "ctx._source.salary1" #将薪水字段的值 1} }预定义变量 POST product/_update/2 {"script": {"lang": "painless","source": "…

Android studio中文汉化教程

相比于jetbrains的软件直接在软件内搜索chinese 就可以找到中文包相比&#xff0c;Android studio需要手动安装&#xff0c;接下来就给大家介绍下如何汉化 一、确认版本号 根据版本下载对应的中文汉化包&#xff0c;如果安装的汉化包版本不对应&#xff0c;可能会导致安装失败。…

升华 RabbitMQ:解锁一致性哈希交换机的奥秘【RabbitMQ 十】

欢迎来到我的博客&#xff0c;代码的世界里&#xff0c;每一行都是一个故事 升华 RabbitMQ&#xff1a;解锁一致性哈希交换机的奥秘【RabbitMQ 十】 前言第一&#xff1a;该插件需求为什么需要一种更智能的消息路由方式&#xff1f;一致性哈希的基本概念&#xff1a; 第二&…

大华 DSS 数字监控系统 itcBulletin SQL 注入漏洞复现

0x01 产品简介 大华 DSS 数字监控系统是大华开发的一款安防视频监控系统,拥有实时监视、云台操作、录像回放、报警处理、设备管理等功能。 0x02 漏洞概述 大华 DSS存在SQL注入漏洞,攻击者 /portal/services/itcBulletin 路由发送特殊构造的数据包,利用报错注入获取数据库…

WPF-UI HandyControl 控件简单实战

文章目录 前言UserControl简单使用新建项目直接新建项目初始化UserControlGeometry:矢量图形额外Icon导入最优解决方案 按钮Button切换按钮ToggleButton默认按钮图片可切换按钮加载按钮切换按钮 单选按钮和复选按钮没有太大特点&#xff0c;就不展开写了总结 DataGrid数据表格G…

【机器学习】044_Kaggle房价预测(机器学习模型实战)

参考自《动手学深度学习》中“Kaggle比赛实战&#xff1a;预测房价”一节 一、数据准备 首先从网站上下载要获取的房价数据。 DATA_HUB是一个字典&#xff0c;用来将数据集名称的字符串和数据集相关的二元组一一对应。 二元组包含两个值&#xff1a;数据集的URL和用来验证文…

基于linux系统的Tomcat+Mysql+Jdk环境搭建(二)jdk1.8 linux 上传到MobaXterm 工具的已有session里

【JDK安装】 1.首先下载一个JDK版本 官网地址&#xff1a;http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html 下载1.8版本&#xff0c;用红框标注出来了&#xff1a; 也许有的同学看到没有1.8版本&#xff0c;你可以随便下载一个linux的…

本地运行大语言模型并可视化(Ollama+big-AGI方案)

目前有两种方案支持本地部署&#xff0c;两种方案都是基于llamacpp。其中 Ollama 目前只支持 Mac&#xff0c;LM Studio目前支持 Mac 和 Windows。 LM Studio&#xff1a;https://lmstudio.ai/ Ollama&#xff1a;https://ollama.ai/download 本文以 Ollama 为例 step1 首先下…

限流常用算法以及基于Sentinel的微服务限流及熔断

一、服务限流的作用及实现 在没有任何保护机制的情况下&#xff0c;如果所有的流量都进入服务器&#xff0c;很可能造成服务器宕机导致整个系统不可用&#xff0c;从而造成巨大的损失。为了保证系统在这些场景中仍然能够稳定运行&#xff0c;就需要采取一定的系统保护策略&…

智能优化算法应用:基于天牛须算法3D无线传感器网络(WSN)覆盖优化 - 附代码

智能优化算法应用&#xff1a;基于天牛须算法3D无线传感器网络(WSN)覆盖优化 - 附代码 文章目录 智能优化算法应用&#xff1a;基于天牛须算法3D无线传感器网络(WSN)覆盖优化 - 附代码1.无线传感网络节点模型2.覆盖数学模型及分析3.天牛须算法4.实验参数设定5.算法结果6.参考文…

Ubuntu 常用命令之 ls 命令用法介绍

Ubuntu ls 命令用法介绍 ls是Linux系统下的一个基本命令&#xff0c;用于列出目录中的文件和子目录。它有许多选项可以用来改变列出的内容和格式。 以下是一些基本的ls命令选项 -l&#xff1a;以长格式列出文件&#xff0c;包括文件类型、权限、链接数、所有者、组、大小、最…

Java 第10、11章 本章作业

目录 6 综合编程题7 成员内部类应用8 枚举类 & switch 6 综合编程题 3. 交通工具工厂类&#xff1a;由于在任务中只需要调用其中获得交通工具的方法&#xff0c;可以将方法定义为静态方法&#xff0c;这样就不用先创建工厂类的对象&#xff0c;直接“类名.方法” 即可。为了…

基于Java SSM框架实现疫情居家办公OA系统项目【项目源码+论文说明】

基于java的SSM框架实现疫情居家办公OA系统演示 摘要 21世纪的今天&#xff0c;随着社会的不断发展与进步&#xff0c;人们对于信息科学化的认识&#xff0c;已由低层次向高层次发展&#xff0c;由原来的感性认识向理性认识提高&#xff0c;管理工作的重要性已逐渐被人们所认识…

3.1 内容管理模块 - 工程搭建、课程查询、配置Swagger、数据字典

文章目录 内容管理模块一、基础工程搭建1.1 需求分析1.2 业务流程1.3 数据模型1.4 创建模块工程1.4.1 介绍1.4.2 xuecheng-plus-content 聚合工程1.4.3 模块演示 二、课程查询准备2.1 需求分析2.1.1 业务流程2.1.2 数据模型 2.2 生成PO类2.2.1 新增Maven配置2.2.2 课程基本信息…

文档安全加固:零容忍盗窃,如何有效预防重要信息外泄

文档安全保护不仅需要从源头着手&#xff0c;杜绝文档在使用和传播过程中产生的泄密风险&#xff0c;同时还需要对文档内容本身进行有效的保护。为了防范通过拷贝、截屏、拍照等手段盗窃重要文档内容信息的风险&#xff0c;迅软DSE加密软件提供了文档加密保护功能&#xff0c;能…

用23种设计模式打造一个cocos creator的游戏框架----(十八)责任链模式

1、模式标准 模式名称&#xff1a;责任链模式 模式分类&#xff1a;行为型 模式意图&#xff1a;使多个对象都有机会处理请求&#xff0c;从而避免请求的发送者和接收者之间的耦合关系。将这些对象连成一条链&#xff0c;并沿着这条链传递该请求&#xff0c;直到有一个对象处…

MLX:苹果 专为统一内存架构(UMA) 设计的机器学习框架

“晨兴理荒秽&#xff0c;带月荷锄归” 夜深闻讯&#xff0c;有点兴奋&#xff5e; 苹果为 UMA 设计的深度学习框架真的来了 统一内存架构 得益于 CPU 与 GPU 内存的共享&#xff0c;同时与 MacOS 和 M 芯片 交相辉映&#xff0c;在效率上&#xff0c;实现对其他框架的降维打…
最新文章