第 6 章:整数集合¶
一个整数集合示例,包含五个 int16_t
类型的整数值。
![digraph {
label = "\n 图 6-1 一个包含五个 int16_t 类型整数值的整数集合";
rankdir = LR;
node [shape = record];
intset [label = " intset | encoding \n INTSET_ENC_INT16 | length \n 5 | <contents> contents "];
//contents [label = " { { 0 位至 15 位 | <arrow> -6370 } | { 16 位至 31 位 | -5 } | { 32 位至 47 位 | 18 } | { 48 至 63 位 | 233 } | { 64 位至 79 位 | 14632 } } "];
//intset:contents -> contents:arrow;
contents [label = " { -6370 | -5 | 18 | 233 | 14632 } "];
intset:contents -> contents;
}](_images/graphviz-4f428e29fda006deae6c9f60c298ff3882306797.png)
另一个整数集合示例,包含四个 int64_t
类型的整数值。
![digraph {
label = "\n 图 6-2 一个包含四个 int64_t 类型整数值的整数集合";
rankdir = LR;
node [shape = record];
intset [label = " intset | encoding \n INTSET_ENC_INT64 | length \n 4 | <contents> contents "];
contents [label = " { -2675256175807981027 | 1 | 3 | 5 } "];
intset:contents -> contents:arrow;
}](_images/graphviz-9f39e2fa512a283c9a16fd96f879e23c79ba28bb.png)
当向一个包含三个 int16_t
类型的值的整数集合添加一个 int32_t
类型的值时,
整数集合的扩展和转换过程。
![digraph {
label = "\n 图 6-4 contents 数组的各个元素,以及它们所在的位";
node [shape = record];
contents [label = " { 位 | 元素 } | { 0 至 15 位 | 1 } | { 16 至 31 位 | 2 } | { 32 至 47 位 | 3 } "];
}](_images/graphviz-b3f83f39f4d500bf9c2eecb63f603d841da6f5e4.png)
![digraph {
label = "\n 图 6-5 进行空间重分配之后的数组";
node [shape = record];
contents [label = " { 位 | 元素 } | { 0 至 15 位 | 1 } | { 16 至 31 位 | 2 } | { 32 至 47 位 | 3 } | { 48 至 127 位 | (新分配空间)} "];
}](_images/graphviz-abbe6f3532ba0111cc8d6f1c2bfe081793f735cb.png)
![digraph {
label = "\n 图 6-6 对元素 3 进行类型转换,并保存在适当的位上";
node [shape = record];
contents [label = " { 位 | 元素 } | { 0 至 15 位 | 1 } | { 16 至 31 位 | 2 } | { 32 至 47 位 | <old> 3 } | { 48 至 63 位 | (新分配空间) } | { 64 位至 95 位 | <new> 3 } | { 96 位至 127 位 | (新分配空间)} "];
contents:old -> contents:new [label = "从 int16_t 类型转换为 int32_t 类型"];
}](_images/graphviz-8b9a2a93992ede79d888fd4d4f1068ed90ac0485.png)
![digraph {
label = "\n 图 6-7 对元素 2 进行类型转换,并保存在适当的位上";
node [shape = record];
contents [label = " { 位 | 元素 } | { 0 至 15 位 | 1 } | { 16 至 31 位 | <old> 2 } | { 32 至 63 位 | <new> 2 } | { 64 位至 95 位 | 3 } | { 96 位至 127 位 | (新分配空间)} "];
contents:old -> contents:new [label = "从 int16_t 类型转换为 int32_t 类型"];
}](_images/graphviz-97545695f6ccb6c228382b4fbaa99b3663811f71.png)
![digraph {
label = "\n 图 6-8 对元素 1 进行类型转换,并保存在适当的位上";
node [shape = record];
contents [label = " { 位 | 元素 } | { 0 至 31 位 | <old> 1 } | { 32 至 63 位 | 2 } | { 64 位至 95 位 | 3 } | { 96 位至 127 位 | (新分配空间)} "];
//contents:old -> contents:new [label = "从 int16_t 类型转换为 int32_t 类型"];
contents:old -> contents:old [label = "从 int16_t 类型转换为 int32_t 类型"];
}](_images/graphviz-6e753cb638cb99acc09ddac31651c9f1479524fd.png)
![digraph {
label = "\n 图 6-9 添加 65535 到数组";
rankdir = BT;
node [shape = record];
set [label = "添加新元素", shape = plaintext];
contents [label = " { 位 | 元素 } | { 0 至 31 位 | 1 } | { 32 至 63 位 | 2 } | { 64 位至 95 位 | 3 } | { 96 位至 127 位 | <new> 65535 } "];
set -> contents:new;
}](_images/graphviz-97b8d80f9370bcffd26993723adfc5b962a05fdf.png)
一个整数集合示例,包含五个 int16_t
类型的整数值。
另一个整数集合示例,包含四个 int64_t
类型的整数值。
当向一个包含三个 int16_t
类型的值的整数集合添加一个 int32_t
类型的值时,
整数集合的扩展和转换过程。