popFront causing more memory to be used

ixid nuaccount at gmail.com
Tue Jul 3 09:33:41 PDT 2012


Thank you, that was faster. I decided to try the obvious method 
of reusing the same array giving similar speed to your suggestion 
while using less memory:

     ulong f2(int k, int n) {
         auto nums = new ulong[k + 1];
         nums[$ - 1] = 1;
         int iter = k;
         ulong total = 0;
         foreach(i;k..n + 1) {
             int iter_next = iter + 1 > k? 0 : iter + 1;
             total += nums[iter] - nums[iter_next];
             nums[iter_next] = total % 10^^8;
             iter = iter_next;
         }

         return nums[iter];
     }



More information about the Digitalmars-d-learn mailing list