Closed abdelaziz-mahdy closed 4 months ago
@abdelaziz-mahdy Thanks for your contribution!
An important problem is that, the multi-dimenssional List in dart is jagged array, which means users may input some 2D list without alignment.
so maybe we should warn users if the list is not aligned, e.g.,
final data = [
[1, 2],
[4, 5, 6, 7],
[7, 8, 9],
];
@abdelaziz-mahdy Thanks for your contribution!
An important problem is that, the multi-dimenssional List in dart is jagged array, which means users may input some 2D list without alignment.
so maybe we should warn users if the list is not aligned, e.g.,
final data = [ [1, 2], [4, 5, 6, 7], [7, 8, 9], ];
do you have any idea how to check on that without reducing performance? i like the idea but i cant think of a way to check on it without checking when expanding that the length is the same
i added checks to ensure the input is correct, to avoid bugs, let me know what you think
do you have any idea how to check on that without reducing performance? i like the idea but i cant think of a way to check on it without checking when expanding that the length is the same
Since dart have no such thing as multidimensional array
like C#, so the easiest way is to check the element length of a 2D array, i.e., data.every((e)=>e.length==data.first.length);
, but I am not sure how much performance will be lost.
do you have any idea how to check on that without reducing performance? i like the idea but i cant think of a way to check on it without checking when expanding that the length is the same
Since dart have no such thing as
multidimensional array
like C#, so the easiest way is to check the element length of a 2D array, i.e.,data.every((e)=>e.length==data.first.length);
, but I am not sure how much performance will be lost.
i did add the checks as a separated loops if you think they should be included in the expand (i think it will be better to iterate the list only once) let me know
i did add the checks as a separated loops if you think they should be included in the expand (i think it will be better to iterate the list only once) let me know
Agree that it should be iterated once, I changed it to linq
style to make it clearer and more concise, hope you won't mind it.
@abdelaziz-mahdy Looks good to me now, what do you think? If no further problems I am going to merge it.
looks good to me, but the every
keyword will make the loop iterated first then flattened so the list is iterated twice? also asserts or exception? asserts only works in debug right? that will lead to crashes on release this is why i used exception?
looks good to me, but the
every
keyword will make the loop iterated first then flattened so the list is iterated twice? also asserts or exception? asserts only works in debug right? that will lead to crashes on release this is why i used exception?
Oh, you are right, I didn't know the assert in dart will only throw in debug mode, such a strange feature....
I have fixed it, could you please review it?
Merged, thanks for your contribution!
fix https://github.com/rainyl/opencv_dart/issues/164
what do you think?