Sync with 5.4.0
[deliverable/titan.core.git] / help / info / set.html
1 <!--
2 Copyright (c) 2000-2015 Ericsson Telecom AB
3
4 All rights reserved. This program and the accompanying materials
5 are made available under the terms of the Eclipse Public License v1.0
6 which accompanies this distribution, and is available at
7 http://www.eclipse.org/legal/epl-v10.html
8 -->
9 <html>
10 <head>
11 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
12 <meta http-equiv="Content-Language" content="en-us">
13 <title>set</title>
14 </head>
15 <body bgcolor="#DAD3C5" vlink="#0094D2" link="#003258">
16 <table align="left" border="0" cellspacing="0" cellpadding="0" valign=top>
17 <tr>
18 <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>
19 </tr>
20 </table>
21 <table border="0" align="right" cellpadding="0" cellspacing="0">
22 <tr>
23 <td><a href="../titan_main.html" alt="contents"><img border="0" src="../images/ao.jpg" width="53" height="40"></a></td>
24 <td><a href="../titan_index.html" alt="index"><img border="0" src="../images/up.jpg" width="53" height="40"></a></td>
25 <td><a href="sender.html" alt="previous"><img border="0" src="../images/left.jpg" width="53" height="40"></a></td>
26 <td><a href="setverdict.html" alt="next"><img border="0" src="../images/right.jpg" width="53" height="40"></a></td>
27 </tr>
28 </table>
29 <p><br clear="all">
30 </p>
31 <hr>
32 <h1>set</h1>
33 <hr align="left" width="75%">
34 <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.
35 <ul>
36 <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>
37 <li>Element type can be any basic or user-defined data type.</li>
38 <li>More elements can have same type as long as their identifiers differ.</li>
39 <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>
40 <li>The <a href="#Example 5">sizeof()</a> predefined function returns the actual size of the set type parameter, constant, variable or template.</li>
41 <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>
42 <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>.&nbsp;</li>
43 </ul>
44 <p>Related keywords:</p>
45 <ul>
46 <li><a href="address.html"><font face="Courier New" color="#003258" size="4"><b>address</b></font></a></li>
47 <li><a href="length.html"><font face="Courier New" color="#003258" size="4"><b>length</b></font></a></li>
48 <li><a href="sizeof.html"><font face="Courier New" color="#003258" size="4"><b>sizeof</b></font></a></li>
49 <li><a href="of.html"><font face="Courier New" color="#003258" size="4"><b>of</b></font></a></li>
50 <li><a href="omit.html"><font face="Courier New" color="#003258" size="4"><b>omit</b></font></a></li>
51 <li><a href="optional.html"><font face="Courier New" color="#003258" size="4"><b>optional</b></font></a></li>
52 <li><a href="type.html"><font face="Courier New" color="#003258" size="4"><b>type</b></font></a> &nbsp;</li>
53 </ul>
54 <hr align="left" width="50%">
55 <div align="center">
56 <center>
57 <table border="0" width="90%" bgcolor="#FFB599" cellpadding="4">
58 <tr>
59 <td width="100%">
60 <h3 align="center"><font face="Courier New" color="#003258" size="5"><b>type set</b>&nbsp;</font> (<i>identifier&nbsp;</i> | <font face="Courier New" color="#003258" size="5"><b>address</b></font>)<font
61 face="Courier New" color="#003258" size="5"><b> {</b></font>&nbsp; <i>type_reference</i>&nbsp; <i>element_identifier</i> [ <font face="Courier New" color="#003258" size="5"><b>optional</b></font>
62 ] ... <font face="Courier New" color="#003258" size="5"><b>};</b></font></h3>
63 </td>
64 </tr>
65 </table>
66 </center>
67 </div>
68 <ul>
69 <li>
70 <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
71 introduce the type definition.</p>
72 </li>
73 <li>
74 <p><i>identifier</i> is the&nbsp;name used to refer to the set. Must begin with a letter, may contain letters, numbers and underscore characters.</p>
75 </li>
76 <li>
77 <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
78 System Under Test.</p>
79 </li>
80 <li>
81 <p><i>type_reference</i> refers to an already defined (structured or simple) <a href="type.html">type</a>.</p>
82 </li>
83 <li>
84 <p><i>element_identifier</i> identifies the elements of the set. The identifiers must be unique within the same set</p>
85 </li>
86 <li>
87 <p><b>...</b> indicates that&nbsp; <i>type_reference</i> <i>element_identifier</i> pairs may be repeated. They are separated by comma.</p>
88 </li>
89 </ul>
90 <hr align="left" width="75%">
91 <div align="center">
92 <center>
93 <table border="0" width="90%" bgcolor="#FFB599" cellpadding="4">
94 <tr>
95 <td width="100%">
96 <h3 align="center"><font face="Courier New" color="#003258" size="5"> <b>type set</b>&nbsp;</font> [ <font face="Courier New" color="#003258" size="5"><b>length (</b></font><i>set_size</i><font
97 face="Courier New" color="#003258" size="5"><b>)</b></font> ]&nbsp; <font face="Courier New" color="#003258" size="5"> <b>of</b>&nbsp;</font> <i>type_reference</i>&nbsp; <i>identifier</i> <font
98 face="Courier New" color="#003258" size="5"><b>};</b></font></h3>
99 </td>
100 </tr>
101 </table>
102 </center>
103 </div>
104 <ul>
105 <li>
106 <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>
107 keywords introduce the type definition.</p>
108 </li>
109 <li>
110 <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>
111 </li>
112 <li>
113 <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
114 and the maximal length of the set are given.</p>
115 </li>
116 <li>
117 <p><i>type_reference</i> refers to an already defined (structured or simple) <a href="type.html">type</a>.</p>
118 </li>
119 <li>
120 <p><i>identifier</i> is the&nbsp;name used to refer to the set. Must begin with a letter, may contain letters, numbers and underscore characters.</p>
121 </li>
122 </ul>
123 <hr align="left" width="50%">
124 <p><a name="Example 1">Example 1</a>: type definition
125 <p><font face="Courier New">type set MySetType {&nbsp;<br>
126 &nbsp;&nbsp;&nbsp;integer Number1 optional,<br>
127 &nbsp;&nbsp;&nbsp;integer Number2,<br>
128 &nbsp;&nbsp;&nbsp;charstring String<br>
129 }</font>
130 <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
131 having the identifier String.</p>
132 <hr align="left" width="50%">
133 <p><a name="Example 2">Example 2</a>: dot notation (For the type definition see example 1)
134 <p><font face="Courier New">var MySetType v_mySet;&nbsp;<br>
135 v_mySet.Number1 := omit;<br>
136 v_mySet.Number2 := 12;</font>
137 <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>
138 <hr align="left" width="50%">
139 <p><a name="Example 3">Example 3</a>: assignment notation (For the type and variable definition see example 1 &amp; 2)
140 <p><font face="Courier New">v_mySet := {Number2 := 112};</font>
141 <p>The value 112 is assigned to the field Number2.&nbsp;</p>
142 <hr align="left" width="50%">
143 <p><a name="Example 5">Example 4</a>: the predefined function sizeof()</p>
144 <p><font face="Courier New">v_mySet := {Number1 := omit, Number2 := 191, String := &quot;s&quot;};<br>
145 var integer v_Stk := sizeof (v_mySet);</font>
146 <p>The variable v_Stk equals two as there are two elements in v_mySet (the first one is omitted).</p>
147 <hr align="left" width="50%">
148 <p><a name="Example 6">Example 5</a>: the predefined function ispresent()</p>
149 <p><font face="Courier New">v_mySet := {Number1 := omit, Number2 := 191, String := &quot;s&quot;};<br>
150 var boolean v_kukuccs := ispresent (v_mySet.Number1);</font>
151 <p>The variable v_kukuccs equals false as there the referenced element in v_mySet (Number1) is omitted.</p>
152 <hr align="left" width="50%">
153 <p><a name="Example 7">Example 6</a>: set of the same element type&nbsp;</p>
154 <p><font face="Courier New">type set length (3) of integer IntegerList;<br>
155 var IntegerList v_il := {71, 92, 83};<br>
156 var integer v_elem := v_il[1];</font>
157 <p>A set of three integers is defined. The set is called IntegerList.&nbsp;<br>
158 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.&nbsp;<br>
159 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>
160 <hr align="left" width="25%">
161 <hr align="left" width="25%">
162 <p><a HREF="BNF.html#setdef">BNF definition</a> of <font face="Courier New"> set</font><br>
163 <a HREF="BNF.html#setofdef">BNF definition</a> of <font face="Courier New">set of</font></p>
164 </body>
165 </html>
This page took 0.050944 seconds and 5 git commands to generate.