久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

STL 還是 Qt 容器?

STL or Qt containers?(STL 還是 Qt 容器?)
本文介紹了STL 還是 Qt 容器?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

使用 Qt 容器(QMapQVector 等)與其等效的 STL 相比有哪些優缺點?

What are the pros and cons of using Qt containers (QMap, QVector, etc.) over their STL equivalent?

我可以看到一個喜歡 Qt 的原因:

I can see one reason to prefer Qt:

  • Qt 容器可以傳遞到 Qt 的其他部分.例如,它們可用于填充 QVariantQSettings(但有一些限制,只有 QListQMap/QHash 其鍵是字符串被接受).
  • Qt containers can be passed along to other parts of Qt. For example, they can be used to populate a QVariant and then a QSettings (with some limitation though, only QList and QMap/QHash whose keys are strings are accepted).

還有嗎?

編輯:假設應用程序已經依賴于 Qt.

Edit: Assuming the application already relies on Qt.

推薦答案

我開始時只使用 std::(w)string 和 STL 容器并轉換為/從 Qt 等效項,但是我已經切換到 QString 并且我發現我越來越多地使用 Qt 的容器.

I started by using std::(w)string and the STL containers exclusively and converting to/from the Qt equivalents, but I have already switched to QString and I find that I'm using Qt's containers more and more.

當談到字符串時,QString 提供了比 std::basic_string 更完整的功能,而且它是完全 Unicode 感知.它還提供了一個 高效的 COW 實施,這是我非常依賴的.

When it comes to strings, QString offers much more complete functionality compared to std::basic_string and it is completely Unicode aware. It also offers an efficient COW implementation, which I've come to rely on heavily.

Qt 的容器:

  • 提供與 QString 相同的 COW 實現,這在使用 Qt 的 foreach 宏時非常有用(進行復制)以及使用元類型或信號和槽時.
  • 可以使用 STL 風格的迭代器或 Java 風格的迭代器
  • 可以使用 QDataStream
  • 流式傳輸
  • 在 Qt 的 API 中被廣泛使用
  • 在各種操作系統上都有穩定的實現.STL 實現必須遵守 C++ 標準,但否則可以隨心所欲(參見 std::string COW 爭議).一些 STL 實現特別是不好.
  • 提供哈希值,除非使用 TR1 否則無法使用
  • offer the same COW implementation as in QString, which is extremely useful when it comes to using Qt's foreach macro (which does a copy) and when using meta-types or signals and slots.
  • can use STL-style iterators or Java-style iterators
  • are streamable with QDataStream
  • are used extensively in Qt's API
  • have a stable implementation across operating systems. A STL implementation must obey the C++ standard, but is otherwise free to do as it pleases (see the std::string COW controversy). Some STL implementations are especially bad.
  • provide hashes, which are not available unless you use TR1

QTL 與 STL 有不同的哲學,這是總結得很好 作者:J. Blanchette:雖然 STL 的容器針對原始速度進行了優化,但 Qt 的容器類經過精心設計,以提供便利、最少的內存使用和最少的代碼擴展."
上面的鏈接提供了有關 QTL 實現和使用了哪些優化的更多詳細信息.

The QTL has a different philosophy from the STL, which is well summarized by J. Blanchette: "Whereas STL's containers are optimized for raw speed, Qt's container classes have been carefully designed to provide convenience, minimal memory usage, and minimal code expansion."
The above link provides more details about the implementation of the QTL and what optimizations are used.

這篇關于STL 還是 Qt 容器?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How can I read and manipulate CSV file data in C++?(如何在 C++ 中讀取和操作 CSV 文件數據?)
In C++ why can#39;t I write a for() loop like this: for( int i = 1, double i2 = 0; (在 C++ 中,為什么我不能像這樣編寫 for() 循環: for( int i = 1, double i2 = 0;)
How does OpenMP handle nested loops?(OpenMP 如何處理嵌套循環?)
Reusing thread in loop c++(在循環 C++ 中重用線程)
Precise thread sleep needed. Max 1ms error(需要精確的線程睡眠.最大 1ms 誤差)
Is there ever a need for a quot;do {...} while ( )quot; loop?(是否需要“do {...} while ()?環形?)
主站蜘蛛池模板: 欧美第一页 | 国产精品小视频在线观看 | 国产精品夜夜春夜夜爽久久电影 | 久草免费福利 | 四虎影音| 国产精品亚洲成在人线 | 男人天堂网址 | 国产区一区二区三区 | 亚洲免费大片 | 日韩视频一级 | h片免费在线观看 | 日韩国产欧美一区 | 成人性视频在线 | 成人影院网站ww555久久精品 | 高清国产一区二区 | 国产日韩精品一区 | 久久精品99久久 | 欧美亚洲另类丝袜综合网动图 | 久日精品| 久久性色| 亚洲播放一区 | 日韩快播电影网 | 高清av电影 | 免费久久久久久 | 日韩精品一区在线观看 | 久久国产精品-国产精品 | 91私密视频| 午夜久久久 | 成人黄色在线 | 黄色成人免费在线观看 | 精品一二三区 | 一区二区三区韩国 | 一级毛片观看 | 亚洲一区 中文字幕 | 亚洲一区二区日韩 | 欧美日韩不卡在线 | 美女视频一区 | 国产一区二区三区网站 | 欧美日韩视频网站 | 国产亚洲人成a在线v网站 | 黄色一级视频免费 |