MCPcopy
hub / github.com/google/guava / DescendingMultiset

Class DescendingMultiset

guava/src/com/google/common/collect/DescendingMultiset.java:34–164  ·  guava/src/com/google/common/collect/DescendingMultiset.java::DescendingMultiset

A skeleton implementation of a descending multiset. Only needs {@code forwardMultiset()} and {@code entryIterator()}. @author Louis Wasserman

Source from the content-addressed store, hash-verified

32 * @author Louis Wasserman
33 */
34@GwtCompatible
35abstract class DescendingMultiset<E extends @Nullable Object> extends ForwardingMultiset<E>
36 implements SortedMultiset<E> {
37 abstract SortedMultiset<E> forwardMultiset();
38
39 @LazyInit private transient @Nullable Comparator<? super E> comparator;
40
41 @Override
42 public Comparator<? super E> comparator() {
43 Comparator<? super E> result = comparator;
44 if (result == null) {
45 result = Ordering.from(forwardMultiset().comparator()).reverse();
46 comparator = result;
47 }
48 return result;
49 }
50
51 @LazyInit private transient @Nullable NavigableSet<E> elementSet;
52
53 @Override
54 public NavigableSet<E> elementSet() {
55 NavigableSet<E> result = elementSet;
56 if (result == null) {
57 return elementSet = new SortedMultisets.NavigableElementSet<>(this);
58 }
59 return result;
60 }
61
62 @Override
63 public @Nullable Entry<E> pollFirstEntry() {
64 return forwardMultiset().pollLastEntry();
65 }
66
67 @Override
68 public @Nullable Entry<E> pollLastEntry() {
69 return forwardMultiset().pollFirstEntry();
70 }
71
72 @Override
73 public SortedMultiset<E> headMultiset(@ParametricNullness E toElement, BoundType boundType) {
74 return forwardMultiset().tailMultiset(toElement, boundType).descendingMultiset();
75 }
76
77 @Override
78 public SortedMultiset<E> subMultiset(
79 @ParametricNullness E fromElement,
80 BoundType fromBoundType,
81 @ParametricNullness E toElement,
82 BoundType toBoundType) {
83 return forwardMultiset()
84 .subMultiset(toElement, toBoundType, fromElement, fromBoundType)
85 .descendingMultiset();
86 }
87
88 @Override
89 public SortedMultiset<E> tailMultiset(@ParametricNullness E fromElement, BoundType boundType) {
90 return forwardMultiset().headMultiset(fromElement, boundType).descendingMultiset();
91 }

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected