Version 8 (modified by wouter, 5 years ago) ( diff )

--

ImmutableList

Maven include:

<dependency>
	<groupId>tudelft.utilities</groupId>
	<artifactId>immutablelist</artifactId>
	<version>1.0.1</version>
</dependency>

available on

<repository>
	<id>artifactory.ewi.tudelft.nl</id>
	<url>http://artifactory.ewi.tudelft.nl/artifactory/libs-release</url>
	<snapshots>
		<enabled>false</enabled>
	</snapshots>
</repository>

ImmutableList is similar to the common java.util.List: it contains a list of elements. However, the big differences are

  • ImmutableList is immutable, so it can not be modified
  • ImmutableList is generating elements on request only, and does not keep the elements.

As a simple comparison, suppose you need a list of all integers between 1000 and 2000. You could write a loop to fill 1000 elements of an ArrayList. Alternatively, you can create an ImmutableList instance where get(n) creates and returns the expected element on request.

This mechanism is especially useful when large lists are used, or when you already know that the user of the list will only pick a few items from the list, or even just wants to know the size of the list. Therefore ImmutableList uses BigInteger for indexing.

The main classes here are

class function
ImmutableList interface, providing get(BigInteger) and size() and being Iterable
AbstractImmutableList abstract superclass with default iterator() implementation, toString and get(long)
JoinedList Joins 2 immutablelists into one.
MapList Maps a function over the input list
MapThreadList Maps a 2-arg function over 2 lists
Outer maps an input list into a list containing all possible combinations with one element from each of the provided lists
AbstractPermutations Abstract superclass of all classes that map some input list into a list of all permutations of the input list
PermutationsOrderedWithoutReturn Maps input list into list of all permutations of the input list, when drawing N without return.
PermutationsWithoutReturn Maps input list into list of all permutations of the input list, when drawn all without return
PermutationsWithReturnMaps the input list into list of all permutations of the input list, when drawn all with return
RangeA list of all values from low to high with given step size
ShuffledListA list of all values of the input list, but shuffled to random order
TuplesMaps two input lists into a list of tuples.
Note: See TracWiki for help on using the wiki.