annotate run/a/associative_array_23_B.d @ 1556:ca435c6f02c8

DMD-1.014: associative array literals
author thomask
date Mon, 23 Jul 2007 18:46:06 +0000
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1556
ca435c6f02c8 DMD-1.014: associative array literals
thomask
parents:
diff changeset
1 // $HeadURL$
ca435c6f02c8 DMD-1.014: associative array literals
thomask
parents:
diff changeset
2 // $Date$
ca435c6f02c8 DMD-1.014: associative array literals
thomask
parents:
diff changeset
3 // $Author$
ca435c6f02c8 DMD-1.014: associative array literals
thomask
parents:
diff changeset
4
ca435c6f02c8 DMD-1.014: associative array literals
thomask
parents:
diff changeset
5 module dstress.run.a.associative_array_23_B;
ca435c6f02c8 DMD-1.014: associative array literals
thomask
parents:
diff changeset
6
ca435c6f02c8 DMD-1.014: associative array literals
thomask
parents:
diff changeset
7 int main(){
ca435c6f02c8 DMD-1.014: associative array literals
thomask
parents:
diff changeset
8 auto arr = [4:"vier", 0:"null", 2:"zwei"];
ca435c6f02c8 DMD-1.014: associative array literals
thomask
parents:
diff changeset
9
ca435c6f02c8 DMD-1.014: associative array literals
thomask
parents:
diff changeset
10 if(3 != arr.length){
ca435c6f02c8 DMD-1.014: associative array literals
thomask
parents:
diff changeset
11 assert(0);
ca435c6f02c8 DMD-1.014: associative array literals
thomask
parents:
diff changeset
12 }
ca435c6f02c8 DMD-1.014: associative array literals
thomask
parents:
diff changeset
13
ca435c6f02c8 DMD-1.014: associative array literals
thomask
parents:
diff changeset
14 char[][] master_e = ["vier", "null", "zwei"];
ca435c6f02c8 DMD-1.014: associative array literals
thomask
parents:
diff changeset
15 int[] master_i = [4, 0, 2];
ca435c6f02c8 DMD-1.014: associative array literals
thomask
parents:
diff changeset
16
ca435c6f02c8 DMD-1.014: associative array literals
thomask
parents:
diff changeset
17 foreach(index, element; arr){
ca435c6f02c8 DMD-1.014: associative array literals
thomask
parents:
diff changeset
18 bool found = false;
ca435c6f02c8 DMD-1.014: associative array literals
thomask
parents:
diff changeset
19 foreach(pos, i; master_i){
ca435c6f02c8 DMD-1.014: associative array literals
thomask
parents:
diff changeset
20 if(index == i && element == master_e[pos]){
ca435c6f02c8 DMD-1.014: associative array literals
thomask
parents:
diff changeset
21 master_i = master_i[0 .. pos] ~ master_i[pos+1 .. $];
ca435c6f02c8 DMD-1.014: associative array literals
thomask
parents:
diff changeset
22 master_e = master_e[0 .. pos] ~ master_e[pos+1 .. $];
ca435c6f02c8 DMD-1.014: associative array literals
thomask
parents:
diff changeset
23 found = true;
ca435c6f02c8 DMD-1.014: associative array literals
thomask
parents:
diff changeset
24 break;
ca435c6f02c8 DMD-1.014: associative array literals
thomask
parents:
diff changeset
25 }
ca435c6f02c8 DMD-1.014: associative array literals
thomask
parents:
diff changeset
26 }
ca435c6f02c8 DMD-1.014: associative array literals
thomask
parents:
diff changeset
27 if(!found){
ca435c6f02c8 DMD-1.014: associative array literals
thomask
parents:
diff changeset
28 assert(0);
ca435c6f02c8 DMD-1.014: associative array literals
thomask
parents:
diff changeset
29 }
ca435c6f02c8 DMD-1.014: associative array literals
thomask
parents:
diff changeset
30 }
ca435c6f02c8 DMD-1.014: associative array literals
thomask
parents:
diff changeset
31 if(master_i.length){
ca435c6f02c8 DMD-1.014: associative array literals
thomask
parents:
diff changeset
32 assert(0);
ca435c6f02c8 DMD-1.014: associative array literals
thomask
parents:
diff changeset
33 }
ca435c6f02c8 DMD-1.014: associative array literals
thomask
parents:
diff changeset
34 return 0;
ca435c6f02c8 DMD-1.014: associative array literals
thomask
parents:
diff changeset
35 }