All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.sf.javagimmicks.collections8.Ring Maven / Gradle / Ivy

There is a newer version: 0.99-alpha1
Show newest version
package net.sf.javagimmicks.collections8;

import java.util.Collection;
import java.util.Iterator;

/**
 * Defines a {@link Collection}-like data structure that organizes elements
 * within a ring structure, so there is a well-defined order but no index,
 * beginning or end.
 * 

* The interface fully extends the {@link Collection} interface but additionally * extends {@link RingCursorProvider} that allows to create a {@link RingCursor} * for it which is a special kind of iterator that defines no beginning or end * but operations to modify or traverse the underlying data structure. * * @param * the type of elements this {@link Ring} can contain */ public interface Ring extends Collection, RingCursorProvider { @Override default boolean add(final E value) { // Get the initial RingCursor add the element before the current position // (this means at the 'end' of the ring) cursor().insertBefore(value); return true; } @Override default boolean addAll(final Collection collection) { // Get the initial RingCursor add the elements before the current position // (this means at the 'end' of the ring) cursor().insertBefore(collection); return true; } @Override default Iterator iterator() { return cursor().iterator(); } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy