Skip to content

Commit 492a418

Browse files
committed
---
yaml --- r: 20671 b: refs/heads/snap-stage3 c: 5cf99c5 h: refs/heads/master i: 20669: 4d51cd3 20667: c23577d 20663: 135fb50 20655: 3fd2dfb 20639: b5e2f7e 20607: 01f8e56 v: v3
1 parent 90c7f18 commit 492a418

File tree

2 files changed

+13
-16
lines changed

2 files changed

+13
-16
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: e430a699f2c60890d9b86069fd0c68a70ece7120
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: de48b7d4c4bba0212080c9aeb63ac8a13bb04b06
4+
refs/heads/snap-stage3: 5cf99c585ac16ad8c990c134333e61ea3bf591fb
55
refs/heads/try: ffbe0e0e00374358b789b0037bcb3a577cd218be
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/libcore/dlist.rs

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -304,20 +304,6 @@ impl extensions<T> for dlist<T> {
304304
tl.map(|nobe| self.unlink(nobe));
305305
tl
306306
}
307-
/// Remove data from the head of the list. O(1).
308-
fn pop() -> option<T> {
309-
do option::map_consume(self.pop_n()) |nobe| {
310-
let dlist_node(@{ data: x, _ }) <- nobe;
311-
x
312-
}
313-
}
314-
/// Remove data from the tail of the list. O(1).
315-
fn pop_tail() -> option<T> {
316-
do option::map_consume(self.pop_tail_n()) |nobe| {
317-
let dlist_node(@{ data: x, _ }) <- nobe;
318-
x
319-
}
320-
}
321307
/// Get the node at the list's head. O(1).
322308
pure fn peek_n() -> option<dlist_node<T>> { self.hd }
323309
/// Get the node at the list's tail. O(1).
@@ -399,7 +385,7 @@ impl extensions<T> for dlist<T> {
399385
// Cute as it would be to simply detach the list and proclaim "O(1)!",
400386
// the GC would still be a hidden O(n). Better to be honest about it.
401387
while !self.is_empty() {
402-
let _ = self.pop();
388+
let _ = self.pop_n();
403389
}
404390
}
405391

@@ -457,6 +443,10 @@ impl extensions<T> for dlist<T> {
457443
}
458444

459445
impl extensions<T: copy> for dlist<T> {
446+
/// Remove data from the head of the list. O(1).
447+
fn pop() -> option<T> { self.pop_n().map (|nobe| nobe.data) }
448+
/// Remove data from the tail of the list. O(1).
449+
fn pop_tail() -> option<T> { self.pop_tail_n().map (|nobe| nobe.data) }
460450
/// Get data at the list's head. O(1).
461451
pure fn peek() -> option<T> { self.peek_n().map (|nobe| nobe.data) }
462452
/// Get data at the list's tail. O(1).
@@ -622,6 +612,13 @@ mod tests {
622612
a.assert_consistent(); assert a.is_empty();
623613
}
624614
#[test]
615+
fn test_dlist_clear() {
616+
let a = from_vec(~[5,4,3,2,1]);
617+
a.clear();
618+
assert a.len() == 0;
619+
a.assert_consistent();
620+
}
621+
#[test]
625622
fn test_dlist_is_empty() {
626623
let empty = new_dlist::<int>();
627624
let full1 = from_vec(~[1,2,3]);

0 commit comments

Comments
 (0)