Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
3165ddeb
R
Rust
项目概览
int
/
Rust
大约 1 年 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rust
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
3165ddeb
编写于
9月 26, 2013
作者:
K
kud1ing
提交者:
Huon Wilson
9月 26, 2013
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
bitv: backticks for code in documentation
上级
c873216a
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
24 addition
and
24 deletion
+24
-24
src/libextra/bitv.rs
src/libextra/bitv.rs
+24
-24
未找到文件。
src/libextra/bitv.rs
浏览文件 @
3165ddeb
...
...
@@ -116,7 +116,7 @@ struct BigBitv {
}
/**
*
a mask that has a 1 for each defined bit in the nth element of a big_bitv
,
*
A mask that has a 1 for each defined bit in the n'th element of a `BigBitv`
,
* assuming n bits.
*/
#[inline]
...
...
@@ -284,7 +284,7 @@ pub fn new(nbits: uint, init: bool) -> Bitv {
* Calculates the union of two bitvectors
*
* Sets `self` to the union of `self` and `v1`. Both bitvectors must be
* the same length. Returns
'true'
if `self` changed.
* the same length. Returns
`true`
if `self` changed.
*/
#[inline]
pub
fn
union
(
&
mut
self
,
v1
:
&
Bitv
)
->
bool
{
self
.do_op
(
Union
,
v1
)
}
...
...
@@ -293,7 +293,7 @@ pub fn union(&mut self, v1: &Bitv) -> bool { self.do_op(Union, v1) }
* Calculates the intersection of two bitvectors
*
* Sets `self` to the intersection of `self` and `v1`. Both bitvectors
* must be the same length. Returns
'true'
if `self` changed.
* must be the same length. Returns
`true`
if `self` changed.
*/
#[inline]
pub
fn
intersect
(
&
mut
self
,
v1
:
&
Bitv
)
->
bool
{
...
...
@@ -395,7 +395,7 @@ pub fn difference(&mut self, v: &Bitv) -> bool {
self
.do_op
(
Difference
,
v
)
}
/// Returns
true
if all bits are 1
/// Returns
`true`
if all bits are 1
#[inline]
pub
fn
is_true
(
&
self
)
->
bool
{
match
self
.rep
{
...
...
@@ -417,7 +417,7 @@ pub fn rev_liter<'a>(&'a self) -> Invert<BitvIterator<'a>> {
self
.iter
()
.invert
()
}
/// Returns
true
if all bits are 0
/// Returns
`true`
if all bits are 0
pub
fn
is_false
(
&
self
)
->
bool
{
match
self
.rep
{
Small
(
ref
b
)
=>
b
.is_false
(
self
.nbits
),
...
...
@@ -433,9 +433,9 @@ pub fn init_to_vec(&self, i: uint) -> uint {
}
/**
* Converts `self` to a vector of
uint
with the same length.
* Converts `self` to a vector of
`uint`
with the same length.
*
* Each
uint in the resulting vector has either value 0u or 1u
.
* Each
`uint` in the resulting vector has either value `0u` or `1u`
.
*/
pub
fn
to_vec
(
&
self
)
->
~
[
uint
]
{
vec
::
from_fn
(
self
.nbits
,
|
x
|
self
.init_to_vec
(
x
))
...
...
@@ -443,8 +443,8 @@ pub fn to_vec(&self) -> ~[uint] {
/**
* Organise the bits into bytes, such that the first bit in the
*
bitv
becomes the high-order bit of the first byte. If the
* size of the
bitv
is not a multiple of 8 then trailing bits
*
`Bitv`
becomes the high-order bit of the first byte. If the
* size of the
`Bitv`
is not a multiple of 8 then trailing bits
* will be filled-in with false/0
*/
pub
fn
to_bytes
(
&
self
)
->
~
[
u8
]
{
...
...
@@ -472,7 +472,7 @@ fn bit (bitv: &Bitv, byte: uint, bit: uint) -> u8 {
}
/**
* Transform
self into a [bool] by turning each bit into a bool
* Transform
`self` into a `[bool]` by turning each bit into a `bool`.
*/
pub
fn
to_bools
(
&
self
)
->
~
[
bool
]
{
vec
::
from_fn
(
self
.nbits
,
|
i
|
self
[
i
])
...
...
@@ -498,7 +498,7 @@ pub fn to_str(&self) -> ~str {
/**
* Compare a bitvector to a vector of
bool
.
* Compare a bitvector to a vector of
`bool`
.
*
* Both the bitvector and vector must have the same length.
*/
...
...
@@ -519,9 +519,9 @@ pub fn ones(&self, f: &fn(uint) -> bool) -> bool {
}
/**
* Transform a byte-vector into a
bitv
. Each byte becomes 8 bits,
* Transform a byte-vector into a
`Bitv`
. Each byte becomes 8 bits,
* with the most significant bits of each byte coming first. Each
* bit becomes
true if equal to 1 or false
if equal to 0.
* bit becomes
`true` if equal to 1 or `false`
if equal to 0.
*/
pub
fn
from_utf8
(
bytes
:
&
[
u8
])
->
Bitv
{
from_fn
(
bytes
.len
()
*
8
,
|
i
|
{
...
...
@@ -532,15 +532,15 @@ pub fn from_utf8(bytes: &[u8]) -> Bitv {
}
/**
* Transform a
[bool] into a bitv by converting each bool
into a bit.
* Transform a
`[bool]` into a `Bitv` by converting each `bool`
into a bit.
*/
pub
fn
from_bools
(
bools
:
&
[
bool
])
->
Bitv
{
from_fn
(
bools
.len
(),
|
i
|
bools
[
i
])
}
/**
* Create a
bitv
of the specified length where the value at each
* index is
f(index)
.
* Create a
`Bitv`
of the specified length where the value at each
* index is
`f(index)`
.
*/
pub
fn
from_fn
(
len
:
uint
,
f
:
&
fn
(
index
:
uint
)
->
bool
)
->
Bitv
{
let
mut
bitv
=
Bitv
::
new
(
len
,
false
);
...
...
@@ -571,7 +571,7 @@ fn iterate_bits(base: uint, bits: uint, f: &fn(uint) -> bool) -> bool {
return
true
;
}
/// An iterator for
Bitv
/// An iterator for
`Bitv`.
pub
struct
BitvIterator
<
'self
>
{
priv
bitv
:
&
'self
Bitv
,
priv
next_idx
:
uint
,
...
...
@@ -631,12 +631,12 @@ fn idx(&self, index: uint) -> Option<bool> {
///
/// It should also be noted that the amount of storage necessary for holding a
/// set of objects is proportional to the maximum of the objects when viewed
/// as a
uint
.
/// as a
`uint`
.
#[deriving(Clone)]
pub
struct
BitvSet
{
priv
size
:
uint
,
// In theory this is a
Bitv instead of always a BigBitv
, but knowing that
// In theory this is a
`Bitv` instead of always a `BigBitv`
, but knowing that
// there's an array of storage makes our lives a whole lot easier when
// performing union/intersection/etc operations
priv
bitv
:
BigBitv
...
...
@@ -861,7 +861,7 @@ fn remove(&mut self, value: &uint) -> bool {
}
impl
BitvSet
{
/// Visits each of the words that the two bit vectors (
self and other
)
/// Visits each of the words that the two bit vectors (
`self` and `other`
)
/// both have in common. The three yielded arguments are (bit location,
/// w1, w2) where the bit location is the number of bits offset so far,
/// and w1/w2 are the words coming from the two vectors self, other.
...
...
@@ -874,13 +874,13 @@ fn common_iter<'a>(&'a self, other: &'a BitvSet)
.map
(|((
i
,
&
w
),
o_store
)|
(
i
*
uint
::
bits
,
w
,
o_store
[
i
]))
}
/// Visits each word in
self or other
that extends beyond the other. This
/// Visits each word in
`self` or `other`
that extends beyond the other. This
/// will only iterate through one of the vectors, and it only iterates
/// over the portion that doesn't overlap with the other one.
///
/// The yielded arguments are a
bool, the bit offset, and a word. The bool
/// is true if the word comes from
'self', and false
if it comes from
///
'other'
.
/// The yielded arguments are a
`bool`, the bit offset, and a word. The `bool`
/// is true if the word comes from
`self`, and `false`
if it comes from
///
`other`
.
fn
outlier_iter
<
'a
>
(
&
'a
self
,
other
:
&
'a
BitvSet
)
->
Map
<
'static
,
((
uint
,
&
'a
uint
),
uint
),
(
bool
,
uint
,
uint
),
Zip
<
Enumerate
<
vec
::
VecIterator
<
'a
,
uint
>>
,
Repeat
<
uint
>>>
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录