diff options
| author | Patrick Walton <[email protected]> | 2011-04-07 10:14:25 -0700 |
|---|---|---|
| committer | Patrick Walton <[email protected]> | 2011-04-07 10:14:25 -0700 |
| commit | 2a894cabc237f32484dd9fb4265790c60eefd661 (patch) | |
| tree | 3d3b128ae9670f7b425d6cd68936482f603ca656 /src/lib/bitv.rs | |
| parent | Merge branch 'master' of github.com:graydon/rust (diff) | |
| parent | Run optimizations. (diff) | |
| download | rust-2a894cabc237f32484dd9fb4265790c60eefd661.tar.xz rust-2a894cabc237f32484dd9fb4265790c60eefd661.zip | |
Merge branch 'master' of github.com:graydon/rust
Diffstat (limited to 'src/lib/bitv.rs')
| -rw-r--r-- | src/lib/bitv.rs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/lib/bitv.rs b/src/lib/bitv.rs index 2029ef52..98e6c040 100644 --- a/src/lib/bitv.rs +++ b/src/lib/bitv.rs @@ -135,6 +135,28 @@ impure fn set(&t v, uint i, bool x) { } } +/* true if all bits are 1 */ +fn is_true(&t v) -> bool { + for(uint i in v.storage) { + if (i != 1u) { + ret false; + } + } + + ret true; +} + +/* true if all bits are non-1 */ +fn is_false(&t v) -> bool { + for(uint i in v.storage) { + if (i == 1u) { + ret false; + } + } + + ret true; +} + fn init_to_vec(t v, uint i) -> uint { if (get(v, i)) { ret 1u; |