SetE


Set<E> java.util

Java 1.2 collection

This interface represents an unordered Collection of objects that contains no duplicate elements. That is, a Set cannot contain two elements e1 and e2 where e1.equals(e2) , and it can contain at most one null element. The Set interface defines the same methods as its superinterface, Collection . It constrains the add( ) and addAll( ) methods from adding duplicate elements to the Set . In Java 5.0 Set is a generic interface and the type variable E represents the type of the objects in the set.

An interface cannot specify constructors, but it is conventional that all implementations of Set provide at least two standard constructors: one that takes no arguments and creates an empty set, and a copy constructor that accepts a Collection object that specifies the initial contents of the new Set . This copy constructor must ensure that duplicate elements are not added to the Set , of course.

As with Collection , the Set methods that modify the contents of the set are optional, and implementations that do not support the methods throw java.lang.UnsupportedOperationException . See also Collection , List , Map , SortedSet , HashSet , and TReeSet .

Figure 16-54. java.util.Set<E>

 public interface  Set<E>  extends Collection<E> {  // Public Instance Methods  boolean  add  (E  o  );        boolean  addAll  (Collection<? extends E>  c  );        void  clear  ( );        boolean  contains  (Object  o  );        boolean  containsAll  (Collection<?>  c  );        boolean  equals  (Object  o  );        int  hashCode  ( );        boolean  isEmpty  ( );        Iterator<E>  iterator  ( );        boolean  remove  (Object  o  );        boolean  removeAll  (Collection<?>  c  );        boolean  retainAll  (Collection<?>  c  );        int  size  ( );        Object[ ]  toArray  ( );        <T> T[ ]  toArray  (T[ ]  a  );   } 

Implementations

AbstractSet , HashSet , LinkedHashSet , SortedSet

Passed To

java.security.cert.PKIXBuilderParameters.PKIXBuilderParameters( ) , java.security.cert.PKIXParameters.{PKIXParameters( ) , setInitialPolicies( ) , setTrustAnchors( )} , java.security.cert.X509CertSelector.{setExtendedKeyUsage( ) , setPolicy( )} , java.text.AttributedCharacterIterator.{getRunLimit( ) , getrunStart( )} , Collections.{checkedSet( ) , synchronizedSet( ) , unmodifiableSet( )} , javax.security.auth.Subject.Subject( )

Returned By

Too many methods to list.

Type Of

Collections.EMPTY_SET



Java In A Nutshell
Java In A Nutshell, 5th Edition
ISBN: 0596007736
EAN: 2147483647
Year: 2004
Pages: 1220

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net