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 org.apache.hadoop.io.WritableComparable; 22 23 /** 24 * Common implementation for VertexIdEdgeIterator, VertexIdMessageIterator 25 * and VertexIdMessageBytesIterator. 26 * 27 * @param <I> Vertex id 28 */ 29 public interface VertexIdIterator<I extends WritableComparable> { 30 /** 31 * Returns true if the iteration has more elements. 32 * 33 * @return True if the iteration has more elements. 34 */ 35 boolean hasNext(); 36 37 /** 38 * Moves to the next element in the iteration. 39 */ 40 void next(); 41 42 /** 43 * Get the current vertex id. Ihis object's contents are only guaranteed 44 * until next() is called. To take ownership of this object call 45 * releaseCurrentVertexId() after getting a reference to this object. 46 * 47 * @return Current vertex id 48 */ 49 I getCurrentVertexId(); 50 51 /** 52 * The backing store of the current vertex id is now released. 53 * Further calls to getCurrentVertexId () without calling next() 54 * will return null. 55 * 56 * @return Current vertex id that was released 57 */ 58 I releaseCurrentVertexId(); 59 } 60