Advertisement
Guest User

Untitled

a guest
Jun 15th, 2013
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
D 0.87 KB | None | 0 0
  1. module main;
  2.  
  3. import std.stdio;
  4. import std.container;
  5. import std.conv;
  6. import std.random;
  7. import std.process;
  8. import core.memory;
  9.  
  10. void pause()
  11. {
  12.     system("pause");
  13. }
  14.  
  15. void toy()
  16. {
  17.     Array!(int) store;
  18.     auto minheap = new BinaryHeap!(Array!(int), "a > b")(store);
  19.     auto rng = new Random(unpredictableSeed);
  20.  
  21.     writeln("inserting...");
  22.  
  23.     for( uint i = 0 ; i < 100_000 ; i++)
  24.     {
  25.         minheap.insert(uniform(0, 1000, rng));
  26.     }
  27.     writeln("done.");
  28.  
  29.     writeln("removing");
  30.     while(!minheap.empty)
  31.     {
  32.         minheap.removeFront();
  33.     }
  34.     writeln("done.");
  35. }
  36.  
  37. void main(string[] argv)
  38. {
  39.     foreach(run; 1..100)
  40.     {
  41.         writeln("Run number ", run);
  42.  
  43.         toy;
  44.  
  45.         writeln("collecting...");
  46.         GC.collect();
  47.         writeln("done.");
  48.  
  49.         if( run == 1 || run == 2) pause;
  50.     }
  51.     pause;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement