Hamming numbers: Difference between revisions
m
→Very fast sequence version using imperative code (mutable vectors) and logarithmic approximations for sorting: fix syntax highlighting...
GordonBGood (talk | contribs) (→Extremely fast non-sequence version by calculation of top band of Hamming numbers: Rust - add imperative sequence using logarithmic approximations...) |
GordonBGood (talk | contribs) m (→Very fast sequence version using imperative code (mutable vectors) and logarithmic approximations for sorting: fix syntax highlighting...) |
||
Line 10,819:
Most of the remaining execution time for the above version is due to the many allocations/deallocations used in implementing the functional lazy list sequence; the following code avoids that overhead by memoizing the pst values using linear vectors with the head and tail values marked by tracking indices:
{{trans|Nim}}
<syntaxhighlight lang=rust>extern crate num;
use num::bigint::BigUint;
Line 10,982 ⟶ 10,980:
println!("This last took {} milliseconds.", dur);
}</syntaxhighlight>
{{out}}
|