tailieunhanh - The book of qt 4 the art of building qt applications - phần 10

ngăn xếp cấu trúc dữ liệu, tuy nhiên. Vì lý do này mà bạn nên sử dụng các phương pháp cung cấp trực tiếp bởi QStack. Như một iterator Java-phong cách, QVectorIterator được sử dụng, nó có chức năng ngữ nghĩa của lớp cơ sở QVector. | B Tulip Containers and Algorithms stack data structure however. For this reason it is recommended that you use the methods provided directly by QStack. As a Java-style iterator QVectorlterator is used it functions with the semantics of the QVector base class. Queues QQueue In many applications you will not be able to avoid having to use a queue. The possibilities are wide ranging-queues are used to implement buffers 5 as temporary memory for tree-based algorithms such as breadth-first search and much more. Qt provides the QQueue class for queues. This is merely a specialization of the QList. It is easy to see the thinking behind this design decision because a QList performs well when inserting and deleting at the beginning and end of the list. To get a value into the front of the queue the enqueue method is used. As a parameter it expects a value of the type that was used as the type parameter in the declaration of the queue. dequeue removes the last element from the queue and returns it. As a Java-style iterator the iterator of the base class is used in the same way as QStack that is QListlterator. Associative Arrays At first glance the container classes QMap and QHash seem to serve the same purpose They save a list of key-value pairs in which access to the resulting collection of values is usually performed by specifying not an index but a key Nevertheless there are differences between the two classes both in their implementation and in their performance in specific circumstances. Dictionaries QMap QMap provides a dictionary and is the slower of the two data structures but it also sorts the key-value pairs automatically This is of particular relevance to the programmer if he wants to iterate over the data structure When using QMap iterators the output is already sorted by key. The following example shows how a QMap that associates a string to an integer value is created 5 Not to be confused with QBuffer which represents an input output device see

TỪ KHÓA LIÊN QUAN
crossorigin="anonymous">
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.