memoized 1.0.1 copy "memoized: ^1.0.1" to clipboard
memoized: ^1.0.1 copied to clipboard

outdated

Useful function wrappers for avoiding unnecessary computation. it makes the function return a memoized(cached) value.

Installing #

dependencies:
  memoized:
import 'package:memoized/memoized.dart';

Usage #

  • Basic

    Iterable<int> numbers = 1.to(30000000);
    final calculateSum = (() => numbers.sum()).memo;
      
    print(time(calculateSum));
    print(time(calculateSum));  // It returns the memoized value.
    
  • Update

    Iterable<int> numbers = 1.to(30000000);
    final calculateSum = (() => numbers.sum()).memo;
      
    numbers = 1.to(9043483);
    calculateSum.update();  // recomputed
    
  • Lazy Update

    Iterable<int> numbers = 1.to(30000000);
    final calculateSum = (() => numbers.sum()).memo;
    print(calculateSum());
      
    numbers = 1.to(9043483);
    calculateSum.requestUpdate();  // not computed
      
    numbers = 1.to(45000000);
    calculateSum.requestUpdate();  // not computed
      
    final value = calculateSum()   // recomputed at this point.
    
7
likes
0
pub points
86%
popularity

Publisher

verified publishersylfree.com

Useful function wrappers for avoiding unnecessary computation. it makes the function return a memoized(cached) value.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

to_string_pretty

More

Packages that depend on memoized