-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multiple inputs & results #12
Open
TheLastGimbus
wants to merge
11
commits into
wrike:master
Choose a base branch
from
KanarekApp:multiple_results
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
1f30f80
Init example
TheLastGimbus 659ac74
Add some heavy calculations example
TheLastGimbus 9ea4ae2
First "multi input" function
TheLastGimbus 0554ae7
Merge branch 'master' into multiple_results
TheLastGimbus d9b63f3
Write first function once again
TheLastGimbus 4a42617
Update example
TheLastGimbus cbd1e1b
A way to support multiple arguments
TheLastGimbus 2802c17
Implement rest of functions
TheLastGimbus c961c3c
Make hashCode more compact
TheLastGimbus eb4571c
Shorter arg names to fit when auto-formatting
TheLastGimbus 84c2854
Fix tests... I hope :grimacing:
TheLastGimbus File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Files and directories created by pub | ||
.dart_tool/ | ||
.packages | ||
|
||
# Conventional directory for build outputs | ||
build/ | ||
|
||
# Directory created by dartdoc | ||
doc/api/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
A simple example showcase of memoize library |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import 'dart:math' as math; | ||
|
||
import 'package:memoize/memoize.dart'; | ||
|
||
num heavyCalc(num number) { | ||
num sum = 0; | ||
for (int x = 0; x < 999999; x++) { | ||
sum += math.sqrt(number); | ||
} | ||
return sum; | ||
} | ||
|
||
void main(List<String> arguments) { | ||
print('Some heavy calculations done 99 times with 6 different inputs:'); | ||
List<double> numbers = [10000, 4206969, 777, 21372137, 99999999, 10000]; | ||
var w = Stopwatch()..start(); | ||
for (int x = 0; x < 99; x++) { | ||
for (var n in numbers) { | ||
heavyCalc(n); | ||
} | ||
} | ||
print('\tNo cache: ${w.elapsedMilliseconds}ms'); | ||
|
||
w.reset(); | ||
var cacheSqrt = memo1(heavyCalc); | ||
for (int x = 0; x < 99; x++) { | ||
for (var n in numbers) { | ||
cacheSqrt(n); | ||
} | ||
} | ||
print('\tWith cache: ${w.elapsedMilliseconds}ms'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
name: example | ||
description: Example showcase of memoize library | ||
|
||
environment: | ||
sdk: '>=2.0.0-dev <3.0.0' | ||
|
||
dependencies: | ||
memoize: | ||
path: ../ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about limit storage capacity? For example second argument (with default value) to memo1.
Otherwise, in some cases, we will waste a lot of memory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, you mean to limit maximum cache? Yeah, that would be useful
Tho i'm not sure how to do this - if you just
pop()
one item from aHashMap
in dart, does it do it in some order or just random?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better refer to the documentation https://api.dart.dev/stable/2.12.2/dart-collection/HashMap/HashMap.html :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, so generally - you like/want my change in general sense? If so, I can implement rest of the features - just wasn't sure if I even should
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I like your changes:)