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
-
Constructor Summary
ConstructorDescriptionWeightedUnmodifiableSet
(Set<E> backingSet) Constructs a WeightedUnmodifiableSet instanceWeightedUnmodifiableSet
(Set<E> backingSet, double weight) Constructs a WeightedUnmodifiableSet instance -
Method Summary
Modifier and TypeMethodDescriptionboolean
boolean
addAll
(Collection<? extends E> c) void
clear()
boolean
boolean
containsAll
(Collection<?> c) boolean
double
Returns the weight of the set.int
hashCode()
boolean
isEmpty()
iterator()
boolean
boolean
removeAll
(Collection<?> c) boolean
retainAll
(Collection<?> c) int
size()
Object[]
toArray()
<T> T[]
toArray
(T[] a) Methods inherited from class java.util.AbstractCollection
toString
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
Methods 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:
size
in interfaceCollection<E>
- Specified by:
size
in interfaceSet<E>
- Specified by:
size
in classAbstractCollection<E>
-
isEmpty
public boolean isEmpty()- Specified by:
isEmpty
in interfaceCollection<E>
- Specified by:
isEmpty
in interfaceSet<E>
- Overrides:
isEmpty
in classAbstractCollection<E>
-
contains
- Specified by:
contains
in interfaceCollection<E>
- Specified by:
contains
in interfaceSet<E>
- Overrides:
contains
in classAbstractCollection<E>
-
iterator
-
toArray
- Specified by:
toArray
in interfaceCollection<E>
- Specified by:
toArray
in interfaceSet<E>
- Overrides:
toArray
in classAbstractCollection<E>
-
toArray
public <T> T[] toArray(T[] a) - Specified by:
toArray
in interfaceCollection<E>
- Specified by:
toArray
in interfaceSet<E>
- Overrides:
toArray
in classAbstractCollection<E>
-
add
- Specified by:
add
in interfaceCollection<E>
- Specified by:
add
in interfaceSet<E>
- Overrides:
add
in classAbstractCollection<E>
-
remove
- Specified by:
remove
in interfaceCollection<E>
- Specified by:
remove
in interfaceSet<E>
- Overrides:
remove
in classAbstractCollection<E>
-
containsAll
- Specified by:
containsAll
in interfaceCollection<E>
- Specified by:
containsAll
in interfaceSet<E>
- Overrides:
containsAll
in classAbstractCollection<E>
-
addAll
- Specified by:
addAll
in interfaceCollection<E>
- Specified by:
addAll
in interfaceSet<E>
- Overrides:
addAll
in classAbstractCollection<E>
-
retainAll
- Specified by:
retainAll
in interfaceCollection<E>
- Specified by:
retainAll
in interfaceSet<E>
- Overrides:
retainAll
in classAbstractCollection<E>
-
removeAll
- Specified by:
removeAll
in interfaceCollection<E>
- Specified by:
removeAll
in interfaceSet<E>
- Overrides:
removeAll
in classAbstractSet<E>
-
clear
public void clear()- Specified by:
clear
in interfaceCollection<E>
- Specified by:
clear
in interfaceSet<E>
- Overrides:
clear
in classAbstractCollection<E>
-
equals
- Specified by:
equals
in interfaceCollection<E>
- Specified by:
equals
in interfaceSet<E>
- Overrides:
equals
in classAbstractSet<E>
-
hashCode
public int hashCode()- Specified by:
hashCode
in interfaceCollection<E>
- Specified by:
hashCode
in interfaceSet<E>
- Overrides:
hashCode
in classAbstractSet<E>
-