java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractSet<E>
org.jgrapht.util.WeightedUnmodifiableSet<E>
- Type Parameters:
E- element type
- All Implemented Interfaces:
Serializable,Iterable<E>,Collection<E>,Set<E>
- Direct Known Subclasses:
CliqueAlgorithm.CliqueImpl,IndependentSetAlgorithm.IndependentSetImpl,SpannerAlgorithm.SpannerImpl,VertexCoverAlgorithm.VertexCoverImpl
Implementation of a weighted, unmodifiable set. This class can for instance be used to store a
weighted vertex cover. The
hashCode() and equals() methods are identical to those
of a normal set, i.e. they are independent of the weight of this class. All methods are
delegated to the underlying set.- Author:
- Joris Kinable
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionWeightedUnmodifiableSet(Set<E> backingSet) Constructs a WeightedUnmodifiableSet instanceWeightedUnmodifiableSet(Set<E> backingSet, double weight) Constructs a WeightedUnmodifiableSet instance -
Method Summary
Modifier and TypeMethodDescriptionbooleanbooleanaddAll(Collection<? extends E> c) voidclear()booleanbooleancontainsAll(Collection<?> c) booleandoubleReturns the weight of the set.inthashCode()booleanisEmpty()iterator()booleanbooleanremoveAll(Collection<?> c) booleanretainAll(Collection<?> c) intsize()Object[]toArray()<T> T[]toArray(T[] a) Methods inherited from class java.util.AbstractCollection
toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface java.util.Set
spliterator
-
Field Details
-
backingSet
-
weight
public final double weight
-
-
Constructor Details
-
WeightedUnmodifiableSet
Constructs a WeightedUnmodifiableSet instance- Parameters:
backingSet- underlying set
-
WeightedUnmodifiableSet
Constructs a WeightedUnmodifiableSet instance- Parameters:
backingSet- underlying setweight- weight of the set
-
-
Method Details
-
getWeight
public double getWeight()Returns the weight of the set.- Returns:
- weight of the set
-
size
public int size()- Specified by:
sizein interfaceCollection<E>- Specified by:
sizein interfaceSet<E>- Specified by:
sizein classAbstractCollection<E>
-
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfaceCollection<E>- Specified by:
isEmptyin interfaceSet<E>- Overrides:
isEmptyin classAbstractCollection<E>
-
contains
- Specified by:
containsin interfaceCollection<E>- Specified by:
containsin interfaceSet<E>- Overrides:
containsin classAbstractCollection<E>
-
iterator
-
toArray
- Specified by:
toArrayin interfaceCollection<E>- Specified by:
toArrayin interfaceSet<E>- Overrides:
toArrayin classAbstractCollection<E>
-
toArray
public <T> T[] toArray(T[] a) - Specified by:
toArrayin interfaceCollection<E>- Specified by:
toArrayin interfaceSet<E>- Overrides:
toArrayin classAbstractCollection<E>
-
add
- Specified by:
addin interfaceCollection<E>- Specified by:
addin interfaceSet<E>- Overrides:
addin classAbstractCollection<E>
-
remove
- Specified by:
removein interfaceCollection<E>- Specified by:
removein interfaceSet<E>- Overrides:
removein classAbstractCollection<E>
-
containsAll
- Specified by:
containsAllin interfaceCollection<E>- Specified by:
containsAllin interfaceSet<E>- Overrides:
containsAllin classAbstractCollection<E>
-
addAll
- Specified by:
addAllin interfaceCollection<E>- Specified by:
addAllin interfaceSet<E>- Overrides:
addAllin classAbstractCollection<E>
-
retainAll
- Specified by:
retainAllin interfaceCollection<E>- Specified by:
retainAllin interfaceSet<E>- Overrides:
retainAllin classAbstractCollection<E>
-
removeAll
- Specified by:
removeAllin interfaceCollection<E>- Specified by:
removeAllin interfaceSet<E>- Overrides:
removeAllin classAbstractSet<E>
-
clear
public void clear()- Specified by:
clearin interfaceCollection<E>- Specified by:
clearin interfaceSet<E>- Overrides:
clearin classAbstractCollection<E>
-
equals
- Specified by:
equalsin interfaceCollection<E>- Specified by:
equalsin interfaceSet<E>- Overrides:
equalsin classAbstractSet<E>
-
hashCode
public int hashCode()- Specified by:
hashCodein interfaceCollection<E>- Specified by:
hashCodein interfaceSet<E>- Overrides:
hashCodein classAbstractSet<E>
-