dart:html 庫中ImmutableListMixin.setRange 方法的用法介紹如下。
用法:
void setRange(
int start,
int end,
Iterable<E> iterable,
[int skipCount = 0]
)
override
將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 ImmutableListMixin.setAll用法及代碼示例
- Dart ImmutableListMixin.shuffle用法及代碼示例
- Dart ImmutableListMixin.sort用法及代碼示例
- Dart ImmutableListMixin.replaceRange用法及代碼示例
- Dart ImmutableListMixin.insert用法及代碼示例
- Dart ImmutableListMixin.addAll用法及代碼示例
- Dart ImmutableListMixin.retainWhere用法及代碼示例
- Dart ImmutableListMixin.removeLast用法及代碼示例
- Dart ImmutableListMixin.remove用法及代碼示例
- Dart ImmutableListMixin.add用法及代碼示例
- Dart ImmutableListMixin.insertAll用法及代碼示例
- Dart ImmutableListMixin.removeRange用法及代碼示例
- Dart ImmutableListMixin.removeWhere用法及代碼示例
- Dart ImmutableListMixin.removeAt用法及代碼示例
- Dart ImmutableListMixin.fillRange用法及代碼示例
- Dart Iterator用法及代碼示例
- Dart Iterable.takeWhile用法及代碼示例
- Dart Int32x4List.view用法及代碼示例
- Dart IterableMixin.isNotEmpty用法及代碼示例
- Dart IterableMixin.firstWhere用法及代碼示例
- Dart IterableMixin.lastWhere用法及代碼示例
- Dart Iterable.skipWhile用法及代碼示例
- Dart IterableMixin.every用法及代碼示例
- Dart Iterable.toSet用法及代碼示例
- Dart Int64List.sublist用法及代碼示例
注:本文由純淨天空篩選整理自dart.dev大神的英文原創作品 setRange method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
