Coverage Report - org.apache.giraph.utils.UnmodifiableIntArrayIterator
 
Classes in this File Line Coverage Branch Coverage Complexity
UnmodifiableIntArrayIterator
100%
7/7
100%
2/2
1
 
 1  
 /*
 2  
  * Licensed to the Apache Software Foundation (ASF) under one
 3  
  * or more contributor license agreements.  See the NOTICE file
 4  
  * distributed with this work for additional information
 5  
  * regarding copyright ownership.  The ASF licenses this file
 6  
  * to you under the Apache License, Version 2.0 (the
 7  
  * "License"); you may not use this file except in compliance
 8  
  * with the License.  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  
 
 19  
 package org.apache.giraph.utils;
 20  
 
 21  
 import com.google.common.collect.UnmodifiableIterator;
 22  
 import org.apache.hadoop.io.IntWritable;
 23  
 
 24  
 /**
 25  
  * {@link UnmodifiableIterator} over a primitive int array
 26  
  */
 27  212
 public class UnmodifiableIntArrayIterator extends
 28  
     UnmodifiableIterator<IntWritable> {
 29  
   /** Array to iterate over */
 30  
   private final int[] intArray;
 31  
   /** Offset to array */
 32  
   private int offset;
 33  
 
 34  
   /**
 35  
    * Constructor with array to iterate over.
 36  
    *
 37  
    * @param intArray Array to iterate over.
 38  
    */
 39  211
   public UnmodifiableIntArrayIterator(int[] intArray) {
 40  211
     this.intArray = intArray;
 41  211
     offset = 0;
 42  211
   }
 43  
 
 44  
   @Override
 45  
   public boolean hasNext() {
 46  423
     return offset < intArray.length;
 47  
   }
 48  
 
 49  
   @Override
 50  
   public IntWritable next() {
 51  212
     return new IntWritable(intArray[offset++]);
 52  
   }
 53  
 }