dart:core
库中List.setRange
方法的用法介绍如下。
用法:
void setRange(
int start,
int end,
Iterable<E> iterable,
[int skipCount = 0]
)
将iterable
的一些元素写入此列表的范围。
将 iterable
的对象,首先跳过 skipCount
对象,复制到此列表的从 start
(含)到 end
(不含)的范围内。
final list1 = <int>[1, 2, 3, 4];
final list2 = <int>[5, 6, 7, 8, 9];
// Copies the 4th and 5th items in list2 as the 2nd and 3rd items
// of list1.
const skipCount = 3;
list1.setRange(1, 3, list2, skipCount);
print(list1); // [1, 8, 9, 4]
start
和 end
提供的范围必须有效。如果 0 ≤ start
≤ end
≤ length ,则从 start
到 end
的范围是有效的。空范围(带有 end == start
)是有效的。
跳过 skipCount
对象后,iterable
必须有足够的对象来填充从 start
到 end
的范围。
如果 iterable
是此列表,则即使两个范围重叠,该操作也会正确地将最初在 skipCount
到 skipCount + (end - start)
范围内的元素复制到范围 start
到 end
。
如果iterable
以其他方式依赖于该列表,则不作任何保证。
相关用法
- Dart List.setAll用法及代码示例
- Dart List.sort用法及代码示例
- Dart List.shuffle用法及代码示例
- Dart List.sublist用法及代码示例
- Dart List.first用法及代码示例
- Dart List.fillRange用法及代码示例
- Dart List.addAll用法及代码示例
- Dart List.indexOf用法及代码示例
- Dart List.removeWhere用法及代码示例
- Dart List.reversed用法及代码示例
- Dart List.removeRange用法及代码示例
- Dart List.unmodifiable用法及代码示例
- Dart List.clear用法及代码示例
- Dart List.length用法及代码示例
- Dart List.from用法及代码示例
- Dart List.removeAt用法及代码示例
- Dart List.lastIndexWhere用法及代码示例
- Dart List.retainWhere用法及代码示例
- Dart List.removeLast用法及代码示例
- Dart List.filled用法及代码示例
- Dart List.empty用法及代码示例
- Dart List.of用法及代码示例
- Dart List.replaceRange用法及代码示例
- Dart List.remove用法及代码示例
- Dart List.asMap用法及代码示例
注:本文由纯净天空筛选整理自dart.dev大神的英文原创作品 setRange method。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。