TransformAdjacentIterator.java :  » Development » jga-Generic-Algorithms » net » sf » jga » util » Java Open Source

Java Open Source » Development » jga Generic Algorithms 
jga Generic Algorithms » net » sf » jga » util » TransformAdjacentIterator.java
// ============================================================================
// $Id: TransformAdjacentIterator.java,v 1.7 2006/05/22 03:36:36 davidahall Exp $
// Copyright (c) 2004-2005  David A. Hall
// ============================================================================
// The contents of this file are subject to the Common Development and
// Distribution License (CDDL), Version 1.0 (the License); you may not use this 
// file except in compliance with the License.  You should have received a copy
// of the the License along with this file: if not, a copy of the License is 
// available from Sun Microsystems, Inc.
//
// http://www.sun.com/cddl/cddl.html
//
// From time to time, the license steward (initially Sun Microsystems, Inc.) may
// publish revised and/or new versions of the License.  You may not use,  
// distribute, or otherwise make this file available under subsequent versions 
// of the License.
// 
// Alternatively, the contents of this file may be used under the terms of the 
// GNU Lesser General Public License Version 2.1 or later (the "LGPL"), in which
// case the provisions of the LGPL are applicable instead of those above. If you 
// wish to allow use of your version of this file only under the terms of the 
// LGPL, and not to allow others to use your version of this file under the 
// terms of the CDDL, indicate your decision by deleting the provisions above 
// and replace them with the notice and other provisions required by the LGPL. 
// If you do not delete the provisions above, a recipient may use your version 
// of this file under the terms of either the CDDL or the LGPL.
// 
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
// ============================================================================

package net.sf.jga.util;

import java.util.Iterator;
import java.util.NoSuchElementException;
import net.sf.jga.algorithms.Transform;
import net.sf.jga.fn.BinaryFunctor;

/**
 * Iterator that applies a given BinaryFunctor to successive pairs of elements
 * from a given iterator, returning the results as elements.
 * Note -- in addition to this class being deprecated in order to be moved,
 * its implementation of Iterable<T> is also deprecated: the successor class
 * will not implement Iterable<T>.
 * <p>
 * Copyright &copy; 2004-2005  David A. Hall
 *
 * @author <a href="mailto:davidahall@users.sourceforge.net">David A. Hall</a>
 * @deprecated moved to within Transform class: use Transform.TransformAdjacentIterator
 **/

public class TransformAdjacentIterator<T,R> extends Transform.AdjacentIterator<T,R>
    implements Iterable<R>
{

    /**
     * Builds a TransormAdjacentIterator that applies the given functor to
     * adjacent elements of the given base iterator.
     */
    public TransformAdjacentIterator(Iterator<? extends T> iter, BinaryFunctor<T,T,R> fn) {
        super(iter, fn);
    }

    // - - - - - - - - - - - -
    // Iterable implementation
    // - - - - - - - - - - - -
    
    /**
     * @deprecated the successor class will not implement Iterable<T>
     */
    public Iterator<R> iterator() { return this; }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.