The Queue class may implement buffer management and scheduling but do not implement the low-level operations on a particular queue. The PacketQueue class is used for this purpose, and is defined as follows (see queue.h):
class PacketQueue { public: PacketQueue(); int length(); /* queue length in packets */ void enque(Packet* p); Packet* deque(); Packet* lookup(int n); /* remove a specific packet, which must be in the queue */ void remove(Packet*); protected: Packet* head_; Packet** tail_; int len_; // packet count };This class maintains a linked-list of packets, and is commonly used by particular scheduling and buffer management disciplines to hold an ordered set of packets. Particular scheduling or buffer management schemes may make use of several PacketQueue objects. The PacketQueue class maintains current counts of the number of packets held in the queue which is returned by the []length method. The enque function places the specified packet at the end of the queue and updates the len_ member variable. The deque function returns the packet at the head of the queue and removes it from the queue (and updates the counters), or returns NULL if the queue is empty. The lookup function returns the nth packet from the head of the queue, or NULL otherwise. The remove function deletes the packet stored in the given address from the queue (and updates the counters). It causes an abnormal program termination if the packet does not exist.