Package net.hydromatic.morel.util
Class ConsList<E>
- java.lang.Object
-
- net.hydromatic.morel.util.AbstractImmutableList<E>
-
- net.hydromatic.morel.util.ConsList<E>
-
- Type Parameters:
E- Element type
- All Implemented Interfaces:
java.lang.Iterable<E>,java.util.Collection<E>,java.util.List<E>
public class ConsList<E> extends AbstractImmutableList<E>
List that consists of a head element and an immutable non-empty list.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object o)Eget(int index)inthashCode()intindexOf(java.lang.Object o)java.util.Iterator<E>iterator()intlastIndexOf(java.lang.Object o)java.util.ListIterator<E>listIterator()java.util.ListIterator<E>listIterator(int index)static <E> java.util.List<E>of(E first, java.util.List<? extends E> rest)Creates a ConsList.intsize()java.lang.Object[]toArray()<T> T[]toArray(T[] a)protected java.util.List<E>toList()java.lang.StringtoString()-
Methods inherited from class net.hydromatic.morel.util.AbstractImmutableList
add, add, addAll, addAll, clear, contains, containsAll, isEmpty, remove, remove, removeAll, retainAll, set, subList
-
-
-
-
Method Detail
-
of
public static <E> java.util.List<E> of(E first, java.util.List<? extends E> rest)Creates a ConsList. It consists of an element pre-pended to another list. If the other list is mutable, creates an immutable copy.
-
get
public E get(int index)
-
size
public int size()
-
hashCode
public int hashCode()
-
equals
public boolean equals(java.lang.Object o)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
toList
protected final java.util.List<E> toList()
- Specified by:
toListin classAbstractImmutableList<E>
-
listIterator
@Nonnull public java.util.ListIterator<E> listIterator()
- Specified by:
listIteratorin interfacejava.util.List<E>- Overrides:
listIteratorin classAbstractImmutableList<E>
-
iterator
@Nonnull public java.util.Iterator<E> iterator()
-
listIterator
@Nonnull public java.util.ListIterator<E> listIterator(int index)
- Specified by:
listIteratorin interfacejava.util.List<E>- Overrides:
listIteratorin classAbstractImmutableList<E>
-
toArray
@Nonnull public java.lang.Object[] toArray()
-
toArray
@Nonnull public <T> T[] toArray(@Nonnull T[] a)
-
indexOf
public int indexOf(java.lang.Object o)
-
lastIndexOf
public int lastIndexOf(java.lang.Object o)
-
-