In the simplist dynamic memory implementation of a queue, the data part of the linked list record is a simple type (integer, real, booean, etc). As an example, in the type below the data part of the linked list record node is an integer. There are two queue pointers to the list : front points to the first node, and rear to the last node on the linked list.
type pointer = ^node; Node = RECORD Data : integer; Next : pointer END (* Node *); Queue = RECORD Front, Rear : pointer; END (* Queue *);In a slightly more complex implementation of a queue, the data part is a pointer to a tree node, and as seen below is of type Nodeptr.
TYPE (* Records for trees *) NodePtr = ^Parent; Parent = RECORD Info: integer; Left, Right: NodePtr END; (* Records for queues *) Pointer = ^Node; Node = RECORD Data: NodePtr; Next: Pointer END (* Node *); Queue = RECORD Front, Rear:Pointer END (* Queue *);Again, front points to the first node on the linked list, and rear, to the last node. Assume in the following that var q : queue. In both cases, q.front := nil (and q.rear := nil) initializes the queue; Append(q, x) adds a node whose data part has the value x to the end of the queue; and Remove(q, x) removes the first node from the list. The type of x, of course, varies with the type definition. In the former case, its integer; in the latter, NodePtr.