<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                [TOC] ## 概述 1. 不能使用 map[key] 這種形式查找映射里是否包含鍵 key 的元素,因為 operator[](const Key & key) 函數在找不到 key 元素時,自動調用 value 類默認構造函數為映射添加 key-value 新元素 2. 一般不建議使用 QMap 的 insertMulti() 和 unite() 函數進行多重映射添加或映射合并,Qt 單獨提供了 QMultiMap 表示多重映射,在程序中盡量讓 QMap 保持一對一映射,避免代碼的誤解 常用函數 ``` // 構造函數 QMap<QString, int> nameAge; QMap() //默認構造函數 QMap(std::initializer_list<std::pair<Key, T> > list) //初始化列表構造函數 QMap(const QMap<Key, T> & other) //復制構造函數 QMap(QMap<Key, T> && other) //移動構造函數 QMap(const std::map<Key, T> & other) //根據標準庫的映射構造 QMap // 添加函數 iterator insert(const Key & key, const T & value) //直接插入一對 key - value iterator insert(const_iterator pos, const Key & key, const T & value)//在建議的迭代器 pos 位置插入一對 key - value T & QMap::?operator[](const Key & key) //[] 運算符重載 //移除和刪除函數 T take(const Key & key) int remove(const Key & key) void clear() // 訪問和查詢函數 bool contains(const Key & key) const QList<Key> keys() const ``` ## 示例 示例1 ``` QMap<QString, int> nameAge{ {"Alice", 20}, {"Bob", 22}, {"Cell", 19} }; qDebug()<<nameAge; QMap<QString, int> nameAgeOther = std::move( nameAge ); qDebug()<<nameAge; qDebug()<<nameAgeOther; ``` 示例2 ``` QMap<QString, int> nameAge; nameAge.insert( "Alice", 20 ); nameAge["Bob"] = 22; nameAge["Cell"] = 19; ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看