Originale-mail to me for new edition

 

Set types

 

A set is a bit array where each bit indicates whether an element is in the set or not. The maximum number of elements in a set is 256, so a set never occupies more than 32 bytes. The number of bytes occupied by a particular set is equal to

(Max div 8) - (Min div 8) + 1

where Max and Min are the upper and lower bounds of the base type of the set. The byte number of a specific element E is

(E div 8) - (Min div 8)

and the bit number within that byte is

E mod 8

where E denotes the ordinal value of the element. When possible, the compiler stores sets in CPU registers, but a set always resides in memory if it is larger than the generic Integer type or if the program contains code that takes the address of the set.

 

Topic groups

 

See also

Memory management: Overview

Sets

Variables

 

 

译文

 

集合类型

 

一个集合就是一个比特数组,该数组中的每个比特位表示一个元素是否在集合中。集合元素的最大数量是256,因此一个集合占用的空间不可能超过32个字节。指定集合占用的字节数等价于

(Max div 8) - (Min div 8) + 1

这里的MaxMin分别是集合基类型的上界和下界。指定元素E的字节编码是

(E div 8) - (Min div 8)

并且元素E在该字节中的位(比特)编号是

E mod 8

这里,E表示的是元素的序数值。如果可能,编译器在CPU寄存器中存储集合,但如果集合大于一般的Integer类型,或者如果程序中包含了操作集合地址的代码,那么集合总是驻留在内存中。

 

主题组

 

相关主题

内存管理:概述

集合

变量