Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
f77cabec
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,发现更多精彩内容 >>
提交
f77cabec
编写于
8月 11, 2014
作者:
A
Aaron Turon
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Deprecation fallout in libcollections
上级
0b5204f5
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
43 addition
and
40 deletion
+43
-40
src/libcollections/bitv.rs
src/libcollections/bitv.rs
+7
-7
src/libcollections/btree.rs
src/libcollections/btree.rs
+14
-14
src/libcollections/dlist.rs
src/libcollections/dlist.rs
+2
-2
src/libcollections/priority_queue.rs
src/libcollections/priority_queue.rs
+3
-3
src/libcollections/ringbuf.rs
src/libcollections/ringbuf.rs
+5
-4
src/libcollections/slice.rs
src/libcollections/slice.rs
+1
-1
src/libcollections/smallintmap.rs
src/libcollections/smallintmap.rs
+2
-1
src/libcollections/str.rs
src/libcollections/str.rs
+7
-7
src/libcollections/string.rs
src/libcollections/string.rs
+1
-1
src/libcollections/vec.rs
src/libcollections/vec.rs
+1
-0
未找到文件。
src/libcollections/bitv.rs
浏览文件 @
f77cabec
...
...
@@ -264,7 +264,7 @@ pub fn get(&self, i: uint) -> bool {
assert
!
(
i
<
self
.nbits
);
let
w
=
i
/
uint
::
BITS
;
let
b
=
i
%
uint
::
BITS
;
let
x
=
self
.storage
.get
(
w
)
&
(
1
<<
b
);
let
x
=
self
.storage
[
w
]
&
(
1
<<
b
);
x
!=
0
}
...
...
@@ -289,8 +289,8 @@ pub fn set(&mut self, i: uint, x: bool) {
let
w
=
i
/
uint
::
BITS
;
let
b
=
i
%
uint
::
BITS
;
let
flag
=
1
<<
b
;
*
self
.storage
.get_mut
(
w
)
=
if
x
{
*
self
.storage
.get
(
w
)
|
flag
}
else
{
*
self
.storage
.get
(
w
)
&
!
flag
};
*
self
.storage
.get_mut
(
w
)
=
if
x
{
self
.storage
[
w
]
|
flag
}
else
{
self
.storage
[
w
]
&
!
flag
};
}
/// Set all bits to 1.
...
...
@@ -827,7 +827,7 @@ fn clone(&self) -> Bitv {
fn
clone_from
(
&
mut
self
,
source
:
&
Bitv
)
{
self
.nbits
=
source
.nbits
;
self
.storage
.reserve
(
source
.storage
.len
());
for
(
i
,
w
)
in
self
.storage
.mut_iter
()
.enumerate
()
{
*
w
=
*
source
.storage
.get
(
i
)
;
}
for
(
i
,
w
)
in
self
.storage
.mut_iter
()
.enumerate
()
{
*
w
=
source
.storage
[
i
]
;
}
}
}
...
...
@@ -1146,7 +1146,7 @@ fn other_op(&mut self, other: &BitvSet, f: |uint, uint| -> uint) {
self_bitv
.reserve
(
other_bitv
.capacity
());
// Apply values
for
(
i
,
w
)
in
other_bitv
.mask_words
(
0
)
{
let
old
=
*
self_bitv
.storage
.get
(
i
)
;
let
old
=
self_bitv
.storage
[
i
]
;
let
new
=
f
(
old
,
w
);
*
self_bitv
.storage
.get_mut
(
i
)
=
new
;
}
...
...
@@ -1573,10 +1573,10 @@ fn next(&mut self) -> Option<uint> {
// one Bitv might be longer than the other
let
word_idx
=
self
.next_idx
/
uint
::
BITS
;
let
w1
=
if
word_idx
<
s_bitv
.storage
.len
()
{
*
s_bitv
.storage
.get
(
word_idx
)
s_bitv
.storage
[
word_idx
]
}
else
{
0
};
let
w2
=
if
word_idx
<
o_bitv
.storage
.len
()
{
*
o_bitv
.storage
.get
(
word_idx
)
o_bitv
.storage
[
word_idx
]
}
else
{
0
};
self
.current_word
=
(
self
.merge
)(
w1
,
w2
);
}
...
...
src/libcollections/btree.rs
浏览文件 @
f77cabec
...
...
@@ -299,14 +299,14 @@ fn bsearch_leaf(&self, k: K) -> Option<uint> {
midpoint
=
0
;
}
loop
{
let
order
=
self
.elts
.get
(
midpoint
)
.key
.cmp
(
&
k
);
let
order
=
self
.elts
[
midpoint
]
.key
.cmp
(
&
k
);
match
order
{
Equal
=>
{
return
None
;
}
Greater
=>
{
if
midpoint
>
0
{
if
self
.elts
.get
(
midpoint
-
1
)
.key
.cmp
(
&
k
)
==
Less
{
if
self
.elts
[
midpoint
-
1
]
.key
.cmp
(
&
k
)
==
Less
{
return
Some
(
midpoint
);
}
else
{
...
...
@@ -322,7 +322,7 @@ fn bsearch_leaf(&self, k: K) -> Option<uint> {
}
Less
=>
{
if
midpoint
+
1
<
self
.elts
.len
()
{
if
self
.elts
.get
(
midpoint
+
1
)
.key
.cmp
(
&
k
)
==
Greater
{
if
self
.elts
[
midpoint
+
1
]
.key
.cmp
(
&
k
)
==
Greater
{
return
Some
(
midpoint
);
}
else
{
...
...
@@ -422,7 +422,7 @@ fn cmp(&self, other: &Leaf<K, V>) -> Ordering {
if
self
.elts
.len
()
<
other
.elts
.len
()
{
return
Less
;
}
self
.elts
.get
(
0
)
.cmp
(
other
.elts
.get
(
0
)
)
self
.elts
[
0
]
.cmp
(
&
other
.elts
[
0
]
)
}
}
...
...
@@ -457,14 +457,14 @@ fn bsearch_branch(&self, k: K) -> Option<uint> {
midpoint
=
0u
;
}
loop
{
let
order
=
self
.elts
.get
(
midpoint
)
.key
.cmp
(
&
k
);
let
order
=
self
.elts
[
midpoint
]
.key
.cmp
(
&
k
);
match
order
{
Equal
=>
{
return
None
;
}
Greater
=>
{
if
midpoint
>
0
{
if
self
.elts
.get
(
midpoint
-
1
)
.key
.cmp
(
&
k
)
==
Less
{
if
self
.elts
[
midpoint
-
1
]
.key
.cmp
(
&
k
)
==
Less
{
return
Some
(
midpoint
);
}
else
{
...
...
@@ -480,7 +480,7 @@ fn bsearch_branch(&self, k: K) -> Option<uint> {
}
Less
=>
{
if
midpoint
+
1
<
self
.elts
.len
()
{
if
self
.elts
.get
(
midpoint
+
1
)
.key
.cmp
(
&
k
)
==
Greater
{
if
self
.elts
[
midpoint
+
1
]
.key
.cmp
(
&
k
)
==
Greater
{
return
Some
(
midpoint
);
}
else
{
...
...
@@ -529,15 +529,15 @@ fn insert(mut self, k: K, v: V, ub: uint) -> (Node<K, V>, bool) {
Some
(
i
)
=>
{
if
i
==
self
.elts
.len
()
{
let
new_outcome
=
self
.clone
()
.rightmost_child
.insert
(
k
.clone
(),
v
.clone
(),
ub
.clone
());
v
.clone
(),
ub
.clone
());
new_branch
=
new_outcome
.clone
()
.val0
();
outcome
=
new_outcome
.val1
();
}
else
{
let
new_outcome
=
self
.elts
.get
(
i
)
.left
.clone
()
.insert
(
k
.clone
(),
v
.clone
(),
ub
.clone
());
let
new_outcome
=
self
.elts
[
i
]
.left
.clone
()
.insert
(
k
.clone
(),
v
.clone
(),
ub
.clone
());
new_branch
=
new_outcome
.clone
()
.val0
();
outcome
=
new_outcome
.val1
();
}
...
...
@@ -581,7 +581,7 @@ fn insert(mut self, k: K, v: V, ub: uint) -> (Node<K, V>, bool) {
//If we have a new branch node, attempt to insert it into the tree
//as with the key-value pair, then check to see if the node is overfull.
BranchNode
(
branch
)
=>
{
let
new_elt
=
branch
.elts
.get
(
0
)
.clone
();
let
new_elt
=
branch
.elts
[
0
]
.clone
();
let
new_elt_index
=
self
.bsearch_branch
(
new_elt
.clone
()
.key
);
match
new_elt_index
{
None
=>
{
...
...
@@ -652,7 +652,7 @@ fn cmp(&self, other: &Branch<K, V>) -> Ordering {
if
self
.elts
.len
()
<
other
.elts
.len
()
{
return
Less
;
}
self
.elts
.get
(
0
)
.cmp
(
other
.elts
.get
(
0
)
)
self
.elts
[
0
]
.cmp
(
&
other
.elts
[
0
]
)
}
}
...
...
src/libcollections/dlist.rs
浏览文件 @
f77cabec
...
...
@@ -654,7 +654,7 @@ fn size_hint(&self) -> (uint, Option<uint>) {
impl
<
A
>
DoubleEndedIterator
<
A
>
for
MoveItems
<
A
>
{
#[inline]
fn
next_back
(
&
mut
self
)
->
Option
<
A
>
{
self
.list
.pop
_back
()
}
fn
next_back
(
&
mut
self
)
->
Option
<
A
>
{
self
.list
.pop
()
}
}
impl
<
A
>
FromIterator
<
A
>
for
DList
<
A
>
{
...
...
@@ -667,7 +667,7 @@ fn from_iter<T: Iterator<A>>(iterator: T) -> DList<A> {
impl
<
A
>
Extendable
<
A
>
for
DList
<
A
>
{
fn
extend
<
T
:
Iterator
<
A
>>
(
&
mut
self
,
mut
iterator
:
T
)
{
for
elt
in
iterator
{
self
.push
_back
(
elt
);
}
for
elt
in
iterator
{
self
.push
(
elt
);
}
}
}
...
...
src/libcollections/priority_queue.rs
浏览文件 @
f77cabec
...
...
@@ -261,7 +261,7 @@ pub fn iter<'a>(&'a self) -> Items<'a, T> {
///
/// ```
pub
fn
top
<
'a
>
(
&
'a
self
)
->
Option
<&
'a
T
>
{
if
self
.is_empty
()
{
None
}
else
{
Some
(
self
.data
.get
(
0
)
)
}
if
self
.is_empty
()
{
None
}
else
{
Some
(
&
self
.data
[
0
]
)
}
}
#[deprecated=
"renamed to `top`"
]
...
...
@@ -473,7 +473,7 @@ fn siftup(&mut self, start: uint, mut pos: uint) {
while
pos
>
start
{
let
parent
=
(
pos
-
1
)
>>
1
;
if
new
>
*
self
.data
.get
(
parent
)
{
if
new
>
self
.data
[
parent
]
{
let
x
=
replace
(
self
.data
.get_mut
(
parent
),
zeroed
());
ptr
::
write
(
self
.data
.get_mut
(
pos
),
x
);
pos
=
parent
;
...
...
@@ -493,7 +493,7 @@ fn siftdown_range(&mut self, mut pos: uint, end: uint) {
let
mut
child
=
2
*
pos
+
1
;
while
child
<
end
{
let
right
=
child
+
1
;
if
right
<
end
&&
!
(
*
self
.data
.get
(
child
)
>
*
self
.data
.get
(
right
)
)
{
if
right
<
end
&&
!
(
self
.data
[
child
]
>
self
.data
[
right
]
)
{
child
=
right
;
}
let
x
=
replace
(
self
.data
.get_mut
(
child
),
zeroed
());
...
...
src/libcollections/ringbuf.rs
浏览文件 @
f77cabec
...
...
@@ -53,7 +53,7 @@ fn clear(&mut self) {
impl
<
T
>
Deque
<
T
>
for
RingBuf
<
T
>
{
/// Return a reference to the first element in the RingBuf
fn
front
<
'a
>
(
&
'a
self
)
->
Option
<&
'a
T
>
{
if
self
.nelts
>
0
{
Some
(
self
.get
(
0
)
)
}
else
{
None
}
if
self
.nelts
>
0
{
Some
(
&
self
[
0
]
)
}
else
{
None
}
}
/// Return a mutable reference to the first element in the RingBuf
...
...
@@ -63,7 +63,7 @@ fn front_mut<'a>(&'a mut self) -> Option<&'a mut T> {
/// Return a reference to the last element in the RingBuf
fn
back
<
'a
>
(
&
'a
self
)
->
Option
<&
'a
T
>
{
if
self
.nelts
>
0
{
Some
(
self
.get
(
self
.nelts
-
1
)
)
}
else
{
None
}
if
self
.nelts
>
0
{
Some
(
&
self
[
self
.nelts
-
1
]
)
}
else
{
None
}
}
/// Return a mutable reference to the last element in the RingBuf
...
...
@@ -152,7 +152,7 @@ pub fn with_capacity(n: uint) -> RingBuf<T> {
#[deprecated
=
"prefer using indexing, e.g., ringbuf[0]"
]
pub
fn
get
<
'a
>
(
&
'a
self
,
i
:
uint
)
->
&
'a
T
{
let
idx
=
self
.raw_index
(
i
);
match
*
self
.elts
.get
(
idx
)
{
match
self
.elts
[
idx
]
{
None
=>
fail
!
(),
Some
(
ref
v
)
=>
v
}
...
...
@@ -481,6 +481,7 @@ fn hash(&self, state: &mut S) {
impl
<
A
>
Index
<
uint
,
A
>
for
RingBuf
<
A
>
{
#[inline]
#[allow(deprecated)]
fn
index
<
'a
>
(
&
'a
self
,
i
:
&
uint
)
->
&
'a
A
{
self
.get
(
*
i
)
}
...
...
@@ -506,7 +507,7 @@ fn from_iter<T: Iterator<A>>(iterator: T) -> RingBuf<A> {
impl
<
A
>
Extendable
<
A
>
for
RingBuf
<
A
>
{
fn
extend
<
T
:
Iterator
<
A
>>
(
&
mut
self
,
mut
iterator
:
T
)
{
for
elt
in
iterator
{
self
.push
_back
(
elt
);
self
.push
(
elt
);
}
}
}
...
...
src/libcollections/slice.rs
浏览文件 @
f77cabec
...
...
@@ -190,7 +190,7 @@ fn new_pos(i: uint, s: Direction) -> uint {
let
max
=
self
.sdir
.iter
()
.map
(|
&
x
|
x
)
.enumerate
()
.filter
(|
&
(
i
,
sd
)|
new_pos
(
i
,
sd
.dir
)
<
self
.sdir
.len
()
&&
self
.sdir
.get
(
new_pos
(
i
,
sd
.dir
))
.size
<
sd
.size
)
self
.sdir
[
new_pos
(
i
,
sd
.dir
)]
.size
<
sd
.size
)
.max_by
(|
&
(
_
,
sd
)|
sd
.size
);
match
max
{
Some
((
i
,
sd
))
=>
{
...
...
src/libcollections/smallintmap.rs
浏览文件 @
f77cabec
...
...
@@ -86,7 +86,7 @@ impl<V> Map<uint, V> for SmallIntMap<V> {
/// Return a reference to the value corresponding to the key.
fn
find
<
'a
>
(
&
'a
self
,
key
:
&
uint
)
->
Option
<&
'a
V
>
{
if
*
key
<
self
.v
.len
()
{
match
*
self
.v
.get
(
*
key
)
{
match
self
.v
[
*
key
]
{
Some
(
ref
value
)
=>
Some
(
value
),
None
=>
None
}
...
...
@@ -421,6 +421,7 @@ fn extend<Iter: Iterator<(uint, V)>>(&mut self, mut iter: Iter) {
impl
<
V
>
Index
<
uint
,
V
>
for
SmallIntMap
<
V
>
{
#[inline]
#[allow(deprecated)]
fn
index
<
'a
>
(
&
'a
self
,
i
:
&
uint
)
->
&
'a
V
{
self
.get
(
i
)
}
...
...
src/libcollections/str.rs
浏览文件 @
f77cabec
...
...
@@ -251,11 +251,11 @@ fn next(&mut self) -> Option<char> {
match
self
.buffer
.as_slice
()
.head
()
{
Some
(
&
(
c
,
0
))
=>
{
self
.sorted
=
false
;
self
.buffer
.
shift
(
);
self
.buffer
.
remove
(
0
);
return
Some
(
c
);
}
Some
(
&
(
c
,
_
))
if
self
.sorted
=>
{
self
.buffer
.
shift
(
);
self
.buffer
.
remove
(
0
);
return
Some
(
c
);
}
_
=>
self
.sorted
=
false
...
...
@@ -287,7 +287,7 @@ fn next(&mut self) -> Option<char> {
self
.sorted
=
true
;
}
match
self
.buffer
.
shift
(
)
{
match
self
.buffer
.
remove
(
0
)
{
Some
((
c
,
0
))
=>
{
self
.sorted
=
false
;
Some
(
c
)
...
...
@@ -805,21 +805,21 @@ fn lev_distance(&self, t: &str) -> uint {
for
(
j
,
tc
)
in
t
.chars
()
.enumerate
()
{
let
next
=
*
dcol
.get
(
j
+
1
)
;
let
next
=
dcol
[
j
+
1
]
;
if
sc
==
tc
{
*
dcol
.get_mut
(
j
+
1
)
=
current
;
}
else
{
*
dcol
.get_mut
(
j
+
1
)
=
cmp
::
min
(
current
,
next
);
*
dcol
.get_mut
(
j
+
1
)
=
cmp
::
min
(
*
dcol
.get
(
j
+
1
)
,
*
dcol
.get
(
j
)
)
+
1
;
*
dcol
.get_mut
(
j
+
1
)
=
cmp
::
min
(
dcol
[
j
+
1
]
,
dcol
[
j
]
)
+
1
;
}
current
=
next
;
}
}
return
*
dcol
.get
(
tlen
)
;
return
dcol
[
tlen
]
;
}
/// An Iterator over the string in Unicode Normalization Form D
...
...
src/libcollections/string.rs
浏览文件 @
f77cabec
...
...
@@ -669,7 +669,7 @@ pub fn pop_char(&mut self) -> Option<char> {
/// }
/// ```
pub
unsafe
fn
shift_byte
(
&
mut
self
)
->
Option
<
u8
>
{
self
.vec
.
shift
(
)
self
.vec
.
remove
(
0
)
}
/// Removes the first character from the string buffer and returns it.
...
...
src/libcollections/vec.rs
浏览文件 @
f77cabec
...
...
@@ -453,6 +453,7 @@ fn clone_from(&mut self, other: &Vec<T>) {
impl
<
T
>
Index
<
uint
,
T
>
for
Vec
<
T
>
{
#[inline]
#[allow(deprecated)]
// allow use of get
fn
index
<
'a
>
(
&
'a
self
,
index
:
&
uint
)
->
&
'a
T
{
self
.get
(
*
index
)
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录