package coll;
/* Immutable Collection
 * by Martin Robinson
 * \__________________/
 *       /
 * \ ('<
 * (<=)
 * */

/*
 * List interface
 * all classe must obey
 * to this patern, so
 * they can be mixed up
 * together without
 * distinction.
 * \_________________/
 *      /
 * \ ('<
 * (<=)
 * */
import java.util.Iterator;

/**
 * @author martin
 * immutable list interface
 * @param <E>
 */
public interface Lst<E> extends Iterable<E> {
	/**
	 * get element from given index
	 * @param i as index
	 * @return element or null if not exist
	 */
	public E get(int i);
	/**
	 * get the size of the list
	 * @return size as int
	 */
	public int size();
	/**
	 * return last modification
	 * @return
	 */
	public Lst<E> undo();
	/**
	 * set value at given index
	 * @param i as index
	 * @param data as data to set
	 * @return new list with applied modification
	 * @throws Exception if index is out of bound
	 */
	public Lst<E> set(int i, final E data);
	/**
	 * add value at the end of the list
	 * @param data as value to add
	 * @return new list  with applied modification
	 * @throws Exception ... but wont throw exception
	 */
	public Lst<E> append(final E data);
	/**
	 * remove value and shrink the list
	 * @param index to remove
	 * @return new list  with applied modification
	 * @throws Exception if index is out of bound
	 */
	public Lst<E> remove(int index);
	/**
	 * add value at given index, expand the list
	 * @param index as int
	 * @param data as data to add
	 * @return new list with applied modification
	 * @throws Exception if index is out of bound
	 */
	public Lst<E> add(int index, final E data);
	/**
	 * make sublist from list
	 * @param from as start of the substring
	 * @param to as end of the substring
	 * @return new list who is a sub string of the first
	 * @throws Exception if index is out of bound or to is lower than from
	 */
	public Lst<E> sub(int from, int to);
	/**
	 * strip part of a list
	 * @param from as start of the strip
	 * @param to as end of the strip
	 * @return new list with applied modification
	 * @throws Exception if index is out of bound or to is lower than from
	 */
	public Lst<E> strip(int from, int to);
	/**
	 * insert lst into another
	 * @param from as start index
	 * @param to as end index
	 * @param insertion as lst to insert
	 * @return new list with applied modification
	 */
	public Lst<E> insert(int from, int to, final Lst<E> insertion);
	/**
	 * add value in front of the lst (increase size)
	 * @param val new val
	 * @return new list
	 */
	public Lst<E> push(final E val);
	/**
	 * pop like a stack
	 * @return new modified list
	 */
	public Lst<E> pop();
	/**
	 * limit the size of the list
	 * @param size as new size
	 * @return new modified list
	 */
	public Lst<E> limit(int size);
	/**
	 * get iterator from list
	 * @return iterator
	 */
	public Iterator<E> iterator();
}
