org.eclipse.xtext.nodemodel.BidiIterable Maven / Gradle / Ivy
/*******************************************************************************
* Copyright (c) 2010 itemis AG (http://www.itemis.eu) and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*******************************************************************************/
package org.eclipse.xtext.nodemodel;
/**
* An iterable that is capable of being iterated in both directions - forwards and backwards.
* @author Sebastian Zarnekow - Initial contribution and API
*/
public interface BidiIterable extends Iterable {
/**
* Returns an iterator that can be used forwards and backwards.
* @return an iterator. Never returns null
.
*/
BidiIterator iterator();
/**
* Returns a reverse version of this iterable that can be used
* forwards and backwards. In other words, an iterator provided by
* the reverse iterable will delegate its {@link BidiIterator#hasNext() hasNext()}
* and {@link BidiIterator#next() next()} invocations to
* {@link BidiIterator#hasPrevious()} and {@link BidiIterator#previous()}
* respectively.
*
* This allows clients to iterate backwards by means of the enhanced
* for-loop:
*
* for(T t: iterable.reverse()) {
* // do something with t
* }
*
*
* @return the reversed iterable. Never returns null
.
*/
BidiIterable reverse();
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy