Changes between Version 20 and Version 21 of immutablelist


Ignore:
Timestamp:
08/03/21 11:39:00 (3 years ago)
Author:
wouter
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • immutablelist

    v20 v21  
    44Part of [wiki:utilities].
    55
    6 ImmutableList is similar to the common java.util.List: it contains a list of elements.
     6{{{ImmutableList}}} is similar to the common java.util.List: it contains a list of elements.
    77However, the big differences are
    8  * ImmutableList allows virtually unlimited sizes.
    9  * ImmutableList does lazy evaluation: it is generating elements on request only, and does not keep the elements.
    10  * ImmutableList is immutable, so it can not be modified
     8 * {{{ImmutableList}}} allows virtually unlimited sizes.
     9 * {{{ImmutableList}}} does lazy evaluation: it is generating elements on request only, and does not keep the elements.
     10 * {{{ImmutableList}}} is immutable, so it can not be modified
    1111
    12 As a simple comparison, suppose you need a list of all integers between 100000 and 200000. You could write a loop to fill 1000 elements of an ArrayList. This takes you about a megabyte of memory plus the time of filling the array. Alternatively, you can use {{{Range(100000,200000, 1)}}}. This takes almost no memory (storing 3 BigDecimals plus some overhead), and no additinal time.
     12As a simple comparison, suppose you need a list of all integers between 100000 and 200000. You could write a loop to fill 1000 elements of an {{{ArrayList}}}. This takes you about a megabyte of memory plus the time of filling the array. Alternatively, you can use {{{RangeInt(100000,200000, 1)}}}. This takes almost no memory (storing 3 BigDecimals plus some overhead), and no additional time.
    1313
    1414This mechanism is especially useful when the list elements have to be generated on an as-needed basis. For example when large lists are used, when the list elements are expensive to create, 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.
     
    1717
    1818|| **class**  || **function** ||
    19 ||ImmutableList ||interface, providing get(BigInteger) and size() and being Iterable ||
    20 ||AbstractImmutableList ||Abstract superclass with default iterator() implementation, toString and get(long) ||
    21 ||JoinedList ||Joins multiple ImmutableLists into one. ||
    22 ||MapList ||Maps a function over the input list. ||
    23 ||MapThreadList ||Maps a 2-arg function over 2 lists.||
    24 ||RandomIntegers||A list of pseudo-random numbers. List size is restricted to powers of 2.||
    25 ||Outer ||Maps an input list into a list containing all possible combinations with one element from each of the provided lists.||
    26 ||AbstractPermutations ||Abstract superclass of all classes that map some input list into a list of all permutations of the input list.||
    27 ||PermutationsOrderedWithoutReturn ||Maps input list into list of all permutations of the input list, when drawing N without return.||
    28 ||PermutationsWithoutReturn ||Maps input list into list of all permutations of the input list, when drawn all without return. ||
    29 ||PermutationsWithReturn||Maps the input list into list of all permutations of the input list, when drawn all with return.||
    30 ||Range||A list of all values from low to high with given step size||
    31 ||RangeInt||As Range, but with BigInteger values.||
    32 ||Shuffle||A list of all values of the input list, but shuffled to random order||
    33 ||Tuples||Maps two input lists into a list of tuples.||
    34 ||SubList||A sublist of a given list. The selected elements are indicated with a binary code, with 1 indicating a selected element.||
    35 ||SubLists||A list of all sublists of size k of the given list.||
    36 ||Partitionings||The set of all possible partitionings - all possible ways to split the set into non-empty groups.||
     19||{{{ImmutableList}}} ||interface, providing get(BigInteger) and size() and being Iterable ||
     20||{{{AbstractImmutableList}}} ||Abstract superclass with default iterator() implementation, toString and get(long) ||
     21||{{{JoinedList}}} ||Joins multiple ImmutableLists into one. ||
     22||{{{MapList}}} ||Maps a function over the input list. ||
     23||{{{MapThreadList}}} ||Maps a 2-arg function over 2 lists.||
     24||{{{RandomIntegers}}}||A list of pseudo-random numbers. List size is restricted to powers of 2.||
     25||{{{Outer}}} ||Maps an input list into a list containing all possible combinations with one element from each of the provided lists.||
     26||{{{AbstractPermutations}}} ||Abstract superclass of all classes that map some input list into a list of all permutations of the input list.||
     27||{{{PermutationsOrderedWithoutReturn}}} ||Maps input list into list of all permutations of the input list, when drawing N without return.||
     28||{{{PermutationsWithoutReturn}}} ||Maps input list into list of all permutations of the input list, when drawn all without return. ||
     29||{{{PermutationsWithReturn}}}||Maps the input list into list of all permutations of the input list, when drawn all with return.||
     30||{{{Range}}}||A list of all values from low to high with given step size||
     31||{{{RangeInt}}}||As Range, but with BigInteger values.||
     32||{{{Shuffle}}}||A list of all values of the input list, but shuffled to random order||
     33||{{{Tuples}}}||Maps two input lists into a list of tuples.||
     34||{{{SubList}}}||A sublist of a given list. The selected elements are indicated with a binary code, with 1 indicating a selected element.||
     35||{{{SubLists}}}||A list of all sublists of size k of the given list.||
     36||{{{Partitionings}}}||The set of all possible partitionings - all possible ways to split the set into non-empty groups. Warning: This list is huge, ||