Java-set Source Code Analysis

Source: Internet
Author: User

Set is also inherited from Collection,set, which is also a collection, and set does not allow duplicate elements to exist.
Set source code:
Public Interfaceset<E>extendscollection<E> {intsize(); //Size    BooleanIsEmpty();//Is empty    Booleancontains(Object o); //Whether an object is included    iterator<E>iterator(); //Generate iterators    Object[]ToArray(); //Returns an object array    <T>T[]ToArray(T[] a); //return generic array    BooleanAdd(EE; //Add elements to set    BooleanRemove(Object o); //Remove an element from the set    BooleanContainsall(collection<?> c); //Whether a collection is included in this LSet    BooleanAddAll(COLLECTION&LT;?extendsE> C); //Append a collection to this set    BooleanRetainall(collection<?> c); //delete elements in a set that do not exist in collection    BooleanRemoveAll(collection<?> c); //Delete the elements contained in this collection    voidClear(); //Empty set    Booleanequals(Object o);//Determine if two sets are the same    inthashcode(); //Calculate set's Hashcode    @Override    defaultspliterator<E>Spliterator() {returnSpliterators.spliterator (This ,SPLITERATOR.DISTINCT);    }}

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Java-set Source Code Analysis

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.