Public Member Functions | List of all members
minx.core.hooks.priority_queue Class Reference

A helper class for Minx's hooks implementation. More...

Public Member Functions

def __init__
 Create an empty priority queue.
 
def add
 Add an element with specified priority. More...
 
def max_priority
 Return priority of highest-priority item in priority queue. More...
 
def min_priority
 Return priority of lowest-priority item in priority queue. More...
 
def __iter__
 Iterator interface to priority queue. More...
 

Detailed Description

A helper class for Minx's hooks implementation.

This class implements a priority queue that the hooks class can use to prioritize its hook function lists.

Note
This class is not a general-purpose priority queue implementation. It is specifically designed for use by the minx.core.hooks.hooks class. It is also not meant to be used by end-users, who should treat it as internal to Minx.

Member Function Documentation

def minx.core.hooks.priority_queue.__iter__ (   self)

Iterator interface to priority queue.

This function returns an iterator for accessing the priority queue's elements in order of descending priority.

def minx.core.hooks.priority_queue.add (   self,
  v,
  p 
)

Add an element with specified priority.

Parameters
vThe value to be added to the priority queue.
pThe priority of the value to be added.
Returns
False if priority queue already contains v; True otherwise.

This function adds v with priority p to the priority queue. This function does not perform any checks on the value of p, requiring its caller to implement appropriate policies regarding priorities.

If the priority queue already contains v, it will not be added again. Thus, clients can make repeated calls to this function with the same value without having to worry about creating duplicate entries.

def minx.core.hooks.priority_queue.max_priority (   self)

Return priority of highest-priority item in priority queue.

If the priority queue is empty, this function will return -1.

def minx.core.hooks.priority_queue.min_priority (   self)

Return priority of lowest-priority item in priority queue.

If the priority queue is empty, this function will return -1.