| 
 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectuniverse.List<X>
public abstract class List<X>
Represents Lisp style Lists. List.create(...) should be used to create lists, and push/pop/top/etc... to pull them apart. All methods are functional, meaning a given list is an immutable data type: methods return a new list, they do not change the old one. The methods can be used to write beautiful recursive functions :) The inner classes (Build, Comp, GComp, Fold, Map, Pred, and Zip) are Function Classes that allow you to implement needed functionalities over basic traversals/iteration. This implementation has been updated to eliminate stack usage, which allows you (the programmer) to create HUGE lists without any problems ;)
| Nested Class Summary | |
|---|---|
| static class | List.Build<X>Build a List from the sequence of integers [0..len-1] | 
| static class | List.Comp<X>Compare two List Elements of the same type | 
| static class | List.Fold<X,Y>Fold the List into a single Value | 
| static class | List.GComp<X,Y>(General) Compare two List Elements of possibly different types (true is "LessThan" for sort(), but "Equal" for same(...)) | 
| static class | List.Map<X,Y>Apply a function to each element of the list | 
| static class | List.Pred<X>Select Elements of a List | 
| static class | List.Stringer<X>Compute a String from a List (Visitor) | 
| static class | List.Zip<X,Y,Z>Zip two Lists into a single Value | 
| Constructor Summary | |
|---|---|
| List(int l)Default Constructor | |
| Method Summary | ||
|---|---|---|
|  List<X> | add(X a,
    int i)Add an Element to this list at the given index | |
|  boolean | andmap(List.Pred<X> p)Does this Predicate match all the elements in this List? | |
|  List<X> | append(List<X> l)Append another List to the end of this List | |
|  List<X> | append(X x)Append an element to the end of this List | |
| static
 | buildlist(List.Build<X> b,
          int len)Build a list from the numbers 0..(len-1) | |
|  boolean | contains(List.Pred<X> p)Does this Predicate match anything in this List? | |
|  boolean | contains(X x)Does the given X occur in this List? | |
|  boolean | containsAll(List<X> l)Does this List contain all of the given List's Elements? | |
|  boolean | containsAll(List<X> l,
            List.Comp<X> c)Does this List contain all of the given List's Elements using the given comparer? | |
| 
 | containsAllG(List<Y> l,
             List.GComp<X,Y> c)Does this List contain all of the given List's Elements using the given comparer? | |
|  boolean | containsAny(List<X> l)Does this List contain any of the given List's Elements? | |
|  boolean | containsAny(List<X> l,
            List.Comp<X> c)Does this List contain any of the given List's Elements using the given comparer? | |
| 
 | containsAnyG(List<Y> l,
             List.GComp<X,Y> c)Does this List contain any of the given List's Elements using the given comparer? | |
| 
 | containsG(Y y,
          List.GComp<X,Y> c)Does the given X occur in this List? | |
|  int | count(List.Pred<X> p)Count the elements that match the given Predicate | |
| static
 | create()Create an Empty List | |
| static
 | create(java.lang.Iterable<X> xs)Create a List from an Iterable... | |
| static
 | create(X... xa)Create a List from an array/variable arguments | |
| static
 | create(X x)Create a List from a single argument | |
| static
 | create(X[] xa,
       int i)Create a List from a fixed array, starting at index 'i' | |
| abstract  boolean | equals(java.lang.Object o)Equals for Lists... | |
|  List<X> | filter(List.Pred<X> p)Filter out all the non-matching Elements | |
|  List<X> | filter(X x)Filter out all the non-same Elements | |
|  List<X> | filterout(List.Pred<X> p)Filter out all the matching Elements | |
|  List<X> | filterout(X x)Filter out all the same Elements | |
|  X | find(List.Pred<X> p)Return the first matching X, throws a RuntimeException if not there | |
|  X | find(X x)Return the given X, throws a RuntimeException if not there | |
| 
 | findG(Y y,
      List.GComp<X,Y> c)Return the given X, throws a RuntimeException if not there | |
| 
 | fold(List.Fold<X,Y> f,
     Y b)Fold this List to a single Value (Left to Right) | |
| 
 | foldl(List.Fold<X,Y> f,
      Y b)Fold this List to a single Value (Left to Right) | |
| 
 | foldr(List.Fold<X,Y> f,
      Y b)Fold this List to a single Value (Right to Left) | |
| abstract  int | hashCode()HashCode for Lists... | |
|  int | index(List.Pred<X> p)Return the Index of the first match | |
|  int | index(X x)Return the Index of the given element | |
|  List<X> | insert(java.lang.Iterable<X> xs,
       List.Comp<X> c)Insert a number of Elements into this SORTED list | |
|  List<X> | insert(X a,
       List.Comp<X> c)Insert an Element into this SORTED list using the given Comparison | |
|  List<X> | insertionSort(List.Comp<X> c)Sort this List using Insertion Sort | |
| abstract  boolean | isEmpty()Is this List Empty? | |
|  java.util.Iterator<X> | iterator()Return an Iterator for this list | |
|  int | length()The Length of This List | |
|  X | lookup(int i)Lookup the i^th item in this List | |
| static void | main(java.lang.String[] args) | |
| 
 | map(List.Map<X,Y> m)Apply a function to each Element of this List | |
|  boolean | ormap(List.Pred<X> p)Does this Predicate match any element in this List? | |
| abstract  List<X> | pop()Return this List without the first Element | |
|  List<X> | pop(int k)Return this List without the first k Elements | |
|  List<X> | push(List<X> xs)Push all Elements of the given List on the front of this List | |
|  List<X> | push(X x)Push a X on the front of this List | |
|  List<X> | remove(int i)Remove an Element from this list at the given index | |
|  List<X> | remove(List.Pred<X> p)Remove the first matching X | |
|  List<X> | remove(X x)Remove the first occurence of the given X | |
|  List<X> | removeDuplicates()Remove duplicate items from this list | |
|  List<X> | removeDuplicates(List.Comp<X> c)Remove duplicate items from this list | |
| 
 | removeG(Y y,
        List.GComp<X,Y> c)Remove the first occurence of the given X | |
|  List<X> | replace(int i,
        X s)Replace the element at index 'i' with 's' | |
|  List<X> | replace(List.Pred<X> p,
        X s)Replace the first matching X with 's' | |
|  List<X> | replace(X t,
        X s)Replace the first occurrence of 't' with 's' | |
|  List<X> | replaceAll(List.Pred<X> p,
           X x)Replace all matching Xs with 't' | |
|  List<X> | replaceAll(X t,
           X s)Replace all occurrences of 't' with 's' | |
|  List<X> | reverse()Reverse this List | |
|  List<X> | reverse(int i)Reverse the first i elements of this List | |
|  boolean | same(List<X> l)Is the given list have the same elements as this list? | |
|  boolean | same(List<X> l,
     List.Comp<X> c)Is the given list have the same elements as this list using the given comparer? | |
| 
 | sameG(List<Y> l,
      List.GComp<X,Y> c)Is the given list have the same elements as this list using the given comparer? | |
|  List<X> | shuffle()Shuffle the elements of this list randomly | |
|  List<X> | sort(List.Comp<X> c)Sort this List using the given Comparison | |
|  List<X> | sublist(int i,
        int k)Return a sublist, starting at index i, with length k | |
|  X[] | toArray(X[] arr)Convert this List into an Array, starting at Index 'i' | |
|  java.util.List<X> | toJavaList()Convert this List into a java.util.List | |
| abstract  X | top()Return the first Element of this List | |
|  java.lang.String | toString()Canonical ToString | |
|  java.lang.String | toString(List.Stringer<X> s)To String using a Stringer (Visitor) | |
|  java.lang.String | toString(java.lang.String sep,
         java.lang.String pre)To String, with a separator and prefix | |
| 
 | zip(List.Zip<X,Y,Z> z,
    List<Y> ys)Zip two lists (this, and 'l') into a single list, one element at a time | |
| Methods inherited from class java.lang.Object | 
|---|
| getClass, notify, notifyAll, wait, wait, wait | 
| Constructor Detail | 
|---|
public List(int l)
| Method Detail | 
|---|
public static void main(java.lang.String[] args)
public static <X> List<X> create()
public static <X> List<X> create(X x)
public static <X> List<X> create(X... xa)
public static <X> List<X> create(X[] xa,
                                 int i)
public static <X> List<X> create(java.lang.Iterable<X> xs)
public List<X> push(X x)
public List<X> push(List<X> xs)
public List<X> reverse()
public List<X> reverse(int i)
public java.lang.String toString()
toString in class java.lang.Objectpublic int index(X x)
public int index(List.Pred<X> p)
public boolean same(List<X> l)
public boolean same(List<X> l,
                    List.Comp<X> c)
public <Y> boolean sameG(List<Y> l,
                         List.GComp<X,Y> c)
public List<X> pop(int k)
public List<X> append(List<X> l)
public List<X> append(X x)
public abstract X top()
public abstract List<X> pop()
public abstract boolean isEmpty()
public boolean ormap(List.Pred<X> p)
public boolean andmap(List.Pred<X> p)
public boolean contains(X x)
public boolean contains(List.Pred<X> p)
public <Y> boolean containsG(Y y,
                             List.GComp<X,Y> c)
public boolean containsAny(List<X> l)
public boolean containsAny(List<X> l,
                           List.Comp<X> c)
public <Y> boolean containsAnyG(List<Y> l,
                                List.GComp<X,Y> c)
public boolean containsAll(List<X> l)
public boolean containsAll(List<X> l,
                           List.Comp<X> c)
public <Y> boolean containsAllG(List<Y> l,
                                List.GComp<X,Y> c)
public X find(X x)
public X find(List.Pred<X> p)
public <Y> X findG(Y y,
                   List.GComp<X,Y> c)
public List<X> remove(X x)
public <Y> List<X> removeG(Y y,
                           List.GComp<X,Y> c)
public List<X> remove(List.Pred<X> p)
public int length()
public X lookup(int i)
public java.lang.String toString(java.lang.String sep,
                                 java.lang.String pre)
public java.lang.String toString(List.Stringer<X> s)
public List<X> filterout(X x)
public List<X> filterout(List.Pred<X> p)
public List<X> filter(X x)
public List<X> filter(List.Pred<X> p)
public int count(List.Pred<X> p)
public List<X> removeDuplicates()
public List<X> removeDuplicates(List.Comp<X> c)
public <Y> Y fold(List.Fold<X,Y> f,
                  Y b)
public <Y> Y foldl(List.Fold<X,Y> f,
                   Y b)
public <Y> Y foldr(List.Fold<X,Y> f,
                   Y b)
public <Y> List<Y> map(List.Map<X,Y> m)
public List<X> add(X a,
                   int i)
public List<X> remove(int i)
public List<X> insert(java.lang.Iterable<X> xs,
                      List.Comp<X> c)
public List<X> insert(X a,
                      List.Comp<X> c)
public List<X> sort(List.Comp<X> c)
public List<X> insertionSort(List.Comp<X> c)
public X[] toArray(X[] arr)
public java.util.Iterator<X> iterator()
iterator in interface java.lang.Iterable<X>
public <Y,Z> List<Z> zip(List.Zip<X,Y,Z> z,
                         List<Y> ys)
public static <X> List<X> buildlist(List.Build<X> b,
                                    int len)
public List<X> replace(int i,
                       X s)
public List<X> replace(X t,
                       X s)
public List<X> replace(List.Pred<X> p,
                       X s)
public List<X> replaceAll(X t,
                          X s)
public List<X> replaceAll(List.Pred<X> p,
                          X x)
public abstract boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic abstract int hashCode()
hashCode in class java.lang.Objectpublic java.util.List<X> toJavaList()
public List<X> sublist(int i,
                       int k)
public List<X> shuffle()
| 
 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||