Sets

A set is a collection of values of the same ordinal type. The values have no inherent order, nor is it meaningful for a value to be included twice in a set.

The range of a set type is the power set of a specific ordinal type, called the base type; that is, the possible values of the set type are all the subsets of the base type, including the empty set. The base type can have no more than 256 possible values, and their ordinalities must fall between 0 and 255. Any construction of the form set of baseType where baseType is an appropriate ordinal type, identifies a set type.

Because of the size limitations for base types, set types are usually defined with subranges. For example, the declarations type

TSomeInts = 1..250; TIntSet = set of TSomeInts;

create a set type called TIntSet whose values are collections of integers in the range from 1 to 250. You could accomplish the same thing with type TIntSet = set of 1..250;

Given this declaration, you can create a sets like this:

var Setl, Set2: TIntSet;

You can also use the set of ... construction directly in variable declarations:

var MySet: set of 'a'..'z'; MySet := ['a','b','c'];

Other examples of set types include set of Byte set of (Club, Diamond, Heart, Spade) set of Char;

The in operator tests set membership:

Every set type can hold the empty set, denoted by [].

Project Management Made Easy

Project Management Made Easy

What you need to know about… Project Management Made Easy! Project management consists of more than just a large building project and can encompass small projects as well. No matter what the size of your project, you need to have some sort of project management. How you manage your project has everything to do with its outcome.

Get My Free Ebook


Post a comment