QMap Class Reference(4)

const Key QMap::key ( const T & value ) const

返回对应值 value 的第一个 key
如果 map 不包含项目,函数返回一个缺省的构建的 key
函数是慢的(线性时间),因为 QMap 的内部数据结构是最佳的为快速查找 b 通过 key ,而不是通过 value

const Key QMap::key ( const T & value, const Key & defaultKey ) const

QList<Key> QMap::keys () const

QList<Key> QMap::keys ( const T & value ) const

iterator QMap::lowerBound ( const Key & key )

返回一个迭代器指向 key 对应的第一个项目。如果 map 不包含 key 对应项目,函数返回一个迭代器到一个最近的较大的 key 对应的项目。
QMap<int, QString> map;
      
 map.insert(1, "one");
      
 map.insert(5, "five");
      
 map.insert(10, "ten");
      

    
      
    
 map.lowerBound(0);      // returns iterator to (1, "one")
      
 map.lowerBound(1);      // returns iterator to (1, "one")
      
 map.lowerBound(2);      // returns iterator to (5, "five")
      
 map.lowerBound(10);     // returns iterator to (10, "ten")
      
 map.lowerBound(999);    // returns end()
      
如果 map 包含多重项目,这个函数返回一个迭代器,指向最近的值。另一个值是可进入的通过增加迭代器。例如,这是一些代码,迭代相同 key 的所有项目:
QMap<QString, int> map;
      
 ...
      
 QMap<QString, int>::const_iterator i = map.lowerBound("HDR");
      
 QMap<QString, int>::const_iterator upperBound = map.upperBound("HDR");
      
 while (i != upperBound) {
      
     cout << i.value() << endl;
      
     ++i;
      
 }
      

const_iterator QMap::lowerBound ( const Key & key ) const

int QMap::remove ( const Key & key )

int QMap::size () const

T QMap::take ( const Key & key )

移除 key 对应的项目,返回对应的值。如果项目不存在于 map ,函数简单的返回一个缺省构造的值。如果一个 key 对应多个项目,只是最近的插入的一个被移除并返回。
如果你不使用返回值, remove ()是更有效率的。

std::map<Key, T> QMap::toStdMap () const

然会一个 stl map 等同于这个 QMap

QList<Key> QMap::uniqueKeys () const

返回一个清单,包含所有的 key 在升序。在 map 发生多次的 keys 在返回清单中只发生一次。

QMap<Key, T> & QMap::unite ( const QMap<Key, T> & other )

插入其他 map 中所有的项目到这个 map 。如果一个 key 是普遍的 maps ,结果 map 将包含 key 多次。

iterator QMap::upperBound ( const Key & key )

返回一个迭代器指向立即跟着最后一个项目的项目。如果 map 不包含 key 对应的项目,函数返回一个迭代器到最近一个较大的 key 的项目。
QMap<int, QString> map;
      
 map.insert(1, "one");
      
 map.insert(5, "five");
      
 map.insert(10, "ten");
      

    
      
    
 map.upperBound(0);      // returns iterator to (1, "one")
      
 map.upperBound(1);      // returns iterator to (5, "five")
      
 map.upperBound(2);      // returns iterator to (5, "five")
      
 map.upperBound(10);     // returns end()
      
 map.upperBound(999);    // returns end()
    

const_iterator QMap::upperBound ( const Key & key ) const

const T QMap::value ( const Key & key ) const

const T QMap::value ( const Key & key, const T & defaultValue ) const

QList<T> QMap::values () const

QList<T> QMap::values ( const Key & key ) const

bool QMap::operator!= ( const QMap<Key, T> & other ) const

QMap<Key, T> & QMap::operator= ( const QMap<Key, T> & other )

bool QMap::operator== ( const QMap<Key, T> & other ) const

T & QMap::operator[] ( const Key & key )

const T QMap::operator[] ( const Key & key ) const

相关非成员:

QDataStream & operator<< ( QDataStream & out, const QMap<Key, T> & map )

map 到流 out 中。

QDataStream & operator>> ( QDataStream & in, QMap<Key, T> & map )

读一个 map 从流 in map

你可能感兴趣的:(职场,Class,reference,休闲,QMap)