Skip to content

Commit 9b33413

Browse files
committed
---
yaml --- r: 31441 b: refs/heads/dist-snap c: 5cf99c5 h: refs/heads/master i: 31439: c8a6c75 v: v3
1 parent 0f94e76 commit 9b33413

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
@@ -7,6 +7,6 @@ refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: d0c6ce338884ee21843f4b40bf6bf18d222ce5df
99
refs/heads/incoming: d9317a174e434d4c99fc1a37fd7dc0d2f5328d37
10-
refs/heads/dist-snap: de48b7d4c4bba0212080c9aeb63ac8a13bb04b06
10+
refs/heads/dist-snap: 5cf99c585ac16ad8c990c134333e61ea3bf591fb
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/dist-snap/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)