de.tfhberlin.panitz.eliza
Class Li

java.lang.Object
  |
  +--de.tfhberlin.panitz.eliza.Li
Direct Known Subclasses:
MyList

public abstract class Li
extends java.lang.Object

An abstract description of a simple linked list.


Constructor Summary
Li()
           
 
Method Summary
abstract  de.tfhberlin.panitz.eliza.Li cons(java.lang.Object x, de.tfhberlin.panitz.eliza.Li xs)
          Constructs a new list by adding an element in front of an existing list.
abstract  de.tfhberlin.panitz.eliza.Li drop(int i)
          Removes the first i elements from a list.
abstract  de.tfhberlin.panitz.eliza.Li empty()
          Constructs a new empty list.
abstract  java.lang.Object head()
          Returns the first element of this list.
abstract  boolean isEmpty()
          Tests, if the list contains some element.
abstract  boolean isPrefixIgnoreCaseOf(de.tfhberlin.panitz.eliza.Li other)
          Tests if this list of Strings is a prefix of the other list of Strings.
abstract  de.tfhberlin.panitz.eliza.Li reverse()
          Reverses the element order of the list.
abstract  void rotate()
          Mutates this list, by appending first element as last.
abstract  de.tfhberlin.panitz.eliza.Li tail()
          Returns the list after the first element has been skipped.
abstract  de.tfhberlin.panitz.eliza.Li tails()
          Makes a list of lists of all taillists.
 java.lang.String toString()
           
abstract  java.lang.String unwords()
          Makes a list of String to a String.
abstract  de.tfhberlin.panitz.eliza.Li words(java.lang.String str)
          Produces a list of the words within a String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Li

public Li()
Method Detail

empty

public abstract de.tfhberlin.panitz.eliza.Li empty()
Constructs a new empty list.

Returns:
a newly created empty list.

cons

public abstract de.tfhberlin.panitz.eliza.Li cons(java.lang.Object x,
                                                  de.tfhberlin.panitz.eliza.Li xs)
Constructs a new list by adding an element in front of an existing list.

Parameters:
x - the first element for the new list.
xs - the tail for the new list.
Returns:
a newly created list.

isEmpty

public abstract boolean isEmpty()
Tests, if the list contains some element.

Returns:
true if no element is contained in the list.

head

public abstract java.lang.Object head()
Returns the first element of this list.

Returns:
from element.

tail

public abstract de.tfhberlin.panitz.eliza.Li tail()
Returns the list after the first element has been skipped.

Returns:
the tail (rest) of the list, which follows first element.

tails

public abstract de.tfhberlin.panitz.eliza.Li tails()
Makes a list of lists of all taillists. example: for the list ("this","is","a","test") this produces: (("this","is","a","test"),("is","a","test"),("a","test"),("test"))

Returns:
a list of lists, which contains all list obtained from this list through several calls of tail().

drop

public abstract de.tfhberlin.panitz.eliza.Li drop(int i)
Removes the first i elements from a list.

Parameters:
i - a positive number of elements to be skipped from the beginning of the list.
Returns:
this list with i elements droped by tail calls.

reverse

public abstract de.tfhberlin.panitz.eliza.Li reverse()
Reverses the element order of the list. example: ("a","b","c") gets ("c","b","a")

Returns:
a new list with reversed element order of this list.

words

public abstract de.tfhberlin.panitz.eliza.Li words(java.lang.String str)
Produces a list of the words within a String. The String is splitted at white-space characters. The words in the result list will not contain any shite space characters. Example: words("this is a test") produces the list: ("this","is","a","test")

Parameters:
str - the string, which is to be splitted into words
Returns:
a list of Strings, which are the words of the input.

unwords

public abstract java.lang.String unwords()
Makes a list of String to a String. This is a reverse function to words. example: unwords for a list: ("this","is","a","test") produces the String: "this is a test"

Returns:
a string which concatenates the Strings of this list with whitespace chareacters.

isPrefixIgnoreCaseOf

public abstract boolean isPrefixIgnoreCaseOf(de.tfhberlin.panitz.eliza.Li other)
Tests if this list of Strings is a prefix of the other list of Strings. The lists are supposed to be list of strings. The test is to be made case insensetive. example: ("tHIs","is") is prefix of ("this","iS","a","test") if cases are ignored.

Parameters:
other - the List of Strings, which is tested ,if it extends this List of Strings.
Returns:
true, if this list prefixes the other list.

rotate

public abstract void rotate()
Mutates this list, by appending first element as last.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object