Package org.aksw.commons.collections
Class PolaritySet<T>
java.lang.Object
org.aksw.commons.collections.PolaritySet<T>
- Type Parameters:
T-
- All Implemented Interfaces:
Serializable,Cloneable
A set of values with positive or negative polarity
This set can thus act as a white or blacklist.
- Author:
- Claus Stadler, Aug 1, 2018
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()protected PolaritySet<T>clone()booleanstatic <T> PolaritySet<T>create(boolean isPositive, T... values) static <T> PolaritySet<T>createDifferenceView(PolaritySet<T> self, PolaritySet<T> that) case: positive - positive Simply take the difference case: positive - negative {1, 2, 3} difference {not {3}}: -> { 3 } (intersection) case: negative - positive {not {3} } difference {1, 2, 3}: case: negative - negative Simply take the intersectionstatic <T> PolaritySet<T>createIntersectionView(PolaritySet<T> self, PolaritySet<T> that) case: positive - positive Simply take the intersection case: positive - negative {1, 2, 3} intersect {not {2}}: -> {1, 3} (positive.removeAll(negative)) case: negative - positive Same as above case: negative - negative Simply take the unionstatic <T> PolaritySet<T>createUnionView(PolaritySet<T> self, PolaritySet<T> that) case: positive - positive Simply take the union case: positive - negative {1, 2, 3} intersect {not {1, 4}}: -> {4} (negative.removeAll(positive)) case: negative - positive Same as above case: negative - negative Simply take the intersectiondifference(PolaritySet<T> that) Immutable union; returns a viewbooleangetValue()inthashCode()intersect(PolaritySet<T> that) Immutable union; returns a viewbooleanisEmpty()booleannegate()Immutable negate; returns a viewbooleansetPolarity(boolean isPositive) Set the polaritystateIntersect(PolaritySet<T> that) Mutating intersectionMutates this by flipping the polaritystateUnion(PolaritySet<T> that) Mutating uniontoString()union(PolaritySet<T> that) Immutable union; returns a view
-
Field Details
-
values
-
isPositive
protected boolean isPositive
-
-
Constructor Details
-
PolaritySet
-
PolaritySet
-
-
Method Details
-
clone
-
create
-
union
Immutable union; returns a view -
intersect
Immutable union; returns a view -
difference
Immutable union; returns a view -
negate
Immutable negate; returns a view -
isEmpty
public boolean isEmpty() -
contains
-
isPositive
public boolean isPositive() -
setPolarity
public boolean setPolarity(boolean isPositive) Set the polarity- Parameters:
isPositive- the new value for the polarity; true = positive- Returns:
- The old polarity befor setting the new one.
-
getValue
-
clear
public void clear() -
toString
-
hashCode
public int hashCode() -
equals
-
stateIntersect
Mutating intersection -
stateUnion
Mutating union -
stateNegate
Mutates this by flipping the polarity -
createDifferenceView
case: positive - positive Simply take the difference case: positive - negative {1, 2, 3} difference {not {3}}: -> { 3 } (intersection) case: negative - positive {not {3} } difference {1, 2, 3}: case: negative - negative Simply take the intersection- Parameters:
other-- Returns:
-
createIntersectionView
case: positive - positive Simply take the intersection case: positive - negative {1, 2, 3} intersect {not {2}}: -> {1, 3} (positive.removeAll(negative)) case: negative - positive Same as above case: negative - negative Simply take the union- Parameters:
other-- Returns:
-
createUnionView
case: positive - positive Simply take the union case: positive - negative {1, 2, 3} intersect {not {1, 4}}: -> {4} (negative.removeAll(positive)) case: negative - positive Same as above case: negative - negative Simply take the intersection- Parameters:
that-- Returns:
-