| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
on |
| 17 |
|
| 18 |
<html> |
| 19 |
<head> |
| 20 |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
| 21 |
<meta http-equiv="Content-Language" content="en-us"> |
| 22 |
<title>set</title> |
| 23 |
</head> |
| 24 |
<body bgcolor="#DAD3C5" vlink="#0094D2" link="#003258"> |
| 25 |
<table align="left" border="0" cellspacing="0" cellpadding="0" valign=top> |
| 26 |
<tr> |
| 27 |
<td width=105 height=40><a href="https://projects.eclipse.org/projects/tools.titan"><img src="../images/titan_transparent.gif" border=0 width=105 height=40 align="left" alt="Titan"></a></td> |
| 28 |
</tr> |
| 29 |
</table> |
| 30 |
<table border="0" align="right" cellpadding="0" cellspacing="0"> |
| 31 |
<tr> |
| 32 |
<td><a href="../titan_main.html" alt="contents"><img border="0" src="../images/ao.jpg" width="53" height="40"></a></td> |
| 33 |
<td><a href="../titan_index.html" alt="index"><img border="0" src="../images/up.jpg" width="53" height="40"></a></td> |
| 34 |
<td><a href="sender.html" alt="previous"><img border="0" src="../images/left.jpg" width="53" height="40"></a></td> |
| 35 |
<td><a href="setencode.html" alt="next"><img border="0" src="../images/right.jpg" width="53" height="40"></a></td> |
| 36 |
</tr> |
| 37 |
</table> |
| 38 |
<p><br clear="all"> |
| 39 |
</p> |
| 40 |
<hr> |
| 41 |
<h1>set</h1> |
| 42 |
<hr align="left" width="75%"> |
| 43 |
<p>The keyword denotes a structured type representing an unordered sequence of elements, i.e., the ordering of the set fields is not significant. Each element consists of a type and an identifier. |
| 44 |
<ul> |
| 45 |
<li>The set may contain <a href="#Example 1">optional elements</a> which may or may not be present when assigning value to the constructs.</li> |
| 46 |
<li>Element type can be any basic or user-defined data type.</li> |
| 47 |
<li>More elements can have same type as long as their identifiers differ.</li> |
| 48 |
<li>Elements of the set may be accessed using the <a href="#Example 2">dot notation</a> or <a href="#Example 3">assignment notation</a>.</li> |
| 49 |
<li>The <a href="#Example 5">sizeof()</a> predefined function returns the actual size of the set type parameter, constant, variable or template.</li> |
| 50 |
<li>The <a href="#Example 6">ispresent()</a> predefined function returns the Boolean value true if the referenced optional field is present in the set.</li> |
| 51 |
<li>A <a href="#Example 7">set of the same element type</a> may be defined using the keyword <font face="Courier New" color="#003258" size="4"><b>of</b></font>. </li> |
| 52 |
</ul> |
| 53 |
<p>Related keywords:</p> |
| 54 |
<ul> |
| 55 |
<li><a href="address.html"><font face="Courier New" color="#003258" size="4"><b>address</b></font></a></li> |
| 56 |
<li><a href="length.html"><font face="Courier New" color="#003258" size="4"><b>length</b></font></a></li> |
| 57 |
<li><a href="sizeof.html"><font face="Courier New" color="#003258" size="4"><b>sizeof</b></font></a></li> |
| 58 |
<li><a href="of.html"><font face="Courier New" color="#003258" size="4"><b>of</b></font></a></li> |
| 59 |
<li><a href="omit.html"><font face="Courier New" color="#003258" size="4"><b>omit</b></font></a></li> |
| 60 |
<li><a href="optional.html"><font face="Courier New" color="#003258" size="4"><b>optional</b></font></a></li> |
| 61 |
<li><a href="type.html"><font face="Courier New" color="#003258" size="4"><b>type</b></font></a> </li> |
| 62 |
</ul> |
| 63 |
<hr align="left" width="50%"> |
| 64 |
<div align="center"> |
| 65 |
<center> |
| 66 |
<table border="0" width="90%" bgcolor="#FFB599" cellpadding="4"> |
| 67 |
<tr> |
| 68 |
<td width="100%"> |
| 69 |
<h3 align="center"><font face="Courier New" color="#003258" size="5"><b>type set</b> </font> (<i>identifier </i> | <font face="Courier New" color="#003258" size="5"><b>address</b></font>)<font |
| 70 |
face="Courier New" color="#003258" size="5"><b> {</b></font> <i>type_reference</i> <i>element_identifier</i> [ <font face="Courier New" color="#003258" size="5"><b>optional</b></font> |
| 71 |
] ... <font face="Courier New" color="#003258" size="5"><b>};</b></font></h3> |
| 72 |
</td> |
| 73 |
</tr> |
| 74 |
</table> |
| 75 |
</center> |
| 76 |
</div> |
| 77 |
<ul> |
| 78 |
<li> |
| 79 |
<p>The <a href="type.html"><font face="Courier New" color="#003258" size="4"><b>type</b></font></a> <font face="Courier New" color="#003258" size="4"><b>set</b></font> keywords |
| 80 |
introduce the type definition.</p> |
| 81 |
</li> |
| 82 |
<li> |
| 83 |
<p><i>identifier</i> is the name used to refer to the set. Must begin with a letter, may contain letters, numbers and underscore characters.</p> |
| 84 |
</li> |
| 85 |
<li> |
| 86 |
<p><a href="address.html"><font face="Courier New" color="#003258" size="4"><b>address</b></font></a> is a user defined type to allow addressing specific entities inside the |
| 87 |
System Under Test.</p> |
| 88 |
</li> |
| 89 |
<li> |
| 90 |
<p><i>type_reference</i> refers to an already defined (structured or simple) <a href="type.html">type</a>.</p> |
| 91 |
</li> |
| 92 |
<li> |
| 93 |
<p><i>element_identifier</i> identifies the elements of the set. The identifiers must be unique within the same set</p> |
| 94 |
</li> |
| 95 |
<li> |
| 96 |
<p><b>...</b> indicates that <i>type_reference</i> <i>element_identifier</i> pairs may be repeated. They are separated by comma.</p> |
| 97 |
</li> |
| 98 |
</ul> |
| 99 |
<hr align="left" width="75%"> |
| 100 |
<div align="center"> |
| 101 |
<center> |
| 102 |
<table border="0" width="90%" bgcolor="#FFB599" cellpadding="4"> |
| 103 |
<tr> |
| 104 |
<td width="100%"> |
| 105 |
<h3 align="center"><font face="Courier New" color="#003258" size="5"> <b>type set</b> </font> [ <font face="Courier New" color="#003258" size="5"><b>length (</b></font><i>set_size</i><font |
| 106 |
face="Courier New" color="#003258" size="5"><b>)</b></font> ] <font face="Courier New" color="#003258" size="5"> <b>of</b> </font> <i>type_reference</i> <i>identifier</i> <font |
| 107 |
face="Courier New" color="#003258" size="5"><b>};</b></font></h3> |
| 108 |
</td> |
| 109 |
</tr> |
| 110 |
</table> |
| 111 |
</center> |
| 112 |
</div> |
| 113 |
<ul> |
| 114 |
<li> |
| 115 |
<p>The <a href="type.html"><font face="Courier New" color="#003258" size="4"><b>type</b></font></a> <font face="Courier New" color="#003258" size="4"><b>set of</b></font> |
| 116 |
keywords introduce the type definition.</p> |
| 117 |
</li> |
| 118 |
<li> |
| 119 |
<p>The optional <a href="length.html"><font face="Courier New" color="#003258" size="4"><b>length</b></font></a> keyword denotes that the size of the set is restricted.</p> |
| 120 |
</li> |
| 121 |
<li> |
| 122 |
<p><i>set_size</i> is the size restriction. When a single integer value is given, it specifies the exact size of the set. When two integer values are given (separated by two dots), the minimal |
| 123 |
and the maximal length of the set are given.</p> |
| 124 |
</li> |
| 125 |
<li> |
| 126 |
<p><i>type_reference</i> refers to an already defined (structured or simple) <a href="type.html">type</a>.</p> |
| 127 |
</li> |
| 128 |
<li> |
| 129 |
<p><i>identifier</i> is the name used to refer to the set. Must begin with a letter, may contain letters, numbers and underscore characters.</p> |
| 130 |
</li> |
| 131 |
</ul> |
| 132 |
<hr align="left" width="50%"> |
| 133 |
<p><a name="Example 1">Example 1</a>: type definition |
| 134 |
<p><font face="Courier New">type set MySetType { <br> |
| 135 |
integer Number1 optional,<br> |
| 136 |
integer Number2,<br> |
| 137 |
charstring String<br> |
| 138 |
}</font> |
| 139 |
<p>The set called MySetType consists of three elements. There are two fields of type integer having the identifier Number1 (optional) and Number2 . There is one field of type character string and |
| 140 |
having the identifier String.</p> |
| 141 |
<hr align="left" width="50%"> |
| 142 |
<p><a name="Example 2">Example 2</a>: dot notation (For the type definition see example 1) |
| 143 |
<p><font face="Courier New">var MySetType v_mySet; <br> |
| 144 |
v_mySet.Number1 := omit;<br> |
| 145 |
v_mySet.Number2 := 12;</font> |
| 146 |
<p>The variable v_mySet of type MySetType is defined. The first field (Number1) is omitted and the value 12 is assigned to the field Number2.</p> |
| 147 |
<hr align="left" width="50%"> |
| 148 |
<p><a name="Example 3">Example 3</a>: assignment notation (For the type and variable definition see example 1 & 2) |
| 149 |
<p><font face="Courier New">v_mySet := {Number2 := 112};</font> |
| 150 |
<p>The value 112 is assigned to the field Number2. </p> |
| 151 |
<hr align="left" width="50%"> |
| 152 |
<p><a name="Example 5">Example 4</a>: the predefined function sizeof()</p> |
| 153 |
<p><font face="Courier New">v_mySet := {Number1 := omit, Number2 := 191, String := "s"};<br> |
| 154 |
var integer v_Stk := sizeof (v_mySet);</font> |
| 155 |
<p>The variable v_Stk equals two as there are two elements in v_mySet (the first one is omitted).</p> |
| 156 |
<hr align="left" width="50%"> |
| 157 |
<p><a name="Example 6">Example 5</a>: the predefined function ispresent()</p> |
| 158 |
<p><font face="Courier New">v_mySet := {Number1 := omit, Number2 := 191, String := "s"};<br> |
| 159 |
var boolean v_kukuccs := ispresent (v_mySet.Number1);</font> |
| 160 |
<p>The variable v_kukuccs equals false as there the referenced element in v_mySet (Number1) is omitted.</p> |
| 161 |
<hr align="left" width="50%"> |
| 162 |
<p><a name="Example 7">Example 6</a>: set of the same element type </p> |
| 163 |
<p><font face="Courier New">type set length (3) of integer IntegerList;<br> |
| 164 |
var IntegerList v_il := {71, 92, 83};<br> |
| 165 |
var integer v_elem := v_il[1];</font> |
| 166 |
<p>A set of three integers is defined. The set is called IntegerList. <br> |
| 167 |
To assign values to the elements of the set, value list notation is used. The elements of the set will have the value 71, 92 and 83, respectively. <br> |
| 168 |
Individual elements of the set may be accessed using the array notation. In the example above the variable v_elem will have the value 92.</p> |
| 169 |
<hr align="left" width="25%"> |
| 170 |
<hr align="left" width="25%"> |
| 171 |
<p><a HREF="BNF.html#setdef">BNF definition</a> of <font face="Courier New"> set</font><br> |
| 172 |
<a HREF="BNF.html#setofdef">BNF definition</a> of <font face="Courier New">set of</font></p> |
| 173 |
</body> |
| 174 |
</html> |