Delphi Language Guide Delphi for Microsoft Win32 Delphi for the Microsoft. Net framework



Yüklə 0,84 Mb.
Pdf görüntüsü
səhifə68/294
tarix02.01.2022
ölçüsü0,84 Mb.
#41395
1   ...   64   65   66   67   68   69   70   71   ...   294
DelphiLanguageGuide

Set Operators
Operator Operation
Operand Types Result Type Example
+
union
set
set
Set1 + Set2
-
difference
set
set
S - T
*
intersection set
set
S * T
<=
subset
set
Boolean
Q <= MySet
>=
superset
set
Boolean
S1 >= S2
=
equality
set
Boolean
S2 = MySet
<>
inequality
set
Boolean
MySet <> S1
in
membership ordinal, set
Boolean
A in Set1
The following rules apply to +-, and *.
An ordinal 
O
 is in 
X + Y
 if and only if 
O
 is in 
X
 or 
Y
 (or both). 
O
 is in 
X - Y
 if and only if 
O
 is in 
X
 but not in 
Y
.
O
 is in 
X * Y
 if and only if 
O
 is in both 
X
 and 
Y
.
The result of a +-, or * operation is of the type 
set of A..B
, where 
A
 is the smallest ordinal value in the result
set and 
B
 is the largest.
The following rules apply to <=>==<>, and in.
X <= Y
 is True just in case every member of 
X
 is a member of 
Y

Z >= W
 is equivalent to 
W <= Z

U = V
 is
True just in case 
U
 and 
V
 contain exactly the same members; otherwise, 
U <> V
 is True.
For an ordinal 
O
 and a set 
S

O in S
 is True just in case 
O
 is a member of 
S
.
Relational Operators
Relational operators are used to compare two operands. The operators =<><=, and >= also apply to sets.
Relational Operators
Operator Operation
Operand Types
Result Type Example
=
equality
simple, class, class reference, interface, string, packed string Boolean
I = Max
52


<>
inequality
simple, class, class reference, interface, string, packed string Boolean
X <> Y
<
less-than
simple, string, packed string, PChar
Boolean
X < Y
>
greater-than
simple, string, packed string, PChar
Boolean
Len > 0
<=
less-than-or-equal-to
simple, string, packed string, PChar
Boolean
Cnt <= I
>=
greater-than-or-equal-to simple, string, packed string, PChar
Boolean
I >= 1
For most simple types, comparison is straightforward. For example, 
I = J
 is True just in case 
I
 and 
J
 have the
same value, and 
I <> J
 is True otherwise. The following rules apply to relational operators.
Operands must be of compatible types, except that a real and an integer can be compared.
Strings are compared according to the ordinal values that make up the characters that make up the string.
Character types are treated as strings of length 1.
Two packed strings must have the same number of components to be compared. When a packed string with
n
 components is compared to a string, the packed string is treated as a string of length 
n
.
Use the operators <><=, and >= to compare PChar (and PWideChar) operands only if the two pointers point
within the same character array.
The operators = and <> can take operands of class and class-reference types. With operands of a class
type, = and <> are evaluated according the rules that apply to pointers: 
C = D
 is True just in case 
C
 and 
D
 point
to the same instance object, and 
C <> D
 is True otherwise. With operands of a class-reference type
C = D
is True just in case 
C
 and 
D
 denote the same class, and 
C <> D
 is True otherwise. This does not compare the
data stored in the classes. For more information about classes, see Classes and objects.
Class Operators
The operators as and is take classes and instance objects as operands; as operates on interfaces as well. For more
information, see Classes and objects and Object interfaces.
The relational operators = and <> also operate on classes.

Yüklə 0,84 Mb.

Dostları ilə paylaş:
1   ...   64   65   66   67   68   69   70   71   ...   294




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©azkurs.org 2024
rəhbərliyinə müraciət

gir | qeydiyyatdan keç
    Ana səhifə


yükləyin