Difference between revisions of "ImmutableList Assignment"
Jump to navigation
Jump to search
Line 1: | Line 1: | ||
=Code To Implement= | =Code To Implement= | ||
==Utilities== | ==Utilities== | ||
+ | ===DefaultImmutableList<E>=== | ||
{{JavaToImplement|DefaultImmutableList|constructors<br/>head<br/>tail<br/>isEmpty<br/>|immutable.list.assignment}} | {{JavaToImplement|DefaultImmutableList|constructors<br/>head<br/>tail<br/>isEmpty<br/>|immutable.list.assignment}} | ||
class DefaultImmutableList implements [https://www.cse.wustl.edu/~cosgroved/courses/cse425s/spring20/apidocs/immutable/list/core/ImmutableList.html ImmutableList<E>] | class DefaultImmutableList implements [https://www.cse.wustl.edu/~cosgroved/courses/cse425s/spring20/apidocs/immutable/list/core/ImmutableList.html ImmutableList<E>] | ||
Line 8: | Line 9: | ||
Note: you need not implement iterator() now. That will be the subject of a future studio. | Note: you need not implement iterator() now. That will be the subject of a future studio. | ||
+ | ===Lists=== | ||
{{JavaToImplement|Lists|nil<br/>cons<br/>brackets<br/>|immutable.list.assignment}} | {{JavaToImplement|Lists|nil<br/>cons<br/>brackets<br/>|immutable.list.assignment}} | ||
+ | |||
+ | ====nil==== | ||
+ | <pre>public static <E> ImmutableList<E> nil()</pre> | ||
+ | |||
+ | ====cons==== | ||
+ | <pre>public static <E> ImmutableList<E> cons(E head, ImmutableList<E> tail)</pre> | ||
+ | |||
+ | ====brackets==== | ||
+ | <pre>public static <E> ImmutableList<E> brackets(E... elements)</pre> | ||
==Apps== | ==Apps== |
Revision as of 22:51, 17 January 2020
Contents
Code To Implement
Utilities
DefaultImmutableList<E>
class: | DefaultImmutableList.java | |
methods: | constructors head tail isEmpty |
|
package: | immutable.list.assignment | |
source folder: | src/main/java |
class DefaultImmutableList implements ImmutableList<E>
Note: consider using java.util.Optional
Note: you need not implement iterator() now. That will be the subject of a future studio.
Lists
class: | Lists.java | |
methods: | nil cons brackets |
|
package: | immutable.list.assignment | |
source folder: | src/main/java |
nil
public static <E> ImmutableList<E> nil()
cons
public static <E> ImmutableList<E> cons(E head, ImmutableList<E> tail)
brackets
public static <E> ImmutableList<E> brackets(E... elements)
Apps
Length
class: | Length.java | |
methods: | length | |
package: | immutable.list.apps.assignment | |
source folder: | src/main/java |
public static <E> int length(ImmutableList<E> list)
SumProductCountdownFactorial
class: | SumProductCountdownFactorial.java | |
methods: | sum product countdown factorial |
|
package: | immutable.list.apps.assignment | |
source folder: | src/main/java |
sum
public static int sum(ImmutableList<Integer> xs)
product
public static int product(ImmutableList<Integer> xs)
countdown
public static ImmutableList<Integer> countdown(int n)
factorial
public static int factorial(int n)
Concat
class: | Concat.java | |
methods: | concat | |
package: | immutable.list.apps.assignment | |
source folder: | src/main/java |
public static <E> ImmutableList<E> concat(ImmutableList<E> xs, ImmutableList<E> ys)
Test
class: | ImmutableListTestSuite.java | |
package: | immutable.list.assignment | |
source folder: | src/test/java |