Changes between Version 21 and Version 22 of immutablelist


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

--

Legend:

Unmodified
Added
Removed
Modified
  • immutablelist

    v21 v22  
    1010 * {{{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 {{{RangeInt(100000,200000, 1)}}}. This takes almost no memory (storing 3 BigDecimals plus some overhead), and no additional time.
     12As a simple comparison, suppose you need a list of all integers between 100000 and 200000. You could write a loop to fill all 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.