当前位置:网站首页>Guava common collection tool classes
Guava common collection tool classes
2022-06-25 05:38:00 【Which floor do you rate moto】
- Sets Tool class operations Set aggregate
- Combine , Delivery and , Difference set , Decompose all subsets in the set , Find the Cartesian product of two sets
public class sets {
public static void main(String[] args) {
Set<Integer> set1 = Sets.newHashSet(1,2,3,4);
Set<Integer> set2 = Sets.newHashSet(4,5,6);
// Combine
Set<Integer> integerSet = Sets.union(set1,set2);
System.out.println(integerSet);
// intersection
Set<Integer> intersectionSet = Sets.intersection(set1,set2);
System.out.println(intersectionSet);
// Difference set : The element belongs to set1 It doesn't belong to set2
Set<Integer> differenceSet = Sets.difference(set1,set2);
System.out.println(differenceSet);
// Relative difference set : Belong to A It doesn't belong to B, Belong to B It doesn't belong to A
Set<Integer> symmetricDifference = Sets.symmetricDifference(set1,set2);
System.out.println(symmetricDifference);
// Decompose all subsets in the set
Set<Set<Integer>> powerSet = Sets.powerSet(set1);
System.out.println(JSON.toJSON(powerSet));
// Cartesian product of two sets
Set<List<Integer>> cartesianProduct = Sets.cartesianProduct(set1,set2);
System.out.println(JSON.toJSON(cartesianProduct));
}
- Lists Tool class operations List aggregate
- reverse , Split
public class lists {
public static void main(String[] args) {
List<Integer> list = Lists.newArrayList(1,2,3,4,5,6,7);
//3 individual 3 Split up : Support with 3 An interface for querying a group of order numbers
List<List<Integer>>lists = Lists.partition(list,3);
System.out.println(lists);
// reverse
List<Integer> integerList = Lists.reverse(list);
System.out.println(integerList);
}
}
边栏推荐
- Edge loss interpretation
- For in JS Of and for in
- Fundamentals of C language
- Two dimensional array and function call cases of C language
- Conflict between v-mode and v-decorator in Ant Design
- Trouble of setting table property to null
- [QT] for multithreaded programs, do not use the printf() function to print out
- H5 canvas drawing circle drawing fillet [detailed explanation]
- CVPR2021-Semi-supervised Domain Adaptation based on Dual-level Domain Mixing for Semantic Segmentati
- C style string
猜你喜欢
Semantic segmentation cvpr2020 unsupervised intra domain adaptation for semantic segmentation through self supervision
Instant messaging project (I)
Svg code snippet of loading animation
[OSPF routing calculation (class I LSA router, class II LSA network, and class III LSA sum net)] -20211228-30
Flex flexible layout for mobile terminal page production
Volatile and JMM memory models
2022.1.23 diary
Array and simple function encapsulation cases
H5 native player [learn video]
Code learning-cvpr2020 unsupervised domain adaptive semantic segmentation: intra advance
随机推荐
Database low-end SQL query statement fragment
Deeply understand the characteristics of standard flow and off standard elements
Jason learning
[relax's law of life lying on the square] those poisonous chicken soup that seem to be too light and too heavy, but think carefully and fear
Analysis of IM project framework
Electronic Society C language level 1 28, character diamond
Electric store stores data
Dynamic programming Backpack - 01 Backpack
MySQL -- optimize query statements and use not in with cases
Extend the toolbar of quill editor
CVPR2021-Semi-supervised Domain Adaptation based on Dual-level Domain Mixing for Semantic Segmentati
Deep learning non local neural networks
Basic bit operation symbols of C language
Database query optimization method
[pan Wai 1] Huawei computer test
Voxel based and second network learning
DOM document object model (I)
Word quickly makes multiple single-sided table labels, number plates, etc
Detailed summary of flex layout
Various pits encountered in the configuration of yolov3 on win10