Package com.google.common.collect
Class TreeMultiset.AvlNode<E>
- java.lang.Object
-
- com.google.common.collect.Multisets.AbstractEntry<E>
-
- com.google.common.collect.TreeMultiset.AvlNode<E>
-
- All Implemented Interfaces:
Multiset.Entry<E>
- Enclosing class:
- TreeMultiset<E>
private static final class TreeMultiset.AvlNode<E> extends Multisets.AbstractEntry<E>
-
-
Field Summary
Fields Modifier and Type Field Description private int
distinctElements
private E
elem
private int
elemCount
private int
height
private TreeMultiset.AvlNode<E>
left
private TreeMultiset.AvlNode<E>
pred
private TreeMultiset.AvlNode<E>
right
private TreeMultiset.AvlNode<E>
succ
private long
totalCount
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) TreeMultiset.AvlNode<E>
add(java.util.Comparator<? super E> comparator, E e, int count, int[] result)
private TreeMultiset.AvlNode<E>
addLeftChild(E e, int count)
private TreeMultiset.AvlNode<E>
addRightChild(E e, int count)
private int
balanceFactor()
private TreeMultiset.AvlNode<E>
ceiling(java.util.Comparator<? super E> comparator, E e)
int
count(java.util.Comparator<? super E> comparator, E e)
private TreeMultiset.AvlNode<E>
deleteMe()
private TreeMultiset.AvlNode<E>
floor(java.util.Comparator<? super E> comparator, E e)
int
getCount()
Returns the count of the associated element in the underlying multiset.E
getElement()
Returns the multiset element corresponding to this entry.private static int
height(TreeMultiset.AvlNode<?> node)
private TreeMultiset.AvlNode<E>
rebalance()
private void
recompute()
private void
recomputeHeight()
private void
recomputeMultiset()
(package private) TreeMultiset.AvlNode<E>
remove(java.util.Comparator<? super E> comparator, E e, int count, int[] result)
private TreeMultiset.AvlNode<E>
removeMax(TreeMultiset.AvlNode<E> node)
private TreeMultiset.AvlNode<E>
removeMin(TreeMultiset.AvlNode<E> node)
private TreeMultiset.AvlNode<E>
rotateLeft()
private TreeMultiset.AvlNode<E>
rotateRight()
(package private) TreeMultiset.AvlNode<E>
setCount(java.util.Comparator<? super E> comparator, E e, int count, int[] result)
(package private) TreeMultiset.AvlNode<E>
setCount(java.util.Comparator<? super E> comparator, E e, int expectedCount, int newCount, int[] result)
java.lang.String
toString()
Returns a string representation of this multiset entry.private static long
totalCount(TreeMultiset.AvlNode<?> node)
-
Methods inherited from class com.google.common.collect.Multisets.AbstractEntry
equals, hashCode
-
-
-
-
Field Detail
-
elem
@Nullable private final E elem
-
elemCount
private int elemCount
-
distinctElements
private int distinctElements
-
totalCount
private long totalCount
-
height
private int height
-
left
private TreeMultiset.AvlNode<E> left
-
right
private TreeMultiset.AvlNode<E> right
-
pred
private TreeMultiset.AvlNode<E> pred
-
succ
private TreeMultiset.AvlNode<E> succ
-
-
Constructor Detail
-
AvlNode
AvlNode(@Nullable E elem, int elemCount)
-
-
Method Detail
-
addRightChild
private TreeMultiset.AvlNode<E> addRightChild(E e, int count)
-
addLeftChild
private TreeMultiset.AvlNode<E> addLeftChild(E e, int count)
-
add
TreeMultiset.AvlNode<E> add(java.util.Comparator<? super E> comparator, @Nullable E e, int count, int[] result)
-
remove
TreeMultiset.AvlNode<E> remove(java.util.Comparator<? super E> comparator, @Nullable E e, int count, int[] result)
-
setCount
TreeMultiset.AvlNode<E> setCount(java.util.Comparator<? super E> comparator, @Nullable E e, int count, int[] result)
-
setCount
TreeMultiset.AvlNode<E> setCount(java.util.Comparator<? super E> comparator, @Nullable E e, int expectedCount, int newCount, int[] result)
-
deleteMe
private TreeMultiset.AvlNode<E> deleteMe()
-
removeMin
private TreeMultiset.AvlNode<E> removeMin(TreeMultiset.AvlNode<E> node)
-
removeMax
private TreeMultiset.AvlNode<E> removeMax(TreeMultiset.AvlNode<E> node)
-
recomputeMultiset
private void recomputeMultiset()
-
recomputeHeight
private void recomputeHeight()
-
recompute
private void recompute()
-
rebalance
private TreeMultiset.AvlNode<E> rebalance()
-
balanceFactor
private int balanceFactor()
-
rotateLeft
private TreeMultiset.AvlNode<E> rotateLeft()
-
rotateRight
private TreeMultiset.AvlNode<E> rotateRight()
-
totalCount
private static long totalCount(@Nullable TreeMultiset.AvlNode<?> node)
-
height
private static int height(@Nullable TreeMultiset.AvlNode<?> node)
-
ceiling
@Nullable private TreeMultiset.AvlNode<E> ceiling(java.util.Comparator<? super E> comparator, E e)
-
floor
@Nullable private TreeMultiset.AvlNode<E> floor(java.util.Comparator<? super E> comparator, E e)
-
getElement
public E getElement()
Description copied from interface:Multiset.Entry
Returns the multiset element corresponding to this entry. Multiple calls to this method always return the same instance.- Returns:
- the element corresponding to this entry
-
getCount
public int getCount()
Description copied from interface:Multiset.Entry
Returns the count of the associated element in the underlying multiset. This count may either be an unchanging snapshot of the count at the time the entry was retrieved, or a live view of the current count of the element in the multiset, depending on the implementation. Note that in the former case, this method can never return zero, while in the latter, it will return zero if all occurrences of the element were since removed from the multiset.- Returns:
- the count of the element; never negative
-
toString
public java.lang.String toString()
Description copied from class:Multisets.AbstractEntry
Returns a string representation of this multiset entry. The string representation consists of the associated element if the associated count is one, and otherwise the associated element followed by the characters " x " (space, x and space) followed by the count. Elements and counts are converted to strings as byString.valueOf
.- Specified by:
toString
in interfaceMultiset.Entry<E>
- Overrides:
toString
in classMultisets.AbstractEntry<E>
-
-