Class: PoorPriorityQueue

### Home Classes Methods

### In Files

- lib/priority_queue/poor_priority_queue.rb

### Parent

Hash

### Methods

- #delete
- #delete_min
- #delete_min_return_key
- #delete_min_return_priority
- #min
- #min_key
- #min_priority
- #push

### Files

- Makefile

### Class/Module Index

Quicksearch

- Object
- PoorPriorityQueue

No matching classes.

# PoorPriorityQueue

A Poor mans Priority Queue. (Very inefficent but minimal implemention).

### Public Instance Methods

delete(object) click to toggle source

    # File lib/priority_queue/poor_priority_queue.rb, line 40
    def delete(object)
      return nil unless self.has_key?(object)
      result = [object, self[object]]
      super
      result
    end

delete_min() click to toggle source

    # File lib/priority_queue/poor_priority_queue.rb, line 25
    def delete_min
      return nil if self.empty?
      min_k, min_p = *min
      self.delete(min_k)
      [min_k, min_p]
    end

delete_min_return_key() click to toggle source

    # File lib/priority_queue/poor_priority_queue.rb, line 32
    def delete_min_return_key
      delete_min[0] rescue nil
    end

delete_min_return_priority() click to toggle source

    # File lib/priority_queue/poor_priority_queue.rb, line 36
    def delete_min_return_priority
      delete_min[1] rescue nil
    end

min() click to toggle source

    # File lib/priority_queue/poor_priority_queue.rb, line 7
    def min
      return nil if self.empty?
      min_k = self.keys.first
      min_p = self[min_k]
      self.each do | k, p |
        min_k, min_p = k, p if p < min_p
      end
      [min_k, min_p]
    end

min_key() click to toggle source

    # File lib/priority_queue/poor_priority_queue.rb, line 17
    def min_key
      min[0] rescue nil
    end

min_priority() click to toggle source

    # File lib/priority_queue/poor_priority_queue.rb, line 21
    def min_priority
      min[1] rescue nil
    end

push(object, priority) click to toggle source

    # File lib/priority_queue/poor_priority_queue.rb, line 3
    def push(object, priority)
      self[object] = priority
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.