Java Collection orthogonal complement

Source: Internet
Author: User

Expressions in mathematics are expressed by using generic methods and set: The orthogonal complement of the collection, which copies the first parameter set in the following three methods, and does not directly modify the set in the parameter.
Package Set;import Java.util.hashset;import Java.util.set;public class Sets {public  static <T> set<t> Intersection (set<t> s1, set<t> s2) {set<t> result = new hashset<t> (s1); Result.retainall (S2); return result;} Public  Static <T> set<t> Union (set<t> S1, set<t> s2) {set<t> result = new hashset<t& gt; (s1); Result.addall (S2); return result;} Subtract subset from Supersetpublic  static <T> set<t> difference (set<t> superset, set<t> subset) {set<t> result = new hashset<t> (superset); Result.addall (subset); return result;} Reflexive--everything not in their intersectionpublic static <T> set<t> complement (set<t>s1,set <T> S2) {Return Difference (Union (S1,S2), intersection (S1,S2));}}

Java Collection orthogonal complement

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.