EMMA Coverage Report (generated Wed Aug 10 12:30:04 EDT 2011)
[all classes][org.jclouds.util]

COVERAGE SUMMARY FOR SOURCE FILE [Lists2.java]

nameclass, %method, %block, %line, %
Lists2.java100% (1/1)50%  (1/2)94%  (49/52)93%  (13/14)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class Lists2100% (1/1)50%  (1/2)94%  (49/52)93%  (13/14)
Lists2 (): void 0%   (0/1)0%   (0/3)0%   (0/1)
multiMax (Comparator, Iterable): List 100% (1/1)100% (49/49)100% (13/13)

1/**
2 *
3 * Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com>
4 *
5 * ====================================================================
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 * ====================================================================
18 */
19package org.jclouds.util;
20 
21import static com.google.common.collect.Lists.newArrayList;
22 
23import java.util.Comparator;
24import java.util.Iterator;
25import java.util.List;
26 
27 
28/**
29 * 
30 * @author Adrian Cole
31 */
32public class Lists2 {
33 
34   /**
35    * Like Ordering, but handle the case where there are multiple valid maximums
36    */
37   @SuppressWarnings("unchecked")
38   public static <T, E extends T> List<E> multiMax(Comparator<T> ordering, Iterable<E> iterable) {
39      Iterator<E> iterator = iterable.iterator();
40      List<E> maxes = newArrayList(iterator.next());
41      E maxSoFar = maxes.get(0);
42      while (iterator.hasNext()) {
43         E current = iterator.next();
44         int comparison = ordering.compare(maxSoFar, current);
45         if (comparison == 0) {
46            maxes.add(current);
47         } else if (comparison < 0) {
48            maxes = newArrayList(current);
49            maxSoFar = current;
50         }
51      }
52      return maxes;
53   }
54 
55}

[all classes][org.jclouds.util]
EMMA 2.0.5312 (C) Vladimir Roubtsov