List集合的Stream流式操作實現數據類型轉換

目錄

問題現象:

?問題分析:

解決方法:

拓展:

????????1、Collectors.toList()

????????2、Collectors.toCollection(ArrayList::new)

? ? ? ? 3、Collectors.toCollection(LinkedList::new)

? ? ? ? 4、Collectors.toCollection(LinkedHashSet::new)

? ? ? ? 5、Collectors.toCollection(HashSet::new)

? ? ? ? 6、Collectors.toCollection(TreeSet::new)

? ? ? ? 7、Collectors.partitioningBy

? ? ? ? 8、【重點】Collectors.groupingBy

? ? ? ? 9、Collectors.collectingAndThen

? ? ? ? 10、map

? ? ? ? 11、【重點】Collectors.toMap

? ? ? ? 11.1、Collectors.toMap(key, value)

????????11.2、【重點】Collectors.toMap(key, value, distinctStrategy)

????????11.3、【重點】Collectors.toMap(key, value, distinctStrategy, returnTypeSupplier)

測試代碼:

???????1、StreamStringListTransformTest 測試類:

????????2、Person實體類:

????????3、StreamObjectListTransformTest 測試類:


問題現象:

? ? ? ? 最近在項目中,有一些邏輯想用List集合的Stream流式操作來快速實現,但由于之前沒做好學習筆記和總結,導致一時間想不起來,只能用本方法來解決,如下:

? ? ? ? 可以看出來代碼量是比較冗長的,于是就回顧了一下List集合的Stream流式操作的相關知識點;打算打一個代碼優化!


?問題分析:

? ? ? ? 由上圖可以知道,我是想將集合list(List<Map<String, Object>> list?)根據元素(Map<String, Object> map)中的key為"infoType"的字段值來作相關的業務邏輯,形成指定的集合(如:List<Map<String,?Object>>?baseInfoList等),然后再存到map集合(Map<String,?Object>?exportParams)中去。

? ? ? ? 根據這個思路其實就可以使用集合list中的Stream流式操作中的Collectors.groupingBy方法來解決了:
? ? ? ? 1、首先對集合list中使用Stream流式操作中的Collectors.groupingBy進行分組(分組依據是元素中的key:"infoType"),形成infoTypeListMap集合(Map<String,?List<Map<String,?Object>>>?infoTypeListMap)。

? ? ? ? 2、遍歷infoTypeListMap集合,然后將元素存入exportParams集合。


解決方法:

? ? ? ? 將上圖的代碼做如下修改即可:

        exportParams.put(StrUtil.toCamelCase(StaffInfoTypeEnum.BASE_INFO.getCode() + "_LIST"), new ArrayList<>());exportParams.put(StrUtil.toCamelCase(StaffInfoTypeEnum.EDUCATION_INFO.getCode() + "_LIST"), new ArrayList<>());exportParams.put(StrUtil.toCamelCase(StaffInfoTypeEnum.TRAIN_INFO.getCode() + "_LIST"), new ArrayList<>());exportParams.put(StrUtil.toCamelCase(StaffInfoTypeEnum.WORK_EXPERIENCE_INFO.getCode() + "_LIST"), new ArrayList<>());exportParams.put(StrUtil.toCamelCase(StaffInfoTypeEnum.SALARY_INFO.getCode() + "_LIST"), new ArrayList<>());exportParams.put(StrUtil.toCamelCase(StaffInfoTypeEnum.FAMILY_CONTACT_INFO.getCode() + "_LIST"), new ArrayList<>());exportParams.put(StrUtil.toCamelCase(StaffInfoTypeEnum.LANGUAGE_INFO.getCode() + "_LIST"), new ArrayList<>());Map<String, List<Map<String, Object>>> infoTypeListMap = list.stream().collect(Collectors.groupingBy(map -> (String)map.get("infoType")));infoTypeListMap.entrySet().stream().forEach(entry->{String key = entry.getKey();List<Map<String, Object>> mapList = entry.getValue();exportParams.put(StrUtil.toCamelCase(key+"_LIST"), mapList);});

拓展:

? ? ? ? 文末有我寫的測試代碼,有助于理解,可直接搬運使用!

????????相信小伙伴們都見識到List集合的Stream流式操作的強大了吧,接下來,我就把List集合的Stream流式操作實現數據類型轉換的常用方法記錄并分享在此,以供自己和大家學習記憶。

????????1、Collectors.toList()

list.stream().collect(Collectors.toList());

? ? ? ? 作用:可用于克隆/拷貝原list集合。作用相當于以下代碼:

new ArrayList<>(list);

????????2、Collectors.toCollection(ArrayList::new)

list.stream().collect(Collectors.toCollection(ArrayList::new));

? ? ? ? 作用:List<Object> 轉為 ArrayList<Object>?。作用相當于以下代碼:

new ArrayList<>(list);

? ? ? ? 3、Collectors.toCollection(LinkedList::new)

list.stream().collect(Collectors.toCollection(LinkedList::new));

????????作用:List<Object> 轉為 LinkedList<Object>?。作用相當于以下代碼:

new LinkedList<>(list);

? ? ? ? 4、Collectors.toCollection(LinkedHashSet::new)

list.stream().collect(Collectors.toCollection(LinkedHashSet::new));

????????作用:List<Object> 轉為 LinkedHashSet<Object>。作用相當于以下代碼:

new LinkedHashSet<>(list);

? ? ? ? 5、Collectors.toCollection(HashSet::new)

list.stream().collect(Collectors.toCollection(HashSet::new));

????????作用:List<Object> 轉為 HashSet<Object>?。作用相當于以下代碼:

new HashSet<>(list);

? ? ? ? 6、Collectors.toCollection(TreeSet::new)

list.stream().collect(Collectors.toCollection(TreeSet::new));

????????作用:List<Object> 轉為 TreeSet<Object>。作用相當于以下代碼:

new TreeSet<>(list);

? ? ? ? 7、Collectors.partitioningBy

list.stream().collect(Collectors.partitioningBy(s -> s.length() > 2));

????????作用:List<Object> 轉為 Map<Boolean, List<Object>>。

? ? ? ? 8、【重點】Collectors.groupingBy

list.stream().collect(Collectors.groupingBy(s -> s));

????????作用:List<Object> 轉為 Map<Object, List<Object>>。

? ? ? ? 9、Collectors.collectingAndThen

list.stream().collect(Collectors.groupingBy(s -> s));

????????作用:根據指定條件,將集合中所有元素形成的指定類型的結果集合后,再將結果集合做指定的結果集。如:List<Object> 轉為 Map<Object, List<Object>> 再轉為 Set<String>返回,如下:

list.stream().collect(Collectors.collectingAndThen(Collectors.groupingBy(s -> s), Map::keySet));

? ? ? ? 10、map

list.stream().collect(Collectors.groupingBy(s -> s));

????????作用:根據指定條件,提取集合中所有元素的指定屬性/字段,形成新的類型(指定屬性/字段的數據類型)集合。如:List<Object> 轉為 List<Integer>

list.stream().map(String::length).collect(Collectors.toList());

? ? ? ? 11、【重點】Collectors.toMap

????????作用:List<Object> 轉為 Map<Object, Object>

? ? ? ? 具有3個重載方法

? ? ? ? 11.1、Collectors.toMap(key, value)

list.stream().collect(Collectors.toMap(str -> str, String::length));

? ? ? ??作用:根據指定條件,提取集合中所有元素的指定屬性/字段,形成新的類型(指定屬性/字段的數據類型)集合。

? ? ? ? 參數說明:

????????????????key:指定元素對象的某個屬性作為map結果集合的key值。

????????????????value:指定元素對象的某個屬性作為map結果集合的value值。

????????缺點:當元素中存在重復的key時,會有如下報錯:Duplicate key XX。

????????11.2、【重點】Collectors.toMap(key, value, distinctStrategy)

list.stream().collect(Collectors.toMap(String::length, str -> str, (length, str) -> str));

? ? ? ??作用:在11.1功能一致,多了一個第三參數,該參數用于配置當出現重復key時,對這些元素的value的操作處理邏輯,可以避免key重復報錯問題。

? ? ? ? 參數說明:

????????????????distinctStrategy:去重邏輯,當遇到重復key時觸發該邏輯。

????????11.3、【重點】Collectors.toMap(key, value, distinctStrategy, returnTypeSupplier)

list.stream().collect(Collectors.toMap(String::length, str -> str, (length, str) -> str, TreeMap::new));

? ? ? ? 參數說明:

?????????returnTypeSupplier:指定map結果集合的數據類型,通過查詢源代碼可知:當未指定該參數時,默認返回的是HashMap數據類型;如下:


測試代碼:

???????1、StreamStringListTransformTest 測試類:

? ? ? ? 測試List<String>集合的Stream流式操作,實現數據類型轉換的功能:

import java.util.*;
import java.util.stream.Collectors;/*** Stream流的各種數據類型轉換操作*/
public class StreamStringListTransformTest {public static void main(String[] args) {//List<String>集合原數據List<String> list = Arrays.asList("java", "python", "C#","php");//1、Collectors.toList()// List<String>克隆(代替流)List<String> listResult = list.stream().collect(Collectors.toList());listResult.forEach(System.out::println);System.out.println("--------------");//2、Collectors.toCollection(ArrayList::new)// List<String> 轉為 ArrayList<String>ArrayList<String> arrayList = list.stream().collect(Collectors.toCollection(ArrayList::new));arrayList.forEach(System.out::println);System.out.println("--------------");//3、Collectors.toCollection(LinkedList::new)// List<String> 轉為 LinkedList<String>List<String> linkedList = list.stream().collect(Collectors.toCollection(LinkedList::new));linkedList.forEach(System.out::println);System.out.println("--------------");//4、Collectors.toCollection(LinkedHashSet::new)// List<String> 轉為 LinkedHashSet<String>LinkedHashSet<String> linkedHashSet = list.stream().collect(Collectors.toCollection(LinkedHashSet::new));linkedHashSet.forEach(System.out::println);//LinkedHashSet是有序的System.out.println("--------------");//5、Collectors.toCollection(HashSet::new)// List<String> 轉為 HashSet<String>HashSet<String> hashSet = list.stream().collect(Collectors.toCollection(HashSet::new));hashSet.forEach(System.out::println);//HashSet是無序的(按hash邏輯自動排序)System.out.println("--------------");//6、Collectors.toCollection(TreeSet::new)// List<String> 轉為 TreeSet<String>TreeSet<String> treeSet = list.stream().collect(Collectors.toCollection(TreeSet::new));treeSet.forEach(System.out::println);//TreeSet是按自然順序自動排序System.out.println("--------------");//7、Collectors.partitioningBy:根據指定條件,將集合中所有元素分成key為true或false的兩組集合,形成的map集合// List<String> 轉為 Map<Boolean, List<String>>Map<Boolean, List<String>> partitioningByMap = list.stream().collect(Collectors.partitioningBy(s -> s.length() > 2));System.out.println(partitioningByMap.toString());System.out.println("--------------");//8、Collectors.groupingBy:根據指定條件,將集合中所有元素分成key為元素本身的集合,形成的map集合//List<String> 轉為 Map<String, List<String>>Map<String, List<String>> groupingByMap = list.stream().collect(Collectors.groupingBy(s -> s));System.out.println(groupingByMap.toString());System.out.println("--------------");//9、Collectors.collectingAndThen:根據指定條件,將集合中所有元素形成的指定類型的結果集合后,再將結果集合做指定的結果集//List<String> 轉為 Map<String, List<String>> 再轉為 Set<String>Set<String> collectingAndThen = list.stream().collect(Collectors.collectingAndThen(Collectors.groupingBy(s -> s), Map::keySet));System.out.println(collectingAndThen.toString());System.out.println("--------------");//10、map:根據指定條件,提取集合中所有元素的指定屬性,形成新的指定集合//List<String> 轉為 List<Integer>List<Integer> lengthList = list.stream().map(String::length).collect(Collectors.toList());System.out.println(lengthList.toString());System.out.println("--------------");//11、Collectors.toMap:根據指定條件,提取集合中所有元素的指定屬性,組合成自定義類型的map結果集合//List<String> 轉為 Map<Integer, String>//List<String> 轉為 Map<String, Integer>//注意:該函數有3個重載方法://      11.1、2個參數(key,value)://          第一個參數(元素對象的某個指定屬性)作為key。//          第二個參數作為value。(缺點:當存在key重復的不同元素時,會有類似以下報錯:Duplicate key 王五)//      11.2、3個參數(key,value,distinctStrategy)://          第一個參數(元素對象的某個指定屬性)作為key;//          第二個參數作為value;//          第三個參數用于配置當出現重復key時,對這些元素的value的操作處理邏輯,可以避免上面的key重復報錯問題。//      11.2、3個參數(key,value,distinctStrategy,returnTypeSupplier)://          第一個參數(元素對象的某個指定屬性)作為key;//          第二個參數作為value;//          第三個參數用于配置當出現重復key時,對這些元素的value的操作處理邏輯,可以避免上面的key重復報錯問題。//          第四個參數用于設置返回map的數據類型(如:TreeMap、ConcurrentHashMap等),默認是返回HashMap。List<String> strList = Arrays.asList("java", "python", "C#","php", "java");//List<String> 轉為 Map<Integer, String>
//		Map<Integer, String> strList1 = strList.stream().collect(Collectors.toMap(String::length, str -> str));//報錯:Duplicate key java
//		System.out.println(strList1.toString());
//		System.out.println("--------------");//List<String> 轉為 Map<String, Integer>
//		Map<String, Integer> strList2 = strList.stream().collect(Collectors.toMap(str -> str, String::length));//報錯:Duplicate key 4
//		System.out.println(strList2.toString());
//		System.out.println("--------------");//List<String> 轉為 Map<String, Integer>Map<String, Integer> strList3 = strList.stream().collect(Collectors.toMap(str -> str, String::length, (first, second) -> second));System.out.println(strList3.toString());System.out.println("--------------");Map<String, Integer> list1 = list.stream().collect(Collectors.toMap(str -> str, String::length));System.out.println(list1.toString());System.out.println("--------------");//List<String> 轉為 Map<String, Integer>Map<Integer, String> list2 = list.stream().collect(Collectors.toMap(String::length, str -> str));System.out.println(list2.toString());System.out.println("--------------");//List<String> 轉為 Map<String, Integer>Map<Integer, String> list3 = list.stream().collect(Collectors.toMap(String::length, str -> str, (length, str) -> str));System.out.println(list3.toString());System.out.println("--------------");//List<String> 轉為 TreeMap<String, Integer>TreeMap<Integer, String> list4 = list.stream().collect(Collectors.toMap(String::length, str -> str, (length, str) -> str, TreeMap::new));System.out.println(list4.toString());System.out.println("--------------");}
}

????????2、Person實體類:

? ? ? ? 用于支持的測試:

public class Person {private String name;private Integer age;public Person() {}public Person(String name, Integer age) {this.name = name;this.age = age;}public String getName() {return name;}public void setName(String name) {this.name = name;}public Integer getAge() {return age;}public void setAge(Integer age) {this.age = age;}@Overridepublic String toString() {return "Person{" + "name='" + name + '\'' + ", age=" + age + '}';}
}

3、StreamObjectListTransformTest 測試類:

? ? ? ? 測試List<Object>集合的Stream流式操作,實現數據類型轉換的功能:

import xxx.Person;//導入Person實體類import java.util.*;
import java.util.stream.Collectors;/*** Stream流的各種數據類型轉換操作*/
public class StreamObjectListTransformTest {public static void main(String[] args) {//List<Object>集合原數據List<Person> list = new ArrayList<>();list.add(new Person("老六", 20));list.add(new Person("王五", 20));list.add(new Person("李四", 19));list.add(new Person("張三", 18));list.add(new Person("錢二", 17));list.add(new Person("趙一", 16));//1、Collectors.toList()// List<Object>克隆(代替流)List<Person> listResult = list.stream().collect(Collectors.toList());listResult.forEach(System.out::println);System.out.println("--------------");//2、Collectors.toCollection(ArrayList::new)// List<Object> 轉為 ArrayList<Object>ArrayList<Person> arrayList = list.stream().collect(Collectors.toCollection(ArrayList::new));arrayList.forEach(System.out::println);System.out.println("--------------");//3、Collectors.toCollection(LinkedList::new)// List<Object> 轉為 LinkedList<Object>List<Person> linkedList = list.stream().collect(Collectors.toCollection(LinkedList::new));linkedList.forEach(System.out::println);System.out.println("--------------");//4、Collectors.toCollection(LinkedHashSet::new)// List<Object> 轉為 LinkedHashSet<Object>LinkedHashSet<Person> linkedHashSet = list.stream().collect(Collectors.toCollection(LinkedHashSet::new));linkedHashSet.forEach(System.out::println);//LinkedHashSet是有序的System.out.println("--------------");//5、Collectors.toCollection(HashSet::new)// List<Object> 轉為 HashSet<Object>HashSet<Person> hashSet = list.stream().collect(Collectors.toCollection(HashSet::new));hashSet.forEach(System.out::println);//HashSet是無序的(按hash邏輯自動排序)System.out.println("--------------");//		//6、Collectors.toCollection(TreeSet::new)
//		// List<Object> 轉為 TreeSet<Object>
//		TreeSet<Person> treeSet = list.stream().collect(Collectors.toCollection(TreeSet::new));
//		treeSet.forEach(System.out::println);
//TreeSet是按單一元素自然順序自動排序,所以轉換時會有類似以下報錯:
//  com.stephen.javademo.stream.bo.Person cannot be cast to java.lang.Comparable
//		System.out.println("--------------");//7、Collectors.partitioningBy:根據指定條件,將集合中所有元素分成key為true或false的兩組集合,形成的map集合// List<Object> 轉為 Map<Boolean, List<Object>>Map<Boolean, List<Person>> partitioningByMap = list.stream().collect(Collectors.partitioningBy(person -> person.getAge() >= 18));System.out.println(partitioningByMap.toString());System.out.println("--------------");//8、Collectors.groupingBy:根據指定條件,將集合中所有元素分成key為元素本身的集合,形成的map集合//List<Object> 轉為 Map<String, List<Object>>Map<String, List<Person>> groupingByMap = list.stream().collect(Collectors.groupingBy(Person::getName));System.out.println(groupingByMap.toString());System.out.println("--------------");//9、Collectors.collectingAndThen:根據指定條件,將集合中所有元素形成的指定類型的結果集合后,再將結果集合做指定的結果集//List<Object> 轉為 Map<String, List<Object>> 再轉為 Set<String>Collection<List<Person>> collectingAndThen = list.stream().collect(Collectors.collectingAndThen(Collectors.groupingBy(Person::getName), Map::values));System.out.println(collectingAndThen.toString());System.out.println("--------------");//10、map:根據指定條件,提取集合中所有元素的指定屬性,形成新的指定集合//List<Object> 轉為 List<String>List<String> nameList = list.stream().map(Person::getName).collect(Collectors.toList());System.out.println(nameList.toString());System.out.println("--------------");//List<Object> 轉為 List<Integer>List<Integer> ageList = list.stream().map(Person::getAge).collect(Collectors.toList());System.out.println(ageList.toString());System.out.println("--------------");//List<Object> 轉為 Set<Integer>Set<Integer> ageSet = list.stream().map(Person::getAge).collect(Collectors.toSet());System.out.println(ageSet.toString());System.out.println("--------------");//11、Collectors.toMap:根據指定條件,提取集合中所有元素的指定屬性,組合成自定義類型的map結果集合//List<Object> 轉為 Map<Object, Object>//注意:該函數有3個重載方法://      11.1、2個參數(key,value)://          第一個參數(元素對象的某個指定屬性)作為key。//          第二個參數作為value。(缺點:當存在key重復的不同元素時,會有類似以下報錯:Duplicate key 王五)//      11.2、3個參數(key,value,distinctStrategy)://          第一個參數(元素對象的某個指定屬性)作為key;//          第二個參數作為value;//          第三個參數用于配置當出現重復key時,對這些元素的value的操作處理邏輯,可以避免上面的key重復報錯問題。//      11.2、3個參數(key,value,distinctStrategy,returnTypeSupplier)://          第一個參數(元素對象的某個指定屬性)作為key;//          第二個參數作為value;//          第三個參數用于配置當出現重復key時,對這些元素的value的操作處理邏輯,可以避免上面的key重復報錯問題。//          第四個參數用于設置返回map的數據類型(如:TreeMap、ConcurrentHashMap等),默認是返回HashMap。//List<Person> 轉為 Map<Integer, String>
//		Map<Integer, String> personMap1 = list.stream().collect(Collectors.toMap(Person::getAge, Person::getName));//報錯:Duplicate key 王五
//		System.out.println(personMap1.toString());
//		System.out.println("--------------");//List<Person> 轉為 Map<String, Integer>Map<String, Integer> personMap2 = list.stream().collect(Collectors.toMap(Person::getName, Person::getAge));System.out.println(personMap2.toString());System.out.println("--------------");//List<Person> 轉為 Map<String, Person>Map<String, Person> personMap3 = list.stream().collect(Collectors.toMap(Person::getName, person -> person));System.out.println(personMap3.toString());System.out.println("--------------");//List<Person> 轉為 Map<Integer, String>Map<Integer, String> personMap4 = list.stream().collect(Collectors.toMap(Person::getAge, Person::getName, (preValue, nextValue) -> nextValue));//(preValue, nextValue) -> nextValue):key重復時,取后者System.out.println(personMap4.toString());System.out.println("--------------");//List<Person> 轉為 Map<Integer, String>Map<Integer, String> personMap5 = list.stream().collect(Collectors.toMap(Person::getAge, Person::getName, (preValue, nextValue) -> preValue));//(preValue, nextValue) -> preValue):key重復時,取前者System.out.println(personMap5.toString());System.out.println("--------------");//List<Person> 轉為 Map<Integer, String>Map<Integer, String> personMap6 = list.stream().collect(Collectors.toMap(Person::getAge, Person::getName, (preValue, nextValue) -> preValue+"、"+nextValue));//(preValue, nextValue) -> preValue+"、"+nextValue):key重復時,取兩者拼接System.out.println(personMap6.toString());System.out.println("--------------");//List<Person> 轉為 TreeMap<Integer, String>TreeMap<Integer, String> personMap7 = list.stream().collect(Collectors.toMap(Person::getAge, Person::getName, (preValue, nextValue) -> preValue + "、" + nextValue, TreeMap::new));//(preValue, nextValue) -> preValue+"、"+nextValue):key重復時,取兩者拼接System.out.println(personMap7.toString());System.out.println("--------------");}
}

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/711555.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/711555.shtml
英文地址,請注明出處:http://en.pswp.cn/news/711555.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

MAC M1 安裝mongodb7.0.5 版本

1、進入官網 Download MongoDB Community Server | MongoDBDownload MongoDB Community Server non-relational database to take your next big project to a higher level!https://www.mongodb.com/try/download/community 2、選擇版本 3、下載后解壓 放到 /usr/local 并修改…

Facebook Messenger鏈接分享:如何創建鏈接并設置自動化內容

Facebook Messenger鏈接是指基于Facebook用戶名創建的會話鏈接&#xff0c;用戶可以在其Facebook頁面的設置部分復制此鏈接進行分享。然后將該鏈接直接粘貼到獨立站、電子郵件、名片或社交媒體中&#xff0c;讓目標受眾可以一鍵進入對話。為了滿足某些商家的需求&#xff0c;Fa…

vue3中的ref和reactive的區別

vue3中的ref和reactive的區別 1、響應式數據2、ref3、reactive4、ref VS reactive5、往期回顧總結&#xff1a; 1、響應式數據 處理響應式數據時到底是該用ref還是reactive... 響應式數據是指在 Vue.js 中&#xff0c;當數據發生變化時&#xff0c;相關的視圖會自動更新以反映…

【bash】2、手把手實現一個 bash shell:多個機器批量執行 shell 命令,支持 ip 補全

文章目錄 一、需求&#xff1a;多臺機器批量遠程執行 shell 命令1.1 業務需求拆解為腳本需求1.2 幫助函數&#xff1a;使用說明文檔1.3 main 函數框架 二、功能&#xff1a;單機 sshp 執行2.1 fullip 函數&#xff1a;實現 ip 補全2.1.1 參數說明2.1.2 定義全局變量2.1.3 實現&…

Cu-HCP-H035 Cu-HCP-R250銅合金高精度零部件

Cu-HCP-H035 Cu-HCP-R250銅合金高精度零部件 CDA102-3/4H EN1982-CC333G EN1982-CC492K BS1400-LG4 EN1982-CC491K BS1400-LG2 CuNi18Zn19Pb1/CW408J CuNi12Zn38Mn5Pb2/CW407J CuNi12Zn30Pb1/CW406J CuNi12Zn29/CW405J CuNi12Zn25Pb1/CW404J CuNi10Zn42Pb2/CW402J CuNi10Zn27/C…

Pytorch 復習總結 4

Pytorch 復習總結&#xff0c;僅供筆者使用&#xff0c;參考教材&#xff1a; 《動手學深度學習》Stanford University: Practical Machine Learning 本文主要內容為&#xff1a;Pytorch 深度學習計算。 本文先介紹了深度學習中自定義層和塊的方法&#xff0c;然后介紹了一些…

基于Beego 1.12.3的簡單website實現

參考 用Beego開發web應用 https://www.cnblogs.com/zhangweizhong/p/10919672.htmlBeego官網 Homepage - beego: simple & powerful Go app frameworkbuild-web-application-with-golang https://github.com/astaxie/build-web-application-with-golang/blob/master/zh/pr…

源碼的角度分析Vue2數據雙向綁定原理

什么是雙向綁定 我們先從單向綁定切入&#xff0c;其實單向綁定非常簡單&#xff0c;就是把Model綁定到View&#xff0c;當我們用JavaScript代碼更新Model時&#xff0c;View就會自動更新。那么雙向綁定就可以從此聯想到&#xff0c;即在單向綁定的基礎上&#xff0c;用戶更新…

微信開發者工具-代碼管理和碼云Github遠程倉庫集成

目錄 思考&#xff1a;IDE如何進行代碼管理 代碼管理方式 一、自身提供服務 二、Git 擴展 1、環境準備 2、創建項目代碼 3、進行項目Git初始化 4、在碼云新建遠程倉庫 5、將項目進行遠程倉庫關聯 三、SVN擴展 四、代碼管理 思考&#xff1a;IDE如何進行代碼管理 初識開…

服務器部署測試環境回顧與改進建議

任務概述&#xff1a; 原計劃在2小時內完成的任務&#xff0c;由于遇到一系列挑戰&#xff0c;最終耗時1.5天。任務目標是在無外網環境的服務器上建立測試環境&#xff0c;涉及將SSD硬盤數據遷移至服務器、SSH連接、運行測試程序并監控服務器功耗。 高效實施策略&#xff1a;…

fs讀取目錄、文件

fs讀取文件 process.cwd() 是 Node.js 中的一個方法&#xff0c;它返回 Node.js 進程的當前工作目錄。這個工作目錄通常是啟動 Node.js 進程時所在的目錄。 const fs require(fs); const path require(path);// 讀取指定目錄 const configPath path.join(process.cwd(), c…

StarRocks實戰——貝殼找房數倉實踐

目錄 前言 一、StarRocks在貝殼的應用現狀 1.1 歷史的數據分析架構 1.2 OLAP選型 1.2.1 離線場景 1.2.2 實時場景 1.2.3 StarRocks 的引入 二、StarRocks 在貝殼的分析實踐 2.1 指標分析 2.2 實時業務 2.3 可視化分析 三、未來規劃 3.1 StarRocks集群的穩定性 3…

PMP考試培訓費用多少錢?

PMP考試的相關費用包括報名費用、培訓費用和證書續證費用三個部分。 一、PMP考試報名費用&#xff1a; 首次報考費用為3900元&#xff0c;如果未通過考試可以在英文報名有效期內進行補考報名&#xff0c;補考費用為2500元。 付費方式是在項目管理學會官方網站上提交報考資料…

企業數字化轉型的第一步:由被動多云向主動多云轉變

隨著經濟環境、市場形勢、技術發展、用戶需求等諸多因素的變化&#xff0c;數字化轉型為企業進一步提升效率和競爭力、提供更加豐富的個性化產品和服務、進行業務場景創新、探尋新的增長機會和運營模式提供了嶄新的途徑。越來越多的企業意識到&#xff0c;數字化轉型已不是企業…

第1篇 Linux Docker安裝rabbitmq

Docker安裝RabbitMq 1、搜索rabbitmq鏡像 docker search rabbitmq2、下載rabbitmq鏡像 docker pull rabbitmq3、運行rabbitmq服務 docker run -d --name rabbitmq --restart always -p 15672:15672 -p 5672:5672 rabbitmq4、訪問rabbitmq http://192.168.1.x:15672 5、rab…

亞信安慧AntDB:打破數據孤島,實現實時處理

AntDB數據庫以其獨特的創新能力在分布式數據庫領域引領潮流。其中&#xff0c;融合統一與實時處理是其兩大核心創新能力&#xff0c;為其贏得廣泛關注與贊譽。融合統一意味著AntDB能夠將多種不同類型的數據庫融合為一體&#xff0c;實現數據的統一管理與處理&#xff0c;極大地…

電視盒子什么品牌好?資深數碼粉強推口碑電視盒子推薦

我對各類數碼產品是非常熟悉的&#xff0c;尤其是電視盒子&#xff0c;用過超十五款了&#xff0c;涵蓋了各個主流品牌&#xff0c;最近看到很多朋友在討論不知道電視盒子什么品牌好&#xff0c;我這次要來分享的就是口碑最好的五款電視盒子推薦給各位不懂如何選電視盒子的新手…

AI、AIGC、AGI、ChatGPT它們的區別?

今天咱們聊點熱門話題&#xff0c;來點科普時間——AI、AIGC、AGI和ChatGPT到底是啥&#xff1f;這幾個詞聽起來好像挺神秘的&#xff0c;但其實它們就在我們生活中。讓我們一起探索這些術語的奧秘&#xff01; AI&#xff08;人工智能&#xff09;&#xff1a;先說說AI&#…

數倉技術選型特點

高性能&#xff1a;用全并行的MPP架構數據庫&#xff0c;業務數據被分散存儲在多個節點上&#xff0c;數據分析任務被推送到數據所在位置就近執行&#xff0c;并行地完成大規模的數據處理工作&#xff0c;實現對數據處理的快速響應。 易擴展&#xff1a;Shared-Nothing開放架構…

電梯物聯網之梯控相機方案-防止電瓶車進電梯

梯控現狀 隨著電梯產品在智能化建筑的日益普及,對于電梯的智能化管理 安全性需求 的要求越來越迫切。尤其今年來隨著電瓶車的大量普及&#xff0c;發起多起樓道、轎廂電瓶車著火惡性事件&#xff0c; 造成了極大的社會 負面影響。控制電瓶車進入單元門&#xff0c;樓道以及電梯…