Package net.cscott.jutil
Interface SetFactory<V>
- All Superinterfaces:
CollectionFactory<V>
- All Known Implementing Classes:
AggregateSetFactory,BitSetFactory,PersistentSetFactory
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
SetFactory is a Set generator.
Implementations construct specific types of Sets.
It is a functional interface, so a constructor which copies a
collection is a SetFactory:
SetFactory<String> sf = HashSet::new;A lambda or a method reference is not serializable unless it is cast to a serializable type, as in
(SetFactory<V> & Serializable) HashSet::new.
The factories of Factories are serializable.
Note also that the current limitations on parametric types in
Java mean that we can't easily type this class as
SetFactory<S extends Set<V>,V>,
as SetFactory<HashSet<V>,V> is not
a subtype of SetFactory<Set<V>,V>,
even though HashSet is a subtype of Set.
- Author:
- Felix S. Klock II <pnkfelix@mit.edu>
-
Method Summary
Modifier and TypeMethodDescriptionGenerates a new, mutable, emptyCollection.makeCollection(int initCapacity) Generates a new, mutable, emptyCollection, usinginitialCapacityas a hint to use for the capacity for the producedCollection.makeCollection(Collection<? extends V> c) Generates a new, mutableCollection, using the elements ofcas a template for its initial contents.makeSet()Generates a new, mutable, emptySet.makeSet(int initialCapacity) makeSet(Collection<? extends V> c) Generates a new mutableSet, using the elements ofcas a template for its initial contents.
-
Method Details
-
makeCollection
Description copied from interface:CollectionFactoryGenerates a new, mutable, emptyCollection.- Specified by:
makeCollectionin interfaceCollectionFactory<V>
-
makeCollection
Description copied from interface:CollectionFactoryGenerates a new, mutableCollection, using the elements ofcas a template for its initial contents. Note that theCollectionreturned is not a view ofc, but rather a snapshot; changes tocare not reflected in the returnedCollection.- Specified by:
makeCollectionin interfaceCollectionFactory<V>
-
makeCollection
Description copied from interface:CollectionFactoryGenerates a new, mutable, emptyCollection, usinginitialCapacityas a hint to use for the capacity for the producedCollection.- Specified by:
makeCollectionin interfaceCollectionFactory<V>
-
makeSet
Generates a new, mutable, emptySet. -
makeSet
-
makeSet
Generates a new mutableSet, using the elements ofcas a template for its initial contents.
-