Site Menu Project Specification Implementation Recommendations Reference Needs Updating Work in Progress Wastebasket Wiki Manual |
Priority QueueSpec.PriorityQueue HistoryHide minor edits - Show changes to markup 2010-05-24 13:28
by -
Changed lines 1-4 from:
[@DEFINITION MODULE Priority Queue; FROM Collections IMPORT Collection Data?, Status; to:
[@DEFINITION MODULE (* Generic Priority Queue Template *) (* --------------------------------------------------------------------------- * This template is expanded by the M 2 R 10? template engine utility. Expansion * can be invoked from within a compiling source file using the MAKE pragma: * <* MAKE = "m2te Priority Queue module:'Foo PQ?' component:'Foo Record?'" *> * IMPORT Foo PQ?; * ------------------------------------------------------------------------ *) FROM Collections IMPORT Capacity, Status; Changed lines 17-19 from:
defaultSize = <implementation defined>; maximumSize = <implementation defined>; to:
(* --------------------------------------------------------------------------- * Default queue size * ------------------------------------------------------------------------ *) defaultCapacity = 256; (* 256 entries *) (* --------------------------------------------------------------------------- * Maximum queue size * ------------------------------------------------------------------------ *) maximumCapacity = 1024*1024*1024; (* more than 1 billion entries *) (* --------------------------------------------------------------------------- * Synonyms for status codes * ------------------------------------------------------------------------ *) invalidQueue = invalidCollection; queueEmpty = collectionEmpty; queueFull = collectionFull; Changed lines 42-60 from:
Priority Queue = OPAQUE; Compare Proc? = PROCEDURE ( item1, item2 : Collection Data? ) : BOOLEAN; PROCEDURE new( size : LONGCARD; compare : Compare Proc?; VAR status : Status ) : Priority Queue; PROCEDURE enqueue( queue : Priority Queue; value : Collection Data?; VAR status : Status ); PROCEDURE inspectNext( queue : Priority Queue; VAR status : Status ) : Collection Data?; PROCEDURE dequeue( queue : Priority Queue; VAR status : Status ) : Collection Data?; PROCEDURE capacity( queue : Priority Queue ) : LONGCARD; PROCEDURE numberOfEntries( queue : Priority Queue ) : LONGCARD; PROCEDURE dispose( VAR queue : Priority Queue ); END Priority Queue.@] to:
(* --------------------------------------------------------------------------- * Opaque handle type: (* --------------------------------------------------------------------------- * Priority Comparison Handler type * --------------------------------------------------------------------------- * * Priority comparison handlers are called by priority queues whenever the * priority of a value needs to be determined. The handler associated with a * priority queue is authoritative to determine priority for the queue. * * Handlers take two arguments of type Data Ptr? and return: * * o TRUE to indicate <value1> has higher than or equal priority to <value2> * o FALSE to indicate <value1> has lower priority than <value2> *) Comparison Handler? = PROCEDURE ( (* value1 *) Value Type?, (* value2 *) Value Type? ) : BOOLEAN ; (* --------------------------------------------------------------------------- * function: PROCEDURE new ( size : Capacity; handler : Comparison Handler?;
VAR status : Status ) : (* --------------------------------------------------------------------------- * function: PROCEDURE enqueue ( queue : (* --------------------------------------------------------------------------- * function: PROCEDURE inspectNext ( queue : (* --------------------------------------------------------------------------- * function: PROCEDURE dequeue ( queue : (* --------------------------------------------------------------------------- * function: PROCEDURE capacity ( queue : (* --------------------------------------------------------------------------- * function: PROCEDURE entryCount ( queue : (* --------------------------------------------------------------------------- * function: PROCEDURE isResizable ( queue : (* --------------------------------------------------------------------------- * function: PROCEDURE dispose ( VAR queue : END |