<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Recent changes to Sets</title><link>https://sourceforge.net/p/asil/wiki/Sets/</link><description>Recent changes to Sets</description><atom:link href="https://sourceforge.net/p/asil/wiki/Sets/feed" rel="self"/><language>en</language><lastBuildDate>Sun, 23 Feb 2014 11:53:45 -0000</lastBuildDate><atom:link href="https://sourceforge.net/p/asil/wiki/Sets/feed" rel="self" type="application/rss+xml"/><item><title>Sets modified by Will Pittenger</title><link>https://sourceforge.net/p/asil/wiki/Sets/</link><description>&lt;div class="markdown_content"&gt;&lt;div class="toc"&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="#overview"&gt;Overview&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#set-variables"&gt;Set variables&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#allocating-memory-for-sets"&gt;Allocating memory for sets&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#declaring-and-using-a-fixed-set"&gt;Declaring and using a fixed set&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#available-operators"&gt;Available operators&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#sets-and-reference-types"&gt;Sets and reference types&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#classes-used-for-set-types"&gt;Classes used for set types&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;h2 id="overview"&gt;Overview&lt;/h2&gt;
&lt;p&gt;ASIL provides the same level of support for sets that it provides arrays.  You can even make set constants.  ASIL sets come in two forms: normal and fixed.  A fixed set is actually a type.  Normal sets can be based on nothing or a fixed set.  If you base a normal set on a fixed set, ASIL knows what &lt;u&gt;can not&lt;/u&gt; be inside the set.  Fixed sets are immutable.  Both types of sets can be any type of variable, even &lt;strong&gt;&lt;a class="" href="/p/asil/wiki/keywords-conditional/"&gt;conditional&lt;/a&gt;&lt;/strong&gt; variables.&lt;/p&gt;
&lt;h2 id="set-variables"&gt;Set variables&lt;/h2&gt;
&lt;p&gt;You declare these with the &lt;strong&gt;&lt;a class="" href="../operators-braces"&gt;{}&lt;/a&gt;&lt;/strong&gt; operator.  If you postfix the braces with "&lt;code&gt;f&lt;/code&gt;", ASIL will actually create a fixed set.  Like the &lt;strong&gt;&lt;a class="" href="/p/asil/wiki/operators-brackets/"&gt;[]&lt;/a&gt;&lt;/strong&gt; operator, the braces go after the rest of the &lt;a class="" href="../Appendices-Terms-Type%20descriptors"&gt;Type descriptor&lt;/a&gt;, but before the identifier, so you get the &lt;strong&gt;&lt;a class="" href="../operators-bracesf"&gt;{}f&lt;/a&gt;&lt;/strong&gt; operator.  To declare a normal set based on a fixed set, place the identifier for the fixed set inside the braces.  The fixed set must already have been declared and initialized.&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;var int{} aSet
var int{}f FixedSet
&lt;/pre&gt;&lt;/div&gt;
&lt;h2 id="allocating-memory-for-sets"&gt;Allocating memory for sets&lt;/h2&gt;
&lt;p&gt;The syntax here is similar, but the data to place into the set goes after the braces as a comma delimited list.  The contents aren't required for normal sets, but are for fixed sets.  Again, if the set will be based on a fixed set, place the identifier of the fixed set inside the braces.&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;new int{} 5, 3, 7, 99
new int{}f 5, 3, 7, 99
&lt;/pre&gt;&lt;/div&gt;
&lt;h2 id="declaring-and-using-a-fixed-set"&gt;Declaring and using a fixed set&lt;/h2&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;var int{}f MyFixedSet = new int{}f 5, 3, 7, 99
var int{MyFixedSet} MyFixedSetInstance = new int{} 5, 3
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;So &lt;code&gt;MyFixedSetInstance&lt;/code&gt; can only contain the members listed when MyFixedSet was initialized.  If you tried to put &lt;code&gt;19&lt;/code&gt; into the set, an exception would be thrown.&lt;/p&gt;
&lt;h2 id="available-operators"&gt;Available operators&lt;/h2&gt;
&lt;p&gt;ASIL makes several types of operators available for use with sets.  These operators are declared as members of the Set class.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Operator&lt;/th&gt;
&lt;th&gt;Meaning&lt;/th&gt;
&lt;th&gt;Sample&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;&lt;a class="" href="/p/asil/wiki/operators-and/"&gt;and&lt;/a&gt;&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Returns a new set that contains only those elements that are in both operands.  Operands must both be sets based on the same fixed set or no fixed set at all and have the same base type (like &lt;code&gt;int&lt;/code&gt;).&lt;/td&gt;
&lt;td&gt;&lt;code&gt;a and b&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;&lt;a class="" href="/p/asil/wiki/operators-or/"&gt;or&lt;/a&gt;&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Returns a new set that contains all elements that are in either operand.  Operands must both be sets based on the same fixed set or no fixed set at all and have the same base type (like &lt;code&gt;int&lt;/code&gt;).&lt;/td&gt;
&lt;td&gt;&lt;code&gt;a or b&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;&lt;a class="" href="/p/asil/wiki/operators-not/"&gt;not&lt;/a&gt;&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Returns a new set which contains all the elements that weren't part of the operand and no more elements.  The operand must be a set based on a fixed set.&lt;/td&gt;
&lt;td&gt;&lt;code&gt;not a&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;&lt;a class="" href="/p/asil/wiki/operators-lt/"&gt;&amp;lt;&lt;/a&gt;&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Returns true if all the members in the left operand are in the right operand and false otherwise.  The operands must either have the same base type (like &lt;code&gt;int&lt;/code&gt;) and be based on the same fixed set or no fixed set at all.  The left operand can be either a set or an instance of the base type for the right operand.&lt;/td&gt;
&lt;td&gt;&lt;code&gt;a &amp;lt; b&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;&lt;a class="" href="../operators-lt-equals"&gt;&amp;lt;=&lt;/a&gt;&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Returns true if the sets are identical or &lt;strong&gt;&lt;a class="" href="/p/asil/wiki/operators-lt/"&gt;&amp;lt;&lt;/a&gt;&lt;/strong&gt; would return true.&lt;/td&gt;
&lt;td&gt;&lt;code&gt;a &amp;lt;= b&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;&lt;a class="" href="/p/asil/wiki/operators-gt/"&gt;&amp;gt;&lt;/a&gt;&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Identical to &lt;strong&gt;&lt;a class="" href="/p/asil/wiki/operators-lt/"&gt;&amp;lt;&lt;/a&gt;&lt;/strong&gt;, but with the operands reversed.&lt;/td&gt;
&lt;td&gt;&lt;code&gt;a &amp;gt; b&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;&lt;a class="" href="../operators-gt-equals"&gt;&amp;gt;=&lt;/a&gt;&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Identical to &lt;strong&gt;&lt;a class="" href="../operators-lt-equals"&gt;&amp;gt;&lt;/a&gt;&lt;/strong&gt;, but with the operands reversed.&lt;/td&gt;
&lt;td&gt;&lt;code&gt;a &amp;gt;= b&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h2 id="sets-and-reference-types"&gt;Sets and reference types&lt;/h2&gt;
&lt;p&gt;If you declare a set based on a reference type like "&lt;code&gt;String{}&lt;/code&gt;", the set is a set of references, not instances.&lt;/p&gt;
&lt;h2 id="classes-used-for-set-types"&gt;Classes used for set types&lt;/h2&gt;
&lt;p&gt;Fixed sets derive from "&lt;code&gt;FixedSet&amp;lt;T&amp;gt;&lt;/code&gt;" where &lt;code&gt;T&lt;/code&gt; is the base type.  Normal sets derive from either "&lt;code&gt;Set&amp;lt;T&amp;gt;&lt;/code&gt;" (when not based on a fixed set) or "&lt;code&gt;FixedSet&amp;lt;T&amp;gt;.Instance&amp;lt;FixedSetInstance&amp;gt;&lt;/code&gt;" where &lt;code&gt;FixedSetInstance&lt;/code&gt; is the type you declared when you created the fixed set.  Remember, fixed sets are types.&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Will Pittenger</dc:creator><pubDate>Sun, 23 Feb 2014 11:53:45 -0000</pubDate><guid>https://sourceforge.netaaa9a8db0746501f2ff764326d6b2e48c6c00702</guid></item></channel></rss>