Open the long-lost IDEA, iterate the project functions, and add a small de-duplication function.

The java-list collection removes the implementation of duplicate objects

Core ideas:

Object duplication means that all variables in an object have the same value, not necessarily the address. List sets are stored as basic types and are easily removed by converting a list to a set.

Three steps:

Public Boolean equals(Object obj) {} public int hashCode() {} Public Boolean equals(Object obj) {} public Boolean equals(Object obj) {}

Add the corresponding public Boolean equals(Object obj) {} and public int hashCode() {}.

The basic module class overrides these two methods:

@override public Boolean equals(Object obj) {Threat_identification_v =(Threat_identification_v)obj; return ip.equals(s.ip)&&software_hardware.equals(s.software_hardware)&&physical_environment==s.physical_environment; @override public int hashCode() {String in = IP + software_hardware + physical_environment; return in.hashCode(); }Copy the code

This task is to de-compare the three main IP addresses, threat name, and threat level

The second step is to save the core data set

// Set sets hold objects that refer to different addresses

Setts = new HashSet(); ts.addAll(threat_identification_vs);Copy the code

This is a stack-like comparison, where the output may be the reverse of the actual value.

The third step is to integrate the original processing methods

rendering

The effect of not being de-processed

Optimized data effect for processing (stack effect advanced and back out -> reversed)

This is a convenient way to do it.

There is also a double loop for logical judgment. The above method may have more code.

A two-tier judgment loop can also be used. (I won’t do the demo this time.)

References:

www.timeit.cn/post-165.ht…

www.cnblogs.com/qianzf/p/75…

www.cnblogs.com/zhaoyan001/…

Subscribe for more revisited articles and study notes

thelostworld

Safe road, side by side with you !!!!

Personal knowledge: www.zhihu.com/people/fu-w…

Brief personal book: www.jianshu.com/u/bf0e38a8d…