1/*
2 * Copyright (C) 2011 The Guava Authors
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 * in compliance with the License. You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software distributed under the License
10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 * or implied. See the License for the specific language governing permissions and limitations under
12 * the License.
13 */
14
15package com.google.common.collect;
16
17import static com.google.common.base.Preconditions.checkNotNull;
18
19import java.util.Comparator;
20
21import javax.annotation.Nullable;
22
23/**
24 * An empty immutable sorted multiset.
25 *
26 * @author Louis Wasserman
27 */
28final class EmptyImmutableSortedMultiset<E> extends ImmutableSortedMultiset<E> {
29  EmptyImmutableSortedMultiset(Comparator<? super E> comparator) {
30    super(comparator);
31  }
32
33  @Override
34  public Entry<E> firstEntry() {
35    return null;
36  }
37
38  @Override
39  public Entry<E> lastEntry() {
40    return null;
41  }
42
43  @Override
44  public int count(@Nullable Object element) {
45    return 0;
46  }
47
48  @Override
49  public int size() {
50    return 0;
51  }
52
53  @Override
54  ImmutableSortedSet<E> createElementSet() {
55    return ImmutableSortedSet.emptySet(comparator());
56  }
57
58  @Override
59  ImmutableSortedSet<E> createDescendingElementSet() {
60    return ImmutableSortedSet.emptySet(reverseComparator());
61  }
62
63  @Override
64  UnmodifiableIterator<Entry<E>> descendingEntryIterator() {
65    return Iterators.emptyIterator();
66  }
67
68  @Override
69  UnmodifiableIterator<Entry<E>> entryIterator() {
70    return Iterators.emptyIterator();
71  }
72
73  @Override
74  public ImmutableSortedMultiset<E> headMultiset(E upperBound, BoundType boundType) {
75    checkNotNull(upperBound);
76    checkNotNull(boundType);
77    return this;
78  }
79
80  @Override
81  public ImmutableSortedMultiset<E> tailMultiset(E lowerBound, BoundType boundType) {
82    checkNotNull(lowerBound);
83    checkNotNull(boundType);
84    return this;
85  }
86
87  @Override
88  int distinctElements() {
89    return 0;
90  }
91
92  @Override
93  boolean isPartialView() {
94    return false;
95  }
96}
97