当前位置: 首页 > news >正文

了解Java集合的概念和体系:Collection<T>、Collections与Stream的使用

学习目标

本文知识是对集合层级的介绍,应用开发中实际使用的是他们的子级,感兴趣的小伙伴或者想深入了解有关Java集合知识的朋友可以选择阅读!

Stream的方法使用使用部分代码块内大多有两种实现方式,是为了更好的理解方法底层的代码,不必过于深究,可以看懂链式应用的方法即可

  1. 核心掌握集合层级
  2. 了解Collection
  3. 了解Collections
  4. 了解Stream

1.集合概念

● 集合和数组一样也是容器,但是只能放对象
● 集合和数组相比,数组长度是固定的(一旦确定之后不能改动) 集合长度不限
● 数组中数组元素要求数据类型一致;集合中可以放任意的对象(只能是对象 ,只不过对象类型不要求一致)
● 集合中不能放基本数据类型,只能放对象
● 集合中有比较多的数据结构 可供选择

2.集合体系

在这里插入图片描述

3.集合分类

● 有2大类的集合: 存储的数据特征。
● 1、Collection接口: 数据只能是单值(一个个的数据) 每次存储一个元素/数据
● 问题: 元素是否可重复? 元素是否有序(索引位置)?
List: 元素有序可重复
Set: 元素无序且唯一

● 2、Map<K,V> 接口 : 数据必须是一组元素(2个数据) 有key–value
● key: 必须唯一
● value: 可以重复

4.Collection<T>

● java.util.Collection
● 表示集合层次的根接口。
● 存储单值元素。

4.1 层级

public interface Collection<E> extends Iterable<E>{}

4.2 常用方法

在这里插入图片描述

4.3 使用方法

  • 无泛型
public static void collectionMethod() {Collection arrayList = new ArrayList();Collection arrayList2 = new ArrayList();arrayList2.add(66);arrayList2.add(99);// 自动装箱  1 int-->IntegerarrayList.add(10);String a = "abc";arrayList.add(99);System.out.println("添加是否成功:" + arrayList.add(a));System.out.println("集合是否为空,没有集合元素:" + arrayList.isEmpty());// Integer是不可变的 ,一旦改值 那就是新的对象System.out.println("移除Integer是否成功:" + arrayList.remove(2));// remove进行移除的时候,看集合中是否包含这个对象 如果有那么移除成功
//        System.out.println("移除stringBuilder是否成功:" + arrayList.remove(stringBuilder));System.out.println("集合中的元素个数:" + arrayList.size());String b = "abc";System.out.println("集合中是否包含某个元素:" + arrayList.contains(b));// 一次性 添加多个元素进来  //arrayList.addAll(arrayList2);System.out.println("addAll:" + arrayList);// arrayList.removeAll(arrayList2);// 只要元素和arrayList2相等 就删除System.out.println("removeAll:" + arrayList); //System.out.println("containsAll 全部包含: " + arrayList.containsAll(arrayList2));//移除所有元素arrayList.clear();}
  • 有泛型
private static void demo1() {//1.创建集合对象Collection collection = new ArrayList();//2.操作//2.1 新增collection.add("hello");collection.add("hello");collection.add(100);collection.add(true);collection.add(10.123);collection.add(null);collection.add(new UserInfo("张三"));//2.2 查看集合元素个数System.out.println(collection.size());//2.3 删除collection.remove("hello");collection.remove("hello");/* collection.removeIf(new Predicate() {@Overridepublic boolean test(Object obj) {return "hello".equals(obj);}});*///collection.removeIf("hello"::equals);//collection.clear();//2.4判断System.out.println(collection.contains(1000));System.out.println(collection.isEmpty());System.out.println(collection.size()==0);System.out.println(collection.size());System.out.println(collection.toString());//}

4.4 遍历集合

  • 集合迭代器常用方法
    在这里插入图片描述
private static void demo2() {Collection<Integer> collection = new ArrayList<>();//java.util.Collections工具类  操作集合元素静态方法  ArraysCollections.addAll(collection, 10, 20, 30, 1, 5);//遍历集合元素的方式: 其实就1种遍历集合的方式(迭代器)// 2. 增强for// 增强for遍历数组: class文件里面还是普通for循环// 增强for遍历集合: class文件里面使用的iterator遍历集合元素的for (Integer num : collection) {System.out.println("num:"+num);}// 3. Iterator<E> iterator()  获得集合的迭代器对象//3.1 获得集合的迭代器对象Iterator<Integer> iterator = collection.iterator();//集合的数据都在iterator里面了//3.2 判断光标之后是否有数据while (iterator.hasNext()){//3.3 获得光标之后的数据Integer num = iterator.next();System.out.println("num:"+num);}// 4. default void forEach(Consumer<? super T> action)   遍历集合元素  jdk1.8+/*collection.forEach(new Consumer<Integer>() {@Overridepublic void accept(Integer num) {System.out.println(num);}});*/collection.forEach(System.out::println);System.out.println(collection);}

4.5 集合转数组

private static void demo3() {Collection<Integer> collection = new ArrayList<>();collection.add(100);//装箱collection.add(200);collection.add(300);//集合转数组----> 数组操作比较复杂//3. default <T> T[] toArray(IntFunction<T[]> generator);//第3个方法  与第2个方法的思想一致的。 length=0Integer[] integers = collection.toArray(new IntFunction<Integer[]>() {@Overridepublic Integer[] apply(int value) {//0System.out.println("value:" + value);return new Integer[value];}});Integer[] integers = collection.toArray(Integer[]::new);System.out.println("integers:"+Arrays.toString(integers));//2. <T> T[] toArray(T[] a);  建议使用  核心:数组Integer[] numArray = new Integer[0];//2.1 length==collection.size() 保证数组里面存储size个元素//2.2 length>collection.size() 问题: 数组的空间比较大的 null----> 功能实现  有可能会出现NPE//2.3 length<collection.size() 可以转换成功//站在并发/性能/扩容: 建议指定的数组的length=0Integer[] toArray = collection.toArray(numArray);System.out.println("numArray:" + Arrays.toString(numArray));System.out.println("toArray:" + Arrays.toString(toArray));System.out.println(numArray == toArray);Object[] array = collection.toArray();//1. 不要使用Object[] toArray() 不管集合里面存储什么类型的数据  都要转成一个Object[]for (Object obj : array) {Integer num = (Integer) obj;System.out.println(num + 100);}System.out.println(Arrays.toString(array));
}

4.6 匿名内部类

● 在任意一个类和接口都能创建匿名内部类,相当于定义了一个 没有名字的新的类。
● 等价于创建了一个类的子类,以及接口的实现类。

  • 创建接口
public interface MyInterface {void method1();
}
  • 创建匿名内部类
public static void main(String[] args) {// 匿名内部类  抽象类 和接口都能使用test(new MyInterface() {@Overridepublic void method1() {System.out.println("method111===");}});//等价于接口的实类对象
}public static void test(MyInterface myInter) {myInter.method1();
}
public static void test1(){Object obj =  new Object(){//等价于类的匿名内部类---->类的子类}
}

提醒(可以先看这部分)

● 虽然我们讲解了集合的根接口Collection以及相关的方法。
● 但是在开发中一般不用父接口,用的还是子级,List或者Set
● 我们只需要知道Collection里面维护的都是List以及Set集合都有的方法即可。

5.Collections的使用

● 工具类。在java.util包。
● 类似于之前学的Arrays。
● Collections操作集合(Collection->List/Set)元素的工具类

  • 常用方法
private static void demo1() {//1.Collections.addAll(Collection,T...data); 将多个数据新增到指定的集合对象中List<Integer> list = new ArrayList<>(10);//list.add(10);Collections.addAll(list, 10, 10, 1, 3, 4, 50, 24, 100);Set<Integer> set = new HashSet<>(16);Collections.addAll(set, 10, 10, 1, 3, 4, 50, 24, 100);List<Integer> list1 = List.of(1, 2, 3);//只能读数据Set<Integer> set1 = Set.of(1, 2, 3, 4, 5);Map<Integer, Integer> map = Map.of(1, 1, 2, 2, 3, 3, 4, 4);//数组转集合List<Integer> list2 = Arrays.asList(1, 2, 3);
}
  • 常用的静态常量
private static List<?> demo3() {//获得一个空集合对象  等价于size=0System.out.println(Collections.EMPTY_LIST);//[]System.out.println(Collections.EMPTY_MAP);//{}System.out.println(Collections.EMPTY_SET);//[]System.out.println(Collections.emptySet());System.out.println(Collections.emptyMap());System.out.println(Collections.emptyList());//前提: 方法的返回值是特定的集合类型//在功能里面 可以作为返回值使用  判断的时候避免出现NPEreturn Collections.EMPTY_LIST;}
private static void demo2() {//2.将线程不安全的集合对象转换成线程安全的集合对象  可以在并发的环境下  作为全局变量使用Collections.synchronizedList(new ArraysList());  VectorCollections.synchronizedSet(new HashSet())Collections.synchronizedMap(new HashMap())  ConcurrentHashMap//以下2个方法 只针对于TreeMap与TreeSetCollections.synchronizedSortedMap(new TreeMap())Collections.synchronizedSortedSet(new TreeSet())}
  • sort
private static void demo4() {//Collections.sort(List); 要求集合元素类型必须实现Comparable//Collections.sort(List,Comparator);//如果真的是对list集合排序,一般我们只会使用List.sort()List<Integer> list = new ArrayList<>(10);Collections.addAll(list, 10, 10, 1, 3, 4, 50, 24, 100);Collections.sort(list);System.out.println(list);System.out.println("-----------------------");List<UserInfo> userInfoList = new ArrayList<>(10);Collections.addAll(userInfoList,new UserInfo(1, "jim", 20),new UserInfo(2, "tom", 18),new UserInfo(3, "lilei", 23),new UserInfo(4, "hanmeimei", 16));//Collections.sort(userInfoList, Comparator.comparing(UserInfo::getAge));userInfoList.sort(Comparator.comparing(UserInfo::getAge).reversed());userInfoList.forEach(System.out::println);}
  • 获得集合的最值
private static void demo5() {TreeSet<Integer> set = new TreeSet<>();Collections.addAll(set, 10, 10, 1, 3, 4, 50, 24, 100);System.out.println(set);//[1, 50, 3, 4, 100, 24, 10]//获得Set集合的最值//1.TreeSetSystem.out.println(set.first());System.out.println(set.last());System.out.println("------------------------------------");Set<Integer> hashSet = new HashSet<>(16);Collections.addAll(hashSet, 10, 10, 1, 3, 4, 50, 24, 100);//Collections.sort(List); 只能对list集合排序  不能对set集合排序//5. 最值Collections.max(Collection);  集合元素类型必须实现ComparableCollections.max(Collection,Comparator);Collections.min(Collection);Collections.min(Collection,Comparator);Integer max = Collections.max(hashSet);Integer min = Collections.min(hashSet);System.out.println(max);System.out.println(min);}
  • shuffle
 private static void demo6() {// Collections.shuffle(List); 随机(随机数)打乱集合元素顺序。 洗牌。List<Integer> list = new ArrayList<>(10);Collections.addAll(list, 10, 1, 3, 4, 50, 24);System.out.println(list);Collections.shuffle(list);System.out.println(list);
}

6.Stream

● 丰富了对Collection(List,Set)的操作
● 可以看成是一个增强版的迭代器。数据源不限,可以是多个数据源(Collection集合对象)
中间操作 属于 惰性操作 只有碰到终止操作才会执行
○ 凡是返回值是Stream类型的都是中间操作
○ filter:对流中数据进行过滤:返回值为
true表示留下的数据
false表示过滤掉的
○ map: 把流中的每个数据经过相同的操作 映射为新的数据
○ sorted:对流中数据排序
○ limit :只保留指定个数的元素
○ peek:表示查看 流中元素
终止操作
○ 只要返回值不是Stream类型的
○ count:得到流中元素个数
○ reduce:合并 合并为一个数据
○ collect:流数据的收集
● Stream对象流是一次性的,只能被操作一次,不能重复操作
● 终止操作只能出现一次,在最后出现

6.1 获得Stream

private static void demo1() {//获得Stream的方式//1. 根据集合对象操作。Collection.stream()/paraStream()List<Integer> list = Arrays.asList(1, 2, 3, 4);Stream<Integer> stream = list.stream();//串行化流  集合的数据都在Stream里面Stream<Integer> stream1 = list.parallelStream();//并行化流Iterator<Integer> iterator = list.iterator();//2. 使用Stream接口里面的静态方法Stream.concat(Stream,Stream);Stream<Integer> stream2 = Stream.of(1, 2, 3);//3.Arrays.stream()//IntStream  LongStream  DoubleStream//避免过多拆箱和装箱  提供了操作基本数据类型数据的StreamIntStream stream2 = Arrays.stream(new int[]{1, 2, 3});//4.Random.ints()//随机数Random//获得10个随机的数字。  0 200随机的数据Random random = new Random();int num = random.nextInt(200);IntStream intStream = random.ints(10, 100, 200);String str = "hello";IntStream intStream1 = str.chars();}

6.2 操作Stream

  1. Stream Stream.distinct() ; 去重
  2. Stream Stream.sorted() ; 排序
  3. Stream Stream.sorted(Comparator<? super T> comparator) ; 根据外部比较器排序规则排序
  4. Stream Stream skip(long n); 跳过数据源里面指定数量的数据
  5. Optional Stream.max(Comparator<? super T> comparator) ; 获得最值
  6. Optional Stream.min(Comparator<? super T> comparator) ;
  7. Stream.limit(long maxSize) ; 对数据源的数量限定
  8. Stream.forEach(Consumer<? super T> action) 循环遍历
  9. Stream.count(); 统计Stream里面的元素个数
  10. Stream.findAny() ; 查询任意一个数据
  11. Stream.findFirst() ;
  12. collect(Collector<? super T,A,R> collector) //收集操作之后的数据 存储到一个新的集合对象中

1.distinct/sort

private static void demo2() {List<Integer> list = Arrays.asList(1, 2, 3, 4, 20, 2, 1, 3);//对list集合元素进行去重/排序(降序)//1.获得Stream对象Stream<Integer> stream = list.parallelStream();//2.操作StreamStream<Integer> stream1 = stream.distinct();Stream<Integer> stream2 = stream1.sorted(Comparator.reverseOrder());//3.获得操作之后满足条件的一些数据  存储到一个新的集合中---->收集起来  终止StreamList<Integer> resultList = stream2.collect(Collectors.toList());System.out.println(resultList);*///Stream就是一次性的。//查询Stream里面还有多少个数据  终止Stream之后  无法再对Stream的数据进行相关的处理//操作Stream: 一般都是方法链的方式List<Integer> list1 = list.parallelStream().distinct().sorted(Comparator.reverseOrder()).collect(Collectors.toList());System.out.println(list1);
}

2.allMatch/anyMatch

private static void demo3() {List<String> list = List.of("hellom", "jiy", "toc");//判断list集合的每个元素是否都包含指定的 m这个数据for (int index = 0; index < list.size(); index++) {String str = list.get(index);if(str==null) break;if(!str.contains("m")){System.out.println(false);return;}}System.out.println(true);System.out.println("----------------------------");boolean flag = list.parallelStream().allMatch(new Predicate<String>() {@Overridepublic boolean test(String s) {return s.contains("m");}});boolean flag = list.stream().anyMatch(str -> str.contains("m"));System.out.println(flag);
}

3.filter

Stream filter(Predicate<? super T> predicate) ;//过滤Stream中不满足条件的数据

private static void demo4() {List<String> list = List.of("zhangsan", "jim", "tom","lisi");//获得list集合中: 过滤下来元素里面包含m的数据List<String> nameList = new ArrayList<>(10);for (String name : list) {if(name.contains("m")){nameList.add(name);}}System.out.println("----------------------------");List<String> stringList = list.parallelStream().filter(name -> name.contains("m")).collect(Collectors.toList());System.out.println(stringList);
}

4.findFirst/findAny/min

private static void demo5() {List<UserInfo> userInfoList = new ArrayList<>(10);Collections.addAll(userInfoList,new UserInfo(1, "jim", 20),new UserInfo(2, "tom", 18),new UserInfo(3, "lilei", 23),new UserInfo(4, "hanmeimei", 16));//获得年龄>=20的用户List<UserInfo> collect = userInfoList.stream().filter(userInfo -> userInfo.getAge() >= 20).collect(Collectors.toList());//使用lambda表达式collect.forEach(System.out::println);//获得userInfoList年龄最小的用户对象//1.正常编写userInfoList.sort(Comparator.comparing(UserInfo::getAge));UserInfo userInfo = userInfoList.get(0);System.out.println(userInfo);System.out.println("-------------------");userInfoList.forEach(System.out::println);//或用Collections.min()//2.StreamOptional<UserInfo> first = userInfoList.stream().sorted(Comparator.comparing(UserInfo::getAge)).findFirst();System.out.println(first);System.out.println("-------------------");userInfoList.forEach(System.out::println);System.out.println("----------------------------");UserInfo userInfo = userInfoList.parallelStream().findAny().orElse(null);System.out.println(userInfo);
}

5.map/peek

场景: Stream里面的每个元素都要执行一样的功能的时候 。
//将stream里面的每个数据转换成另外一个类型的数据。

private static void demo6() {List<UserInfo> userInfoList = new ArrayList<>(10);Collections.addAll(userInfoList,new UserInfo(1, "jim", 20),new UserInfo(2, "tom", 18),new UserInfo(3, "lilei", 23),new UserInfo(4, "hanmeimei", 16));//将集合里面每个用户的name的数据全部转换成大写字母for (UserInfo userInfo : userInfoList) {userInfo.setName(userInfo.getName().toUpperCase());}//获得集合里面每个用户对象的name的属性数据  全部转大写字母存储List<String> collect = userInfoList.parallelStream().map(new Function<UserInfo, String>() {@Overridepublic String apply(UserInfo userInfo) {return userInfo.getName().toUpperCase();}}).collect(Collectors.toList());List<String> collect = userInfoList.parallelStream().map(userInfo -> userInfo.getName().toUpperCase()).collect(Collectors.toList());collect.forEach(System.out::println);System.out.println("-----------------------------");userInfoList.forEach(System.out::println);}
private static void demo7() {List<UserInfo> userInfoList = new ArrayList<>(10);Collections.addAll(userInfoList,new UserInfo(1, "jim", 20),new UserInfo(2, "tom", 18),new UserInfo(3, "lilei", 23),new UserInfo(4, "hanmeimei", 16));List<UserInfo> collect = userInfoList.stream().map(new Function<UserInfo, UserInfo>() {@Overridepublic UserInfo apply(UserInfo userInfo) {userInfo.setName(userInfo.getName().toUpperCase());return userInfo;}}).collect(Collectors.toList());/* List<UserInfo> collect = userInfoList.stream().map(userInfo -> {userInfo.setName(userInfo.getName().toUpperCase());return userInfo;}).collect(Collectors.toList());*///前提: 对Stream的元素都执行同样的功能 最后集合里面的元素类型与原集合数据类型一致  建议使用peek替换mapList<UserInfo> collect = userInfoList.parallelStream().peek(userInfo -> userInfo.setName(userInfo.getName().toUpperCase())).collect(Collectors.toList());System.out.println(collect);System.out.println(userInfoList);
}

6.flatMap

private static void demo8() {List<Integer> list1 = List.of(1, 2, 30, 4, 5);List<Integer> list2 = List.of(10, 27, 3, 40, 5);List<Integer> list3 = List.of(11, 2, 3, 4, 5);List<Integer> list4 = List.of(100, 21, 3, 4, 50);//获得前5个数据(降序)+去重//核心: 将多个集合数据转换到一个集合中.List<Integer> collect = Stream.of(list1, list2, list3, list4).flatMap(List::stream).distinct().sorted(Comparator.reverseOrder()).limit(5).collect(Collectors.toList());System.out.println(collect);/*Stream.of(list1, list2, list3, list4).flatMapToInt(new Function<List<Integer>, IntStream>() {@Overridepublic IntStream apply(List<Integer> list) {return list.stream().mapToInt(Integer::intValue);}})*/Stream.of(list1, list2, list3, list4).flatMapToInt(list -> list.stream().mapToInt(Integer::intValue)).distinct().sorted().limit(5).forEach(System.out::println);}

7.reduce

private static void demo9() {List<Integer> list = List.of(89, 90, 98);int sum = 0;for (Integer integer : list) {sum+=integer;}Integer sum1 = list.stream().reduce(new BinaryOperator<Integer>() {@Overridepublic Integer apply(Integer num1, Integer num2) {//System.out.println(num1+":"+num2);return num1 + num2;}}).orElse(null);Integer sum1 = list.stream().reduce(Integer::max).orElse(null);System.out.println(sum1);
}

相关文章:

了解Java集合的概念和体系:Collection<T>、Collections与Stream的使用

学习目标 本文知识是对集合层级的介绍&#xff0c;应用开发中实际使用的是他们的子级&#xff0c;感兴趣的小伙伴或者想深入了解有关Java集合知识的朋友可以选择阅读&#xff01; Stream的方法使用使用部分代码块内大多有两种实现方式&#xff0c;是为了更好的理解方法底层的代…...

扫描局域网可用端口

site: https://mengplus.top #SiliconFlow : 在Linux系统&#xff0c;你可以使用一个简单的Bash脚本来扫描局域网中可用的端口。这个脚本可以使用nmap工具来实现。nmap是一个强大的网络扫描工具&#xff0c;可以用来探测网络中的主机和端口。 以下是一个简单的Bash脚本&#…...

算法分析 —— 《栈》

文章目录 删除字符串中的所有相邻重复项题目描述&#xff1a;代码实现&#xff1a;代码解析&#xff1a; 比较含退格的字符串题目描述&#xff1a;代码实现&#xff1a;代码解析&#xff1a; [基本计算器 II](https://leetcode.cn/problems/remove-all-adjacent-duplicates-in-…...

693. 交替位二进制数

交替位二进制数 题目描述尝试做法推荐做法 题目描述 给定一个正整数&#xff0c;检查它的二进制表示是否总是 0、1 交替出现&#xff1a;换句话说&#xff0c;就是二进制表示中相邻两位的数字永不相同。 示例 1&#xff1a; 输入&#xff1a;n 5 输出&#xff1a;true 解释…...

uniapp中使用leaferui使用Canvas绘制复杂异形表格的实现方法

需求&#xff1a; 如下图&#xff0c;要实现左图的样式&#xff0c;先实现框架&#xff0c;文字到时候 往里填就行了&#xff0c;原来的解决方案是想用css,html来实现&#xff0c;发现实现起来蛮麻烦的。我也没找到合适的实现方法&#xff0c;最后换使用canvas来实现&#xff…...

Java 反射(Reflection)的原理和应用

反射&#xff08;Reflection&#xff09;是 Java 语言的一项强大功能&#xff0c;它允许程序在运行时动态地获取类的信息&#xff0c;并且可以操作这些信息&#xff0c;如创建对象、调用方法、访问字段等。反射机制的核心在于 Java 的 类加载机制 和 动态类型检查&#xff0c;使…...

Linux top 常用参数记录

top命令经常用来监控linux的系统状况&#xff0c;能实时显示系统中各个进程、线程的资源占用情况&#xff0c;是常用的性能分析工具。 一些常用参数记录 top的使用方式 top [-d number] | top [-bnp] # 5s 更新一次 top -d 5# 进行2次top命令的输出结果 top -n 2# 查看进程的…...

hive之LEAD 函数详解

1. 函数概述 LEAD 是 Hive 中的窗口函数&#xff0c;用于获取当前行之后指定偏移量处的行的值。常用于分析时间序列数据、计算相邻记录的差异或预测趋势。 2. 语法 LEAD(column, offset, default) OVER ([PARTITION BY partition_column] [ORDER BY order_column [ASC|DESC]…...

Element Plus中el-tree点击的节点字体变色加粗

el-tree标签设置 <el-tree class"tree":data"treeData":default-expand-all"true":highlight-current"true"node-click"onTreeNodeClick"><!-- 自定义节点内容&#xff0c;点击的节点字体变色加粗 --><!-- 动…...

.gitignore 设置后不见效的解决方法中,方案一就可以了

遇到的问题&#xff1a;你的 .gitignore 文件中包含了 unpackage/ 目录&#xff0c;但它不起作用的原因可能有以下几个&#xff1a; 1. 文件或目录已经被 Git 跟踪 .gitignore 只能忽略 未被 Git 追踪 的文件或目录。如果 unpackage/ 目录已经被提交到 Git 版本库中&#xff…...

git提交管理

git提交管理 scoop install nodejs # windows npm install --save-dev commitlint/config-conventional commitlint/cli # non-windows npm install --save-dev commitlint/{cli,config-conventional} # windows将commitlint.config.js修改为utf8编码, 默认utf16编码 echo &qu…...

DeepSeek八大组合软件,效率加倍

DeepSeek王炸组合&#xff1a;开启2025年高效工作与创意新时代 在科技飞速发展的2025年&#xff0c;人工智能和各类工具的融合正不断重塑我们的工作与生活方式。DeepSeek作为一款强大的工具&#xff0c;与众多应用组成的王炸组合&#xff0c;展现出了令人瞩目的能力。今天&…...

TCP和UDP比较

以下是 TCP&#xff08;传输控制协议&#xff09; 和 UDP&#xff08;用户数据报协议&#xff09; 的详细对比&#xff0c;涵盖核心特性、应用场景及技术差异&#xff1a; 1. 核心特性对比 特性TCPUDP连接方式面向连接&#xff08;需三次握手建立连接&#xff09;无连接&#…...

【实战篇】【深度解析DeepSeek:从机器学习到深度学习的全场景落地指南】

一、机器学习模型:DeepSeek的降维打击 1.1 监督学习与无监督学习的"左右互搏" 监督学习就像学霸刷题——给标注数据(参考答案)训练模型。DeepSeek在信贷风控场景中,用逻辑回归模型分析百万级用户数据,通过特征工程挖掘出"凌晨3点频繁申请贷款"这类魔…...

Postgresql高可用之Pacemaker+Corosync

简介 Pacemaker 是 ClusterLabs 开源高可用性集群堆栈的资源管理器。它协调配置、启动、监控和跨所有集群节点恢复相互关联的服务。在这套高可用架构用会用到Pacemaker、Corosync以下是对其功能作用的说明。 Corosync &#xff1a;主要负责 集群通信和成员管理&#xff0c;它用…...

智能成绩表

智能成绩表 真题目录: 点击去查看 E 卷 100分题型 题目描述 小明来到学校当老师,需要将学生按考试总分或单科分数进行排名,你能帮帮他吗? 输入描述 第 1 行输入两个整数,学生人数 n 和科目数量 m。 0 < n < 1000 < m < 10第 2 行输入 m 个科目名称,彼此之…...

制作安装win10系统U盘详细步骤

https://www.microsoft.com/zh-cn/software-download/windows10 ①微软官方链接&#xff0c;下载工具 ②下载之后&#xff0c;点击鼠标右键用管理员身份运行 ③等待几分钟 ④出现许可条款点击接受 ⑤点击为另一台电脑安装介质&#xff0c;然后下一步 ⑥根据需要选择版本。 体系…...

【RAG】Embeding 和 Rerank学习笔记

Q: 现在主流Embeding模型架构 在RAG&#xff08;Retrieval-Augmented Generation&#xff09;系统中&#xff0c;嵌入模型&#xff08;Embedding Model&#xff09; 是检索阶段的核心组件&#xff0c;负责将查询&#xff08;Query&#xff09;和文档&#xff08;Document&#…...

华为 Open Gauss 数据库在 Spring Boot 中使用 Flyway

db-migration&#xff1a;Flyway、Liquibase 扩展支持达梦&#xff08;DM&#xff09;、南大通用&#xff08;GBase 8s&#xff09;、OpenGauss 等国产数据库。部分数据库直接支持 Flowable 工作流。 开源代码仓库 Github&#xff1a;https://github.com/mengweijin/db-migrat…...

B/B+树与mysql索引

数据结构操作网站&#xff1a;https://www.cs.usfca.edu/~galles/visualization/Algorithms.html B树 算法平均最差空间O(n)O(n)搜索O(log n)O(log n)插入O(log n)O(log n)删除O(log n)O(log n) B树 算法平均最差空间O(n)O(n)搜索O(log n)O(log n)插入O(log n)O(log n)删除O(…...

心智模式与企业瓶颈突破

“是环境限制了你&#xff0c;还是你的心智模式&#xff1f;” 当企业发展遇到瓶颈&#xff0c;我们习惯于找外部原因&#xff1a;经济不好、竞争加剧、资源不够、市场环境变化快 可现实是&#xff0c;在同样的市场环境下&#xff0c;总有企业逆势增长&#xff0c;而有些企业只…...

介绍微信小程序中页面的生命周期函数和组件的生命周期函数

1.1 页面生命周期函数 这些函数主要用于管理页面的显示和隐藏。 onLoad(options): 页面加载时触发&#xff0c;options 是页面路由参数&#xff0c;可以在这里初始化数据。每当用户进入该页面时都会调用这个函数。 onShow(): 页面显示时触发。每当页面从后台切换到前台时都会…...

网络运维学习笔记(DeepSeek优化版)009网工初级(HCIA-Datacom与CCNA-EI)路由理论基础与静态路由

文章目录 路由理论基础核心概念路由表六要素路由选路原则加表规则选路优先级 协议与参数常见协议号路由协议优先级对比 网络架构基础AS&#xff08;autonomous system&#xff0c;自治系统&#xff09;路由分类 静态路由(static routing)实验拓扑思科配置示例华为配置示例 典型…...

基于微信小程序的疫情互助平台(源码+lw+部署文档+讲解),源码可白嫖!

摘要 时代在飞速进步&#xff0c;每个行业都在努力发展现在先进技术&#xff0c;通过这些先进的技术来提高自己的水平和优势&#xff0c;从2019年底新型冠状肺炎疫情的爆发以来&#xff0c;使很多工作的管理工作难度再上一层楼。为了在疫情期间能更好的维护信息管理&#xff0…...

【SRC实战】小游戏漏洞强制挑战

小游戏业务分析: 1、挑战成功加分&#xff0c;失败减分&#xff0c;存在段位机制&#xff0c;段位影响榜单排名 2、随机推荐挑战对象&#xff0c;随着等级升高不再推荐低等级玩家 3、玩家等级需要培养&#xff0c;培养需要道具&#xff0c;道具需要看广告/完成任务/付费 4、…...

阿里云轻量级服务器通过宝塔安装PgVector要点

设置环境变量&#xff1a; export PG_HOME/www/server/pgsql export LD_LIBRARY_PATH$LD_LIBRARY_PATH:/www/server/pgsql/lib export PG_CONFIG/www/server/pgsql/bin/pg_config export PGDATA/www/server/pgsql/data PATH$PATH:$HOME/.local/bin:$HOME/bin:$PG_HOME/bin ali…...

安装 Windows Docker Desktop - WSL问题

一、关联文章: 1、Docker Desktop 安装使用教程 2、家庭版 Windows 安装 Docker 没有 Hyper-V 问题 3、打开 Windows Docker Desktop 出现 Docker Engine Stopped 问题 二、问题解析 打开 Docker Desktop 出现问题,如下: Docker Desktop - WSL update failed An error o…...

基于SpringBoot和PostGIS的省域“地理难抵点(最纵深处)”检索及可视化实践

目录 前言 1、研究背景 2、研究意义 一、研究目标 1、“地理难抵点”的概念 二、“难抵点”空间检索实现 1、数据获取与处理 2、计算流程 3、难抵点计算 4、WebGIS可视化 三、成果展示 1、华东地区 2、华南地区 3、华中地区 4、华北地区 5、西北地区 6、西南地…...

神经网络之RNN和LSTM(基于pytorch-api)

1.RNN 1.1简介 RNN用于处理序列数据。在传统的神经网络模型中&#xff0c;是从输入层到隐含层再到输出层&#xff0c;层与层之间是全连接的&#xff0c;每层之间的节点是无连接的。但是这种普通的神经网络对于很多问题却无能无力。例如&#xff0c;你要预测句子的下一个单词是…...

16.3 LangChain Runnable 协议精要:构建高效大模型应用的核心基石

LangChain Runnable 协议精要:构建高效大模型应用的核心基石 关键词:LCEL Runnable 协议、LangChain 链式开发、自定义组件集成、流式处理优化、生产级应用设计 1. Runnable 协议设计哲学与核心接口 1.1 协议定义与类结构 #mermaid-svg-PlmvpSDrEUrUGv2p {font-family:&quo…...

[操作系统] 文件的软链接和硬链接

文章目录 引言硬链接&#xff08;Hard Link&#xff09;什么是硬链接&#xff1f;硬链接的特性硬链接的用途 软链接&#xff08;Symbolic Link&#xff09;什么是软链接&#xff1f;软链接的特性软链接的用途 软硬链接对比文件的时间戳实际应用示例使用硬链接节省备份空间用软链…...

【Python · PyTorch】循环神经网络 RNN(基础应用)

【Python PyTorch】循环神经网络 RNN&#xff08;简单应用&#xff09; 1. 简介2. 模拟客流预测&#xff08;数据集转化Tensor&#xff09;3.1 数据集介绍3.2 训练过程 3. 模拟股票预测&#xff08;DataLoader加载数据集&#xff09;3.1 IBM 数据集3.1.2 数据集介绍3.1.3 训练…...

Spring Boot 项目开发流程全解析

目录 引言 一、开发环境准备 二、创建项目 三、项目结构 四、开发业务逻辑 1.创建实体类&#xff1a; 2.创建数据访问层&#xff08;DAO&#xff09;&#xff1a; 3.创建服务层&#xff08;Service&#xff09;&#xff1a; 4.创建控制器层&#xff08;Controller&…...

基于互联网协议的诊断通信(DoIP)

1、ISO 13400标准和其他汽车网络协议标准有何不同&#xff1f; ISO 13400 标准即 DoIP 协议标准&#xff0c;与其他常见汽车网络协议标准&#xff08;如 CAN、LIN、FlexRay 等&#xff09;有以下不同&#xff1a; 通信基础与适用场景 ISO 13400&#xff1a;基于互联网协议&a…...

MacDroid for Mac v2.3 安卓手机文件传输助手 支持M、Intel芯片 4.7K

MacDroid 是Mac毒搜集到的一款安卓手机文件传输助手&#xff0c;在Mac和Android设备之间传输文件。您只需要将安卓手机使用 USB 连接到 Mac 电脑上即可将安卓设备挂载为本地磁盘&#xff0c;就像编辑mac磁盘上的文件一样编辑安卓设备上的文件&#xff0c;MacDroid支持所有 Andr…...

Skywalking介绍,Skywalking 9.4 安装,SpringBoot集成Skywalking

一.Skywalking介绍 Apache SkyWalking是一个开源的分布式追踪与性能监视平台&#xff0c;特别适用于微服务架构、云原生环境以及基于容器&#xff08;如Docker、Kubernetes&#xff09;的应用部署。该项目由吴晟发起&#xff0c;并已加入Apache软件基金会的孵化器&#xff0c;…...

基于POI的Excel下拉框自动搜索,包括数据验证的单列删除

目录 目标 例子 1.搜索下拉框页 2.数据源页 3.效果 代码以及注意事项 1.代码 2.注意事项 1.基于Excel的话&#xff0c;相当于加入了一个【数据验证】 2.代码中的一些方法说明 目标 期望在Excel利用代码创建具备自动搜索功能的下拉框 例子 1.搜索下拉框页 2.数据源…...

std::allocator_traits 能做但 std::allocator 不能的事情

&#x1f31f; std::allocator_traits 能做但 std::allocator 不能的事情 1️⃣ 适配自定义分配器 假设你要实现一个内存池 MyAllocator&#xff0c;而 STL 容器默认使用的是 std::allocator。 如果你希望 STL 容器可以使用你的 MyAllocator&#xff0c;你 不能直接用 std::a…...

深度解析Ant Design Pro 6开发实践

深度解析Ant Design Pro 6全栈开发实践&#xff1a;从架构设计到企业级应用落地 一、Ant Design Pro 6核心特性与生态定位&#xff08;技术架构分析&#xff09; 作为Ant Design生态体系的旗舰级企业应用中台框架&#xff0c;Ant Design Pro 6基于以下技术栈实现突破性升级&am…...

flutter 局部刷新控件Selector源码实现原理

Flutter 中的 Selector 组件是 provider 包提供的一个优化工具&#xff0c;用于在状态管理中仅选择所需数据片段&#xff0c;避免不必要的 Widget 重建。其实现原理基于以下几个关键点&#xff1a; 1. 核心设计目标 选择性重建&#xff1a;仅当特定数据变化时触发 Widget 重建&…...

Hadoop之01:HDFS分布式文件系统

HDFS分布式文件系统 1.目标 理解分布式思想学会使用HDFS的常用命令掌握如何使用java api操作HDFS能独立描述HDFS三大组件namenode、secondarynamenode、datanode的作用理解并独立描述HDFS读写流程HDFS如何解决大量小文件存储问题 2. HDFS 2.1 HDFS是什么 HDFS是Hadoop中的一…...

vite+react+ts如何集成redux状态管理工具,实现持久化缓存

1.安装插件 这里的redux-persist--进行数据的持久化缓存&#xff0c;确保页面刷新数据不会丢失 yarn add react-redux^9.2.0 redux-persist^6.0.0 reduxjs/toolkit^2.5.1 2.创建仓库文件夹 在项目的src文件夹下创建名为store的文件夹&#xff0c;里面的具体文件如下 featur…...

文字的力量

不知道以前的时代的年轻人有没有这样的感受。现在我觉得自己是不是出现了认知偏差&#xff0c;发现在很多描写现在的二十几岁年轻人的成长经历的文字下面都会出现很多共鸣&#xff0c;包括我自己也有&#xff0c;就让我有一个错觉:是不是中国所有的和我同龄的年轻人都是这样过来…...

网络空间安全(4)web应用程序安全要点

前言 Web应用程序安全是确保Web应用程序、服务和服务器免受网络攻击和威胁的关键环节。 一、编写安全的代码 输入验证与过滤&#xff1a;确保所有的用户输入都被正确验证和过滤&#xff0c;以防止注入攻击等安全漏洞。开发者应对URL、查询关键字、HTTP头、POST数据等进行严格的…...

openwebUI访问vllm加载deepseek微调过的本地大模型

文章目录 前言一、openwebui安装二、配置openwebui环境三、安装vllm四、启动vllm五、启动openwebui 前言 首先安装vllm&#xff0c;然后加载本地模型&#xff0c;会起一个端口好。 在安装openwebui,去访问这个端口号。下面具体步骤的演示。 一、openwebui安装 rootautodl-co…...

安全测试之五:SQL Server注入漏洞几个实例

示例 1&#xff1a;在 GET 请求中测试 SQL 注入 最简单且有时最有效的情况是针对登录页面进行测试。当登录页面请求用户输入用户名和密码时&#xff0c;攻击者可以尝试输入以下字符串 “ or 11”&#xff08;不包含双引号&#xff09;&#xff1a; https://vulnerable.web.ap…...

计算机毕业设计SpringBoot+Vue.js线上辅导班系统(源码+文档+PPT+讲解)

温馨提示&#xff1a;文末有 CSDN 平台官方提供的学长联系方式的名片&#xff01; 温馨提示&#xff1a;文末有 CSDN 平台官方提供的学长联系方式的名片&#xff01; 温馨提示&#xff1a;文末有 CSDN 平台官方提供的学长联系方式的名片&#xff01; 作者简介&#xff1a;Java领…...

C#委托(delegate)的常用方式

C# 中委托的常用方式&#xff0c;包括委托的定义、实例化、不同的赋值方式以及匿名委托的使用。 委托的定义 // 委托的核心是跟委托的函数结构一样 public delegate string SayHello(string c);public delegate string SayHello(string c);&#xff1a;定义了一个公共委托类型 …...

《白帽子讲 Web 安全》之移动 Web 安全

目录 摘要 一、WebView 简介 二、WebView 对外暴露 WebView 对外暴露的接口风险 三、通用型 XSS - Universal XSS 介绍 四、WebView 跨域访问 五、与本地代码交互 js 5.1接口暴露风险&#xff1a; 5.2漏洞利用&#xff1a; 5.3JavaScript 与 Native 代码通信 六、Chr…...

【Tourism】Yongzhou

永州市&#xff08;英文&#xff1a;Yongzhou city、Yungchow city&#xff09;是湖南省辖地级市&#xff0c;简称“永”&#xff0c;别称“零陵”或“潇湘”。位于湖南南部&#xff0c;潇、湘二水汇合处&#xff0c;地势三面环山、地貌复杂多样。截至2022年10月&#xff0c;永…...