-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(Dart): Avoid using num as a variable name (#946)
- Loading branch information
Showing
15 changed files
with
98 additions
and
98 deletions.
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
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
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
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
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
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
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
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 |
---|---|---|
|
@@ -4,10 +4,10 @@ | |
* Author: what-is-me ([email protected]) | ||
*/ | ||
|
||
/* 获取元素 num 的第 k 位,其中 exp = 10^(k-1) */ | ||
int digit(int num, int exp) { | ||
/* 获取元素 _num 的第 k 位,其中 exp = 10^(k-1) */ | ||
int digit(int _num, int exp) { | ||
// 传入 exp 而非 k 可以避免在此重复执行昂贵的次方计算 | ||
return (num ~/ exp) % 10; | ||
return (_num ~/ exp) % 10; | ||
} | ||
|
||
/* 计数排序(根据 nums 第 k 位排序) */ | ||
|
@@ -41,7 +41,7 @@ void radixSort(List<int> nums) { | |
// 获取数组的最大元素,用于判断最大位数 | ||
// dart 中 int 的长度是 64 位的 | ||
int m = -1 << 63; | ||
for (int num in nums) if (num > m) m = num; | ||
for (int _num in nums) if (_num > m) m = _num; | ||
// 按照从低位到高位的顺序遍历 | ||
for (int exp = 1; exp <= m; exp *= 10) | ||
// 对数组元素的第 k 位执行计数排序 | ||
|
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
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
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
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
Oops, something went wrong.