Coverage Report - org.apache.giraph.types.ops.collections.WCollection
 
Classes in this File Line Coverage Branch Coverage Complexity
WCollection
N/A
N/A
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  
 package org.apache.giraph.types.ops.collections;
 19  
 
 20  
 import java.io.DataInput;
 21  
 import java.io.DataOutput;
 22  
 import java.io.IOException;
 23  
 
 24  
 import org.apache.giraph.function.Consumer;
 25  
 import org.apache.giraph.function.Predicate;
 26  
 import org.apache.giraph.types.ops.PrimitiveTypeOps;
 27  
 import org.apache.hadoop.io.Writable;
 28  
 
 29  
 /**
 30  
  * Collection over mutable elements, which are probably
 31  
  * internally stored differently/efficiently, and are accessed
 32  
  * through methods providing "return" value.
 33  
  *
 34  
  * @param <T> Element type
 35  
  */
 36  
 public interface WCollection<T> extends Writable {
 37  
   /** Removes all of the elements from this  */
 38  
   void clear();
 39  
   /**
 40  
    * Number of elements in this list
 41  
    * @return size
 42  
    */
 43  
   int size();
 44  
   /**
 45  
    * Capacity of currently allocated memory
 46  
    * @return capacity
 47  
    */
 48  
   int capacity();
 49  
   /**
 50  
    * Forces allocated memory to hold exactly N values
 51  
    * @param n new capacity
 52  
    */
 53  
   void setCapacity(int n);
 54  
   /**
 55  
    * Add value to the collection
 56  
    * @param value Value
 57  
    */
 58  
   void addW(T value);
 59  
   /**
 60  
    * TypeOps for type of elements this object holds
 61  
    * @return TypeOps
 62  
    */
 63  
   PrimitiveTypeOps<T> getElementTypeOps();
 64  
   /**
 65  
    * Fast iterator over collection objects, which doesn't allocate new
 66  
    * element for each returned element, and can be iterated multiple times
 67  
    * using reset().
 68  
    *
 69  
    * Object returned by next() is only valid until next() is called again,
 70  
    * because it is reused.
 71  
    *
 72  
    * @return RessettableIterator
 73  
    */
 74  
   ResettableIterator<T> fastIteratorW();
 75  
   /**
 76  
    * Fast iterator over collection objects, which doesn't allocate new
 77  
    * element for each returned element, and can be iterated multiple times
 78  
    * using reset().
 79  
    *
 80  
    * Each call to next() populates passed value.
 81  
    *
 82  
    * @param iterationValue Value that call to next() will populate
 83  
    * @return RessettableIterator
 84  
    */
 85  
   ResettableIterator<T> fastIteratorW(T iterationValue);
 86  
   /**
 87  
    * Traverse all elements of the collection, calling given function on each
 88  
    * element. Passed values are valid only during the call to the passed
 89  
    * function, so data needs to be consumed during the function.
 90  
    *
 91  
    * @param f Function to call on each element.
 92  
    */
 93  
   void fastForEachW(Consumer<T> f);
 94  
   /**
 95  
    * Traverse all elements of the collection, calling given function on each
 96  
    * element, or until predicate returns false.
 97  
    * Passed values are valid only during the call to the passed
 98  
    * function, so data needs to be consumed during the function.
 99  
    *
 100  
    * @param f Function to call on each element.
 101  
    * @return true if the predicate returned true for all elements,
 102  
    *    false if it returned false for some element.
 103  
    */
 104  
   boolean fastForEachWhileW(Predicate<T> f);
 105  
   /**
 106  
    * Write elements to the DataOutput stream, without the size itself.
 107  
    * Can be read back using readElements function.
 108  
    *
 109  
    * @param out Data output
 110  
    */
 111  
   void writeElements(DataOutput out) throws IOException;
 112  
   /**
 113  
    * Read elements from DataInput stream, with passing the size instead
 114  
    * reading it from the stream.
 115  
    *
 116  
    * @param in Data Input
 117  
    * @param size Number of elements
 118  
    */
 119  
   void readElements(DataInput in, int size) throws IOException;
 120  
 }