Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
3
Task/Collections/D/collections-1.d
Normal file
3
Task/Collections/D/collections-1.d
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
int[3] array;
|
||||
array[0] = 5;
|
||||
// array.length = 4; // compile-time error
|
||||
6
Task/Collections/D/collections-2.d
Normal file
6
Task/Collections/D/collections-2.d
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
int[] array;
|
||||
array ~= 5; // append 5
|
||||
array.length = 3;
|
||||
array[3] = 17; // runtime error: out of bounds. check removed in release mode.
|
||||
array = [2, 17, 3];
|
||||
writefln(array.sort); // 2, 3, 17
|
||||
8
Task/Collections/D/collections-3.d
Normal file
8
Task/Collections/D/collections-3.d
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
int[int] array;
|
||||
// array ~= 5; // it doesn't work that way!
|
||||
array[5] = 17;
|
||||
array[6] = 20;
|
||||
// prints "[5, 6]" -> "[17, 20]" - although the order is not specified.
|
||||
writefln(array.keys, " -> ", array.values);
|
||||
assert(5 in array); // returns a pointer, by the way
|
||||
if (auto ptr = 6 in array) writefln(*ptr); // 20
|
||||
Loading…
Add table
Add a link
Reference in a new issue