QT的容器

  • QList <T > is implemented using an array, with space preallocated at both ends. It is optimized for index-based random access and, for lists with less than a thousand items, it also gives good performance with operations like prepend() and append() .

  • QStringList is a convenience class that is derived from QList <QString >.

  • QLinkedList <T > is optimized for sequential access with iterators and quick, constant-time inserts anywhere in the list. Sorting and searching are slow. It has several convenience functions for frequently-used operations.

  • QVector <T > stores its data in contiguous memory locations and is optimized for random access by index. Generally, QVector objects are constructed with an initial size. There is no automatic preallocation of memory at either end so insertions, appends, and prepends are expensive.

  • QStack <T > is publicly derived from QVector <T > so the public interface of QVector is available to QStack objects. However, the Last-in-first-out semantics are offered by the push(), pop() , and top() functions.

  • QMap <Key,T > is an ordered associative container that stores (key, value) pairs and is designed for fast lookup of the value associated with a key. It is also designed to support reasonably fast insertions and removals. It keeps its keys in sorted order, for fast searching and subranging, by means of a skip-list dictionary which is probabilistically balanced and uses memory very efficiently. The Key type must have an operator<() and operator==() .

  • QHash <Key,T > is also an associative container that uses a hash table to facilitate key lookups. It provides very fast lookups (exact key match) and insertions, but slow searching, and no sorting. The Key type must have an operator==() .

  • QMultiMap <Key,T > is a subclass of QMap and QMultiHash <Key,T > is a subclass of QHash . These two classes allow multiple values to be associated with a single key.

  • QCache <Key,T > is also an associative container but it provides fastest access to recently used items and automatic removal of infrequently used items based on cost functions.

  • QSet <T > stores values of type T using a QHash with keys in T and a dummy value associated with each key. This arrangement optimizes lookups and insertions. QSet has functionss for the usual set operations (e.g., union, intersection, set difference, etc.). The default constructor creates an empty set.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值