Difference between revisions of "Iterable Immutable List Assignment"
Jump to navigation
Jump to search
(→nil) |
|||
Line 1: | Line 1: | ||
=Code To Implement= | =Code To Implement= | ||
+ | ==DefaultImmutableList== | ||
+ | {{JavaToImplement|DefaultImmutableList|head<br>tail<br>isEmpty<br>iterator|immutable.list.assignment}} | ||
+ | ===default constructor=== | ||
+ | ===head and tail constructor=== | ||
+ | ===head=== | ||
+ | ===tail=== | ||
+ | ===isEmpty=== | ||
+ | ===iterator=== | ||
+ | |||
==Lists== | ==Lists== | ||
{{JavaToImplement|Lists|nil<br>cons<br>brackets|immutable.list.assignment}} | {{JavaToImplement|Lists|nil<br>cons<br>brackets|immutable.list.assignment}} | ||
Line 14: | Line 23: | ||
<nowiki>@SafeVarargs | <nowiki>@SafeVarargs | ||
public static <E> ImmutableList<E> brackets(E... elements)</nowiki> | public static <E> ImmutableList<E> brackets(E... elements)</nowiki> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
=Test= | =Test= | ||
{{TestSuite|ListsTestSuite|immutable.list.assignment}} | {{TestSuite|ListsTestSuite|immutable.list.assignment}} |
Revision as of 17:24, 30 July 2019
Contents
Code To Implement
DefaultImmutableList
class: | DefaultImmutableList.java | ![]() |
methods: | head tail isEmpty iterator |
|
package: | immutable.list.assignment | |
source folder: | src/main/java |
default constructor
head and tail constructor
head
tail
isEmpty
iterator
Lists
class: | Lists.java | ![]() |
methods: | nil cons brackets |
|
package: | immutable.list.assignment | |
source folder: | src/main/java |
nil
public static <E> ImmutableList<E> nil()
Analogous to the SML List nil constructor.
Note: often SML programs use empty brackets []
instead of nil
.
cons
public static <E> ImmutableList<E> cons(E head, ImmutableList<E> tail)
brackets
@SafeVarargs public static <E> ImmutableList<E> brackets(E... elements)
Test
class: | ListsTestSuite.java | ![]() |
package: | immutable.list.assignment | |
source folder: | src/test/java |