Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright (C) 2011 The Guava Authors
   * 
   * Licensed under the Apache License, Version 2.0 (the "License"); you may not
   * use this file except in compliance with the License. You may obtain a copy of
   * the License at
   * 
   * http://www.apache.org/licenses/LICENSE-2.0
   * 
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  * License for the specific language governing permissions and limitations under
  * the License.
  */
 
 package com.google.common.collect;
 
 
A com.google.common.collect.Multiset which maintains the ordering of its elements, according to either their natural order or an explicit java.util.Comparator. In all cases, this implementation uses java.lang.Comparable.compareTo(java.lang.Object) or java.util.Comparator.compare(java.lang.Object,java.lang.Object) instead of java.lang.Object.equals(java.lang.Object) to determine equivalence of instances.

Warning: The comparison must be consistent with equals as explained by the java.lang.Comparable class specification. Otherwise, the resulting multiset will violate the java.util.Collection contract, which it is specified in terms of java.lang.Object.equals(java.lang.Object).

See the Guava User Guide article on Multiset.

Author(s):
Louis Wasserman
Since:
11.0
 
 public interface SortedMultiset<E> extends Multiset<E>, SortedIterable<E> {
  
Returns the comparator that orders this multiset, or Ordering.natural() if the natural ordering of the elements is used.
 
   Comparator<? super E> comparator();

  
Returns the entry of the first element in this multiset, or null if this multiset is empty.
 
   Entry<E> firstEntry();

  
Returns the entry of the last element in this multiset, or null if this multiset is empty.
 
   Entry<E> lastEntry();

  
Returns and removes the entry associated with the lowest element in this multiset, or returns null if this multiset is empty.
 
   Entry<E> pollFirstEntry();

  
Returns and removes the entry associated with the greatest element in this multiset, or returns null if this multiset is empty.
 
   Entry<E> pollLastEntry();

  
Returns a java.util.SortedSet view of the distinct elements in this multiset.
 
   @Override SortedSet<E> elementSet();

  

The iterator returns the elements in ascending order according to this multiset's comparator.

 
   @Override Iterator<E> iterator();

  
Returns a descending view of this multiset. Modifications made to either map will be reflected in the other.
 
Returns a view of this multiset restricted to the elements less than upperBound, optionally including upperBound itself. The returned multiset is a view of this multiset, so changes to one will be reflected in the other. The returned multiset supports all operations that this multiset supports.

The returned multiset will throw an java.lang.IllegalArgumentException on attempts to add elements outside its range.

  SortedMultiset<E> headMultiset(E upperBoundBoundType boundType);

  
Returns a view of this multiset restricted to the range between lowerBound and upperBound. The returned multiset is a view of this multiset, so changes to one will be reflected in the other. The returned multiset supports all operations that this multiset supports.

The returned multiset will throw an java.lang.IllegalArgumentException on attempts to add elements outside its range.

This method is equivalent to tailMultiset(lowerBound, lowerBoundType).headMultiset(upperBound, upperBoundType).

  SortedMultiset<E> subMultiset(E lowerBoundBoundType lowerBoundType,
      E upperBoundBoundType upperBoundType);

  
Returns a view of this multiset restricted to the elements greater than lowerBound, optionally including lowerBound itself. The returned multiset is a view of this multiset, so changes to one will be reflected in the other. The returned multiset supports all operations that this multiset supports.

The returned multiset will throw an java.lang.IllegalArgumentException on attempts to add elements outside its range.

  SortedMultiset<E> tailMultiset(E lowerBoundBoundType boundType);
New to GrepCode? Check out our FAQ X