annotate tests/mini/aa6.d @ 1651:cb960b882ca3 tip

bindings were moved to dsource.org/projects/bindings/
author Moritz Warning <moritzwarning@web.de>
date Thu, 20 May 2010 20:05:03 +0200
parents 1bb99290e03a
children
rev   line source
lindquist@127 1 module aa6;
lindquist@127 2
lindquist@270 3 extern(C) int printf(char*, ...);
lindquist@270 4
lindquist@127 5 void main()
lindquist@127 6 {
lindquist@127 7 int[int] aa;
lindquist@127 8 aa = [1:1, 2:4, 3:9, 4:16];
lindquist@127 9 printf("---\n");
lindquist@127 10 foreach(int k, int v; aa)
lindquist@127 11 printf("aa[%d] = %d\n", k, v);
lindquist@127 12 aa.rehash;
lindquist@127 13 printf("---\n");
lindquist@127 14 foreach(int k, int v; aa)
lindquist@127 15 printf("aa[%d] = %d\n", k, v);
lindquist@127 16 size_t n = aa.length;
lindquist@127 17 assert(n == 4);
lindquist@127 18 int[] keys = aa.keys;
lindquist@127 19 assert(keys[] == [1,2,3,4][]);
lindquist@127 20 int[] vals = aa.values;
lindquist@127 21 assert(vals[] == [1,4,9,16][]);
lindquist@127 22 aa.remove(3);
lindquist@127 23 printf("---\n");
lindquist@127 24 foreach(int k, int v; aa)
lindquist@127 25 printf("aa[%d] = %d\n", k, v);
lindquist@127 26 assert(aa.length == 3);
lindquist@127 27 }