Q3PtrQueue Class

The Q3PtrQueue class is a template class that provides a queue. 更多...

頭: #include <Q3PtrQueue>
繼承: Q3PtrCollection

公共函數

Q3PtrQueue ()
Q3PtrQueue (const Q3PtrQueue<type> & queue )
~Q3PtrQueue ()
bool autoDelete () const
type * current () const
type * dequeue ()
void enqueue (const type * d )
type * head () const
bool isEmpty () const
bool remove ()
void setAutoDelete (bool enable )
operator type * () const
Q3PtrQueue<type> & operator= (const Q3PtrQueue<type> & queue )

重實現公共函數

virtual void clear ()
virtual uint count () const

重實現保護函數

virtual QDataStream & read (QDataStream & s , Q3PtrCollection::Item & item )
virtual QDataStream & write (QDataStream & s , Q3PtrCollection::Item item ) const

詳細描述

The Q3PtrQueue class is a template class that provides a queue.

Q3ValueVector can be used as an STL-compatible alternative to this class.

A template instance Q3PtrQueue <X> is a queue that operates on pointers to X (X*).

A queue is a first in, first out structure. Items are added to the tail of the queue with enqueue () and retrieved from the head with dequeue (). You can peek at the head item without dequeing it using head ().

You can control the queue's deletion policy with setAutoDelete ().

For compatibility with the Q3PtrCollection 類, current () 和 remove () are provided; both operate on the head ().

另請參閱 Q3PtrList and Q3PtrStack .

成員函數文檔編製

Q3PtrQueue:: Q3PtrQueue ()

Creates an empty queue with autoDelete () set to FALSE.

Q3PtrQueue:: Q3PtrQueue (const Q3PtrQueue < type > & queue )

Creates a queue from queue .

Only the pointers are copied; the items are not. The autoDelete () flag is set to FALSE.

Q3PtrQueue:: ~Q3PtrQueue ()

Destroys the queue. Items in the queue are deleted if autoDelete () is TRUE.

bool Q3PtrQueue:: autoDelete () const

Returns the setting of the auto-delete option. The default is FALSE.

另請參閱 setAutoDelete ().

[虛擬] void Q3PtrQueue:: clear ()

重實現自 Q3PtrCollection::clear ().

Removes all items from the queue, and deletes them if autoDelete () is TRUE.

另請參閱 remove ().

[虛擬] uint Q3PtrQueue:: count () const

重實現自 Q3PtrCollection::count ().

Returns the number of items in the queue.

另請參閱 isEmpty ().

type * Q3PtrQueue:: current () const

Returns a pointer to the head item in the queue. The queue is not changed. Returns 0 if the queue is empty.

另請參閱 dequeue () 和 isEmpty ().

type * Q3PtrQueue:: dequeue ()

Takes the head item from the queue and returns a pointer to it. Returns 0 if the queue is empty.

另請參閱 enqueue () 和 count ().

void Q3PtrQueue:: enqueue (const type * d )

Adds item d 到隊列末尾。

另請參閱 count () 和 dequeue ().

Returns a pointer to the head item in the queue. The queue is not changed. Returns 0 if the queue is empty.

另請參閱 dequeue () 和 isEmpty ().

bool Q3PtrQueue:: isEmpty () const

Returns TRUE if the queue is empty; otherwise returns FALSE.

另請參閱 count (), dequeue (),和 head ().

[virtual protected] QDataStream & Q3PtrQueue:: read ( QDataStream & s , Q3PtrCollection::Item & item )

Reads a queue item, item , from the stream s 並返迴流引用。

The default implementation sets item 為 0。

另請參閱 write ().

bool Q3PtrQueue:: remove ()

Removes the head item from the queue, and returns TRUE if there was an item, i.e. the queue wasn't empty; otherwise returns FALSE.

The item is deleted if autoDelete () is TRUE.

另請參閱 head (), isEmpty (),和 dequeue ().

void Q3PtrQueue:: setAutoDelete ( bool enable )

Sets the queue to auto-delete its contents if enable is TRUE and not to delete them if enable is FALSE.

If auto-deleting is turned on, all the items in a queue are deleted when the queue itself is deleted. This can be quite convenient if the queue has the only pointer to the items.

The default setting is FALSE, for safety. If you turn it on, be careful about copying the queue: you might find yourself with two queues deleting the same items.

另請參閱 autoDelete ().

[virtual protected] QDataStream & Q3PtrQueue:: write ( QDataStream & s , Q3PtrCollection::Item item ) const

Writes a queue item, item , to the stream s 並返迴流引用。

默認實現什麼都不做。

另請參閱 read ().

Q3PtrQueue:: operator type * () const

Returns a pointer to the head item in the queue. The queue is not changed. Returns 0 if the queue is empty.

另請參閱 dequeue () 和 isEmpty ().

Q3PtrQueue < type > & Q3PtrQueue:: operator= (const Q3PtrQueue < type > & queue )

賦值 queue to this queue and returns a reference to this queue.

This queue is first cleared and then each item in queue is enqueued to this queue. Only the pointers are copied.

警告: The autoDelete () flag is not modified. If it is TRUE for both queue and this queue, deleting the two lists will cause double-deletion of the items.