Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Design Notes 設計說明

Boost.Intrusive in performance sensitive environments 性能敏感環境下的 Boost.Intrusive
Boost.Intrusive in space constrained environments 空間受限環境下的 Boost.Intrusive
Boost.Intrusive as a basic building block 作為基本構建塊的 Boost.Intrusive
Extending Boost.Intrusive 擴展 Boost.Intrusive

When designing Boost.Intrusive the following guidelines have been taken into account:
在設計 Boost.Intrusive 時,下列準則已被考慮到:

Boost.Intrusive should be a valuable tool in performance sensitive environments, and following this guideline, Boost.Intrusive has been designed to offer well known complexity guarantees. Apart from that, some options, like optional constant-time, have been designed to offer faster complexity guarantees in some functions, like slist::splice.
Boost.Intrusive 應該是性能敏感環境下的一個有用的工具,依據這一準則,Boost.Intrusive 被設計為提供眾所周知的時間複雜度保證。除此以外,還設計了一些選項,如可選的常量時間,以為某些函數提供更快的時間複雜度保證,如 slist::splice

The advanced lookup and insertion functions for associative containers, taking an arbitrary key type and predicates, were designed to avoid unnecessary object constructions.
關聯容器的高級查找和高級插入函數,接受任意的鍵值類型和謂詞,這一設計是為了避免不必要的對象構造。

Boost.Intrusive should be useful in space constrained environments, and following this guideline Boost.Intrusive separates node algorithms and intrusive containers to avoid instantiating node algorithms for each user type. For example, a single class of red-black algorithms will be instantiated to implement all set and multiset containers using raw pointers. This way, Boost.Intrusive seeks to avoid any code size overhead associated with templates.
Boost.Intrusive 在空間受限環境下應該是有用的,依據這一準則,Boost.Intrusive 分離了節點算法和介入式容器,以避免為每個用戶類型實例化節點算法。例如,只實例化一個紅黑樹算法類,就可以實現所有使用裸指針的 set 和 multiset 容器。使用這一方式,Boost.Intrusive 避免了與模板相關的任何代碼空間的開銷。

Apart from that, Boost.Intrusive implements some size improvements: for example, red-black trees embed the color bit in the parent pointer lower bit, if nodes are two-byte aligned. The option to forgo constant-time size operations can reduce container size, and this extra size optimization is noticeable when the container is empty or contains few values.
此外,Boost.Intrusive 實現了一些空間改進:例如,如果節點是雙字節對齊的,紅黑樹就將顏色位嵌入到父指針的低位。放棄常量時間的 size 操作的選項可以縮小容器的大小,當容器為空或只包含少量值的時間,這個空間優化是很顯著的。

Boost.Intrusive can be a basic building block to build more complex containers and this potential has motivated many design decisions. For example, the ability to have more than one hook per user type opens the opportunity to implement multi-index containers on top of Boost.Intrusive.
Boost.Intrusive 可以被作為基本構建塊來構建更為複雜的容器,這一潛能已經推動了許多設計決定。例如,每個用戶類型可以具有多個鉤子就提供了在 Boost.Intrusive 之上實現多索引容器的機會。

Boost.Intrusive containers implement advanced functions taking function objects as arguments (clone_from, erase_and_dispose, insert_check, etc.). These functions come in handy when implementing non-intrusive containers (for example, STL-like containers) on top of intrusive containers.
Boost.Intrusive 容器實現了以函數對像為參數的高級函數(clone_from, erase_and_dispose, insert_check, 等等)。當要在介入式容器之上實現非介入式容器(如類似於STL的容器)時,這些函數就非常方便使用。

Boost.Intrusive offers a wide range of containers but also allows the construction of custom containers reusing Boost.Intrusive elements. The programer might want to use node algorithms directly or build special hooks that take advantage of an application environment.
Boost.Intrusive 提供了大量的容器,但是也允許重用 Boost.Intrusive 元素來構造定制化的容器。程序員可能想直接使用節點算法,或者構建利用應用程序環境的特殊鉤子。

For example, the programmer can customize parts of Boost.Intrusive to manage old data structures whose definition can't be changed.
例如,程序員可以定制化 Boost.Intrusive 的一部分,以管理那些不能修改定義的舊數據結構。


PrevUpHomeNext