Movatterモバイル変換


[0]ホーム

URL:


We bake cookies in your browser for a better experience. Using this site means that you consent.Read More

Menu

Qt Documentation

  • Qt 4.8
  • Qt3SupportLight
  • Q3PtrQueue

Q3PtrQueue Class

TheQ3PtrQueue class is a template class that provides a queue.More...

Header:#include <Q3PtrQueue>
Inherits:Q3PtrCollection

Public Functions

Q3PtrQueue()
Q3PtrQueue(const Q3PtrQueue<type> & queue)
~Q3PtrQueue()
boolautoDelete() const
type *current() const
type *dequeue()
voidenqueue(const type * d)
type *head() const
boolisEmpty() const
boolremove()
voidsetAutoDelete(bool enable)
operator type *() const
Q3PtrQueue<type> &operator=(const Q3PtrQueue<type> & queue)

Reimplemented Public Functions

virtual voidclear()
virtual uintcount() const

Reimplemented Protected Functions

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

Detailed Description

TheQ3PtrQueue class is a template class that provides a queue.

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

A template instanceQ3PtrQueue<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 withenqueue() and retrieved from the head withdequeue(). You can peek at the head item without dequeing it usinghead().

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

For compatibility with theQ3PtrCollection classes,current() andremove() are provided; both operate on thehead().

See alsoQ3PtrList andQ3PtrStack.

Member Function Documentation

Q3PtrQueue::Q3PtrQueue()

Creates an empty queue withautoDelete() set to FALSE.

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

Creates a queue fromqueue.

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

Q3PtrQueue::~Q3PtrQueue()

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

bool Q3PtrQueue::autoDelete() const

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

See alsosetAutoDelete().

[virtual]void Q3PtrQueue::clear()

Reimplemented fromQ3PtrCollection::clear().

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

See alsoremove().

[virtual]uint Q3PtrQueue::count() const

Reimplemented fromQ3PtrCollection::count().

Returns the number of items in the queue.

See alsoisEmpty().

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.

See alsodequeue() andisEmpty().

type * Q3PtrQueue::dequeue()

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

See alsoenqueue() andcount().

void Q3PtrQueue::enqueue(consttype * d)

Adds itemd to the tail of the queue.

See alsocount() anddequeue().

type * Q3PtrQueue::head() const

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

See alsodequeue() andisEmpty().

bool Q3PtrQueue::isEmpty() const

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

See alsocount(),dequeue(), andhead().

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

Reads a queue item,item, from the streams and returns a reference to the stream.

The default implementation setsitem to 0.

See alsowrite().

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 ifautoDelete() is TRUE.

See alsohead(),isEmpty(), anddequeue().

void Q3PtrQueue::setAutoDelete(bool enable)

Sets the queue to auto-delete its contents ifenable is TRUE and not to delete them ifenable 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.

See alsoautoDelete().

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

Writes a queue item,item, to the streams and returns a reference to the stream.

The default implementation does nothing.

See alsoread().

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.

See alsodequeue() andisEmpty().

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

Assignsqueue to this queue and returns a reference to this queue.

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

Warning: TheautoDelete() flag is not modified. If it is TRUE for bothqueue and this queue, deleting the two lists will causedouble-deletion of the items.

© 2016 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of theGNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.


[8]ページ先頭

©2009-2025 Movatter.jp