Skip to content

Commit

Permalink
traits can return self.
Browse files Browse the repository at this point in the history
  • Loading branch information
stevej committed Dec 7, 2012
1 parent eb87bfd commit f8fdb2f
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions pairing_heap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,17 @@ pub enum PairingHeap<E: Copy Eq Ord> {
}

pub trait Heap<E: Copy Eq Ord> {
// I would really love for these to return Heaps but my knowledge
// of Rust is too limited to make that work.

// returns true if the Heap is empty.
pure fn is_empty(&self) -> bool;

// returns a new Heap with the element inserted.
pure fn insert(elem: E) -> PairingHeap<E>;
pure fn insert(elem: E) -> self;

// returns the minimum element without a modified heap
pure fn find_min() -> Option<E>;

// returns the minimum element and a new Heap without that element.
pure fn delete_min() -> (Option<E>, PairingHeap<E>);
pure fn delete_min() -> (Option<E>, self);
}


Expand Down

0 comments on commit f8fdb2f

Please sign in to comment.