Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2587)

Unified Diff: sdk/lib/typeddata/typeddata.dart

Issue 13834008: Add fromList constructor to typeddata typed lists. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: sdk/lib/typeddata/typeddata.dart
diff --git a/sdk/lib/typeddata/typeddata.dart b/sdk/lib/typeddata/typeddata.dart
index 773d3cc441619e8f29e9bfdcdf25568ad0275d4f..76db6be5530d9640aaffa56dd941012b09b57c56 100644
--- a/sdk/lib/typeddata/typeddata.dart
+++ b/sdk/lib/typeddata/typeddata.dart
@@ -327,6 +327,12 @@ abstract class Int8List implements List<int>, TypedData {
external factory Int8List(int length);
/**
+ * Creates a [Int8List] with the same size as the [elements] list
+ * and copies over the elements.
+ */
+ external factory Int8List.fromList(List<int> elements);
+
+ /**
* Creates an [Int8List] _view_ of the specified region in the specified
* byte buffer. Changes in the [Int8List] will be visible in the byte
* buffer and vice versa. If the [offsetInBytes] index of the region is not
@@ -358,6 +364,12 @@ abstract class Uint8List implements List<int>, TypedData {
external factory Uint8List(int length);
/**
+ * Creates a [Uint8List] with the same size as the [elements] list
+ * and copies over the elements.
+ */
+ external factory Uint8List.fromList(List<int> elements);
+
+ /**
* Creates a [Uint8List] _view_ of the specified region in the specified
* byte buffer. Changes in the [Uint8List] will be visible in the byte
* buffer and vice versa. If the [offsetInBytes] index of the region is not
@@ -390,6 +402,12 @@ abstract class Uint8ClampedList implements List<int>, TypedData {
external factory Uint8ClampedList(int length);
/**
+ * Creates a [Uint8ClampedList] of the same size as the [elements]
+ * list and copies over the values clamping when needed.
+ */
+ external factory Uint8ClampedList.fromList(List<int> elements);
+
+ /**
* Creates a [Uint8ClampedList] _view_ of the specified region in the
* specified byte [buffer]. Changes in the [Uint8List] will be visible in the
* byte buffer and vice versa. If the [offsetInBytes] index of the region is
@@ -421,6 +439,12 @@ abstract class Int16List implements List<int>, TypedData {
external factory Int16List(int length);
/**
+ * Creates a [Int16List] with the same size as the [elements] list
+ * and copies over the elements.
+ */
+ external factory Int16List.fromList(List<int> elements);
+
+ /**
* Creates an [Int16List] _view_ of the specified region in the specified
* byte buffer. Changes in the [Int16List] will be visible in the byte
* buffer and vice versa. If the [offsetInBytes] index of the region is not
@@ -455,6 +479,12 @@ abstract class Uint16List implements List<int>, TypedData {
external factory Uint16List(int length);
/**
+ * Creates a [Uint16List] with the same size as the [elements] list
+ * and copies over the elements.
+ */
+ external factory Uint16List.fromList(List<int> elements);
+
+ /**
* Creates a [Uint16List] _view_ of the specified region in
* the specified byte buffer. Changes in the [Uint16List] will be
* visible in the byte buffer and vice versa. If the [offsetInBytes] index
@@ -489,6 +519,12 @@ abstract class Int32List implements List<int>, TypedData {
external factory Int32List(int length);
/**
+ * Creates a [Int32List] with the same size as the [elements] list
+ * and copies over the elements.
+ */
+ external factory Int32List.fromList(List<int> elements);
+
+ /**
* Creates an [Int32List] _view_ of the specified region in the specified
* byte buffer. Changes in the [Int32List] will be visible in the byte
* buffer and vice versa. If the [offsetInBytes] index of the region is not
@@ -523,6 +559,12 @@ abstract class Uint32List implements List<int>, TypedData {
external factory Uint32List(int length);
/**
+ * Creates a [Uint32List] with the same size as the [elements] list
+ * and copies over the elements.
+ */
+ external factory Uint32List.fromList(List<int> elements);
+
+ /**
* Creates a [Uint32List] _view_ of the specified region in
* the specified byte buffer. Changes in the [Uint32] will be
* visible in the byte buffer and vice versa. If the [offsetInBytes] index
@@ -557,6 +599,12 @@ abstract class Int64List implements List<int>, TypedData {
external factory Int64List(int length);
/**
+ * Creates a [Int64List] with the same size as the [elements] list
+ * and copies over the elements.
+ */
+ external factory Int64List.fromList(List<int> elements);
+
+ /**
* Creates an [Int64List] _view_ of the specified region in the specified
* byte buffer. Changes in the [Int64List] will be visible in the byte buffer
* and vice versa. If the [offsetInBytes] index of the region is not
@@ -591,6 +639,12 @@ abstract class Uint64List implements List<int>, TypedData {
external factory Uint64List(int length);
/**
+ * Creates a [Uint64List] with the same size as the [elements] list
+ * and copies over the elements.
+ */
+ external factory Uint64List.fromList(List<int> elements);
+
+ /**
* Creates an [Uint64List] _view_ of the specified region in
* the specified byte buffer. Changes in the [Uint64List] will be
* visible in the byte buffer and vice versa. If the [offsetInBytes]
@@ -627,6 +681,12 @@ abstract class Float32List implements List<double>, TypedData {
external factory Float32List(int length);
/**
+ * Creates a [Float32List] with the same size as the [elements] list
+ * and copies over the elements.
+ */
+ external factory Float32List.fromList(List<double> elements);
+
+ /**
* Creates a [Float32List] _view_ of the specified region in the specified
* byte buffer. Changes in the [Float32List] will be visible in the byte
* buffer and vice versa. If the [offsetInBytes] index of the region is not
@@ -662,6 +722,12 @@ abstract class Float64List implements List<double>, TypedData {
external factory Float64List(int length);
/**
+ * Creates a [Float64List] with the same size as the [elements] list
+ * and copies over the elements.
+ */
+ external factory Float64List.fromList(List<double> elements);
+
+ /**
* Creates a [Float64List] _view_ of the specified region in the specified
* byte buffer. Changes in the [Float64List] will be visible in the byte
* buffer and vice versa. If the [offsetInBytes] index of the region is not

Powered by Google App Engine
This is Rietveld 408576698