Package org.apache.calcite.util
Class EquivalenceSet<E extends Comparable<E>>
java.lang.Object
org.apache.calcite.util.EquivalenceSet<E>
- Type Parameters:
- E- Element type
Set of elements organized into equivalence classes.
 
Elements are equivalent by the rules of a mathematical equivalence relation:
- Reflexive
- Every element eis equivalent to itself
- Symmetric
- If eis equivalent tof, thenfis equivalent toe
- Transitive
- If eis equivalent tof, andfis equivalent tog, theneis equivalent tog
For any given pair of elements, answers in O(log N) (two hash-table lookups) whether they are equivalent to each other.
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionAdds an element, and returns the element (which is its own parent).booleanareEquivalent(E e, E f) Returns whether two elements are in the same equivalence class.intReturns the number of equivalence classes in this equivalence set.voidclear()Removes all elements in this equivalence set.Marks two elements as equivalent.map()Returns a map of the canonical element in each equivalence class to the set of elements in that class.intsize()Returns the number of elements in this equivalence set.
- 
Constructor Details- 
EquivalenceSetpublic EquivalenceSet()
 
- 
- 
Method Details- 
addAdds an element, and returns the element (which is its own parent). If already present, returns the element's parent.
- 
equivMarks two elements as equivalent. They may or may not be registered, and they may or may not be equal.
- 
areEquivalentReturns whether two elements are in the same equivalence class. Returns false if either or both of the elements are not registered.
- 
mapReturns a map of the canonical element in each equivalence class to the set of elements in that class. The keys are sorted in natural order, as are the elements within each key.
- 
clearpublic void clear()Removes all elements in this equivalence set.
- 
sizepublic int size()Returns the number of elements in this equivalence set.
- 
classCountpublic int classCount()Returns the number of equivalence classes in this equivalence set.
 
-