 |
Changeset 2589
- Timestamp:
- 09/30/07 00:15:22
(1 year ago)
- Author:
- kris
- Message:
fixes #579
added a toArray() method on all collections, which copies collection values into an array
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r2465 |
r2589 |
|
| 905 | 905 | Cout (value).newline; |
|---|
| 906 | 906 | |
|---|
| 907 | | array.checkImplementation(); |
|---|
| | 907 | auto a = array.toArray; |
|---|
| | 908 | foreach (value; a) |
|---|
| | 909 | Cout (value).newline; |
|---|
| | 910 | |
|---|
| | 911 | array.checkImplementation(); |
|---|
| 908 | 912 | } |
|---|
| 909 | 913 | } |
|---|
| r2465 |
r2589 |
|
| 97 | 97 | |
|---|
| 98 | 98 | // Default implementations of Collection methods |
|---|
| | 99 | |
|---|
| | 100 | /*********************************************************************** |
|---|
| | 101 | |
|---|
| | 102 | expose collection content as an array |
|---|
| | 103 | |
|---|
| | 104 | ************************************************************************/ |
|---|
| | 105 | |
|---|
| | 106 | public T[] toArray () |
|---|
| | 107 | { |
|---|
| | 108 | auto result = new T[this.size]; |
|---|
| | 109 | |
|---|
| | 110 | int i = 0; |
|---|
| | 111 | foreach (e; this) |
|---|
| | 112 | result[i++] = e; |
|---|
| | 113 | |
|---|
| | 114 | return result; |
|---|
| | 115 | } |
|---|
| 99 | 116 | |
|---|
| 100 | 117 | /*********************************************************************** |
|---|
| r2465 |
r2589 |
|
| 168 | 168 | |
|---|
| 169 | 169 | /** |
|---|
| | 170 | expose collection content as an array |
|---|
| | 171 | **/ |
|---|
| | 172 | |
|---|
| | 173 | public T[] toArray (); |
|---|
| | 174 | |
|---|
| | 175 | /** |
|---|
| 170 | 176 | * Report whether other has the same element structure as this. |
|---|
| 171 | 177 | * That is, whether other is of the same size, and has the same |
|---|
Download in other formats:
|
 |
 |
|
 |
Copyright © 2006-2008 Tango. All Rights Reserved. | Page Width:
Static or
Dynamic