Mercurial > projects > doodle
annotate doodle/utils/prog/hash_test.d @ 112:b569d7d5064f
Added some utilities that are a work in progress.
author | David Bryant <bagnose@gmail.com> |
---|---|
date | Thu, 14 Apr 2011 11:27:17 +0930 |
parents | |
children | 8343c1dafac6 |
rev | line source |
---|---|
112
b569d7d5064f
Added some utilities that are a work in progress.
David Bryant <bagnose@gmail.com>
parents:
diff
changeset
|
1 import std.stdio; |
b569d7d5064f
Added some utilities that are a work in progress.
David Bryant <bagnose@gmail.com>
parents:
diff
changeset
|
2 import std.random; |
b569d7d5064f
Added some utilities that are a work in progress.
David Bryant <bagnose@gmail.com>
parents:
diff
changeset
|
3 import std.string; |
b569d7d5064f
Added some utilities that are a work in progress.
David Bryant <bagnose@gmail.com>
parents:
diff
changeset
|
4 |
b569d7d5064f
Added some utilities that are a work in progress.
David Bryant <bagnose@gmail.com>
parents:
diff
changeset
|
5 int main(string[] args) { |
b569d7d5064f
Added some utilities that are a work in progress.
David Bryant <bagnose@gmail.com>
parents:
diff
changeset
|
6 /* |
b569d7d5064f
Added some utilities that are a work in progress.
David Bryant <bagnose@gmail.com>
parents:
diff
changeset
|
7 struct S { |
b569d7d5064f
Added some utilities that are a work in progress.
David Bryant <bagnose@gmail.com>
parents:
diff
changeset
|
8 string[] names; |
b569d7d5064f
Added some utilities that are a work in progress.
David Bryant <bagnose@gmail.com>
parents:
diff
changeset
|
9 } |
b569d7d5064f
Added some utilities that are a work in progress.
David Bryant <bagnose@gmail.com>
parents:
diff
changeset
|
10 */ |
b569d7d5064f
Added some utilities that are a work in progress.
David Bryant <bagnose@gmail.com>
parents:
diff
changeset
|
11 |
b569d7d5064f
Added some utilities that are a work in progress.
David Bryant <bagnose@gmail.com>
parents:
diff
changeset
|
12 bool[ubyte[16]] aa; |
b569d7d5064f
Added some utilities that are a work in progress.
David Bryant <bagnose@gmail.com>
parents:
diff
changeset
|
13 |
b569d7d5064f
Added some utilities that are a work in progress.
David Bryant <bagnose@gmail.com>
parents:
diff
changeset
|
14 for (int count = 0; ; ++count) { |
b569d7d5064f
Added some utilities that are a work in progress.
David Bryant <bagnose@gmail.com>
parents:
diff
changeset
|
15 ubyte[16] digest; |
b569d7d5064f
Added some utilities that are a work in progress.
David Bryant <bagnose@gmail.com>
parents:
diff
changeset
|
16 foreach (ref a; digest) { |
b569d7d5064f
Added some utilities that are a work in progress.
David Bryant <bagnose@gmail.com>
parents:
diff
changeset
|
17 a = cast(ubyte)uniform(0, 256); |
b569d7d5064f
Added some utilities that are a work in progress.
David Bryant <bagnose@gmail.com>
parents:
diff
changeset
|
18 } |
b569d7d5064f
Added some utilities that are a work in progress.
David Bryant <bagnose@gmail.com>
parents:
diff
changeset
|
19 |
b569d7d5064f
Added some utilities that are a work in progress.
David Bryant <bagnose@gmail.com>
parents:
diff
changeset
|
20 /* |
b569d7d5064f
Added some utilities that are a work in progress.
David Bryant <bagnose@gmail.com>
parents:
diff
changeset
|
21 auto s = S(); |
b569d7d5064f
Added some utilities that are a work in progress.
David Bryant <bagnose@gmail.com>
parents:
diff
changeset
|
22 s.names ~= "hello"; |
b569d7d5064f
Added some utilities that are a work in progress.
David Bryant <bagnose@gmail.com>
parents:
diff
changeset
|
23 aa[digest] = s; |
b569d7d5064f
Added some utilities that are a work in progress.
David Bryant <bagnose@gmail.com>
parents:
diff
changeset
|
24 */ |
b569d7d5064f
Added some utilities that are a work in progress.
David Bryant <bagnose@gmail.com>
parents:
diff
changeset
|
25 aa[digest] = true; |
b569d7d5064f
Added some utilities that are a work in progress.
David Bryant <bagnose@gmail.com>
parents:
diff
changeset
|
26 |
b569d7d5064f
Added some utilities that are a work in progress.
David Bryant <bagnose@gmail.com>
parents:
diff
changeset
|
27 if (count % 1000 == 0) { |
b569d7d5064f
Added some utilities that are a work in progress.
David Bryant <bagnose@gmail.com>
parents:
diff
changeset
|
28 writefln("%s %s", count, digest); |
b569d7d5064f
Added some utilities that are a work in progress.
David Bryant <bagnose@gmail.com>
parents:
diff
changeset
|
29 } |
b569d7d5064f
Added some utilities that are a work in progress.
David Bryant <bagnose@gmail.com>
parents:
diff
changeset
|
30 |
b569d7d5064f
Added some utilities that are a work in progress.
David Bryant <bagnose@gmail.com>
parents:
diff
changeset
|
31 //writefln("%s %s", count, digest); |
b569d7d5064f
Added some utilities that are a work in progress.
David Bryant <bagnose@gmail.com>
parents:
diff
changeset
|
32 } |
b569d7d5064f
Added some utilities that are a work in progress.
David Bryant <bagnose@gmail.com>
parents:
diff
changeset
|
33 |
b569d7d5064f
Added some utilities that are a work in progress.
David Bryant <bagnose@gmail.com>
parents:
diff
changeset
|
34 return 0; |
b569d7d5064f
Added some utilities that are a work in progress.
David Bryant <bagnose@gmail.com>
parents:
diff
changeset
|
35 } |