Coverage Summary for Class: IndexedImmutableSet (com.google.common.collect)

Class Method, % Line, %
IndexedImmutableSet 50% (3/6) 30% (3/10)
IndexedImmutableSet$1 60% (3/5) 60% (3/5)
Total 54.5% (6/11) 40% (6/15)


1 /* 2  * Copyright (C) 2018 The Guava Authors 3  * 4  * Licensed under the Apache License, Version 2.0 (the "License"); 5  * you may not use this file except in compliance with the License. 6  * You may obtain a copy of the License at 7  * 8  * http://www.apache.org/licenses/LICENSE-2.0 9  * 10  * Unless required by applicable law or agreed to in writing, software 11  * distributed under the License is distributed on an "AS IS" BASIS, 12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13  * See the License for the specific language governing permissions and 14  * limitations under the License. 15  */ 16  17 package com.google.common.collect; 18  19 import static com.google.common.base.Preconditions.checkNotNull; 20  21 import com.google.common.annotations.GwtCompatible; 22 import com.google.common.annotations.GwtIncompatible; 23 import java.util.Spliterator; 24 import java.util.function.Consumer; 25 import org.checkerframework.checker.nullness.qual.Nullable; 26  27 @GwtCompatible(emulated = true) 28 @ElementTypesAreNonnullByDefault 29 abstract class IndexedImmutableSet<E> extends ImmutableSet<E> { 30  abstract E get(int index); 31  32  @Override 33  public UnmodifiableIterator<E> iterator() { 34  return asList().iterator(); 35  } 36  37  @Override 38  public Spliterator<E> spliterator() { 39  return CollectSpliterators.indexed(size(), SPLITERATOR_CHARACTERISTICS, this::get); 40  } 41  42  @Override 43  public void forEach(Consumer<? super E> consumer) { 44  checkNotNull(consumer); 45  int n = size(); 46  for (int i = 0; i < n; i++) { 47  consumer.accept(get(i)); 48  } 49  } 50  51  @Override 52  @GwtIncompatible 53  int copyIntoArray(@Nullable Object[] dst, int offset) { 54  return asList().copyIntoArray(dst, offset); 55  } 56  57  @Override 58  ImmutableList<E> createAsList() { 59  return new ImmutableAsList<E>() { 60  @Override 61  public E get(int index) { 62  return IndexedImmutableSet.this.get(index); 63  } 64  65  @Override 66  boolean isPartialView() { 67  return IndexedImmutableSet.this.isPartialView(); 68  } 69  70  @Override 71  public int size() { 72  return IndexedImmutableSet.this.size(); 73  } 74  75  @Override 76  ImmutableCollection<E> delegateCollection() { 77  return IndexedImmutableSet.this; 78  } 79  }; 80  } 81 }