提交 d611800a 编写于 作者: B bors

auto merge of #15284 : apoelstra/rust/bitv-methods, r=cmr

The types `Bitv` and `BitvSet` are badly out of date. This PR:
- cleans up the code (primarily, simplifies `Bitv` and implements `BitvSet` in terms of `Bitv`)
- implements several new traits for `Bitv`
- adds new functionality to `Bitv` and `BitvSet`
- replaces internal iterators with external ones
- updates documentation
- minor bug fixes

This is a significantly souped-up version of PR #15139 and is the result of the discussion there.
此差异已折叠。
......@@ -13,8 +13,8 @@
use std::collections::Bitv;
fn bitv_test() {
let mut v1 = box Bitv::new(31, false);
let v2 = box Bitv::new(31, true);
let mut v1 = box Bitv::with_capacity(31, false);
let v2 = box Bitv::with_capacity(31, true);
v1.union(v2);
}
......
......@@ -16,7 +16,7 @@
fn main() {
// Generate sieve of Eratosthenes for n up to 1e6
let n = 1000000u;
let sieve = Bitv::new(n+1, true);
let sieve = Bitv::with_capacity(n+1, true);
let limit: uint = (n as f32).sqrt() as uint;
for i in range(2, limit+1) {
if sieve[i] {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册