import{_ as l,o as p,c as o,k as s,a,X as n}from"./chunks/framework.6e839c56.js";const S=JSON.parse('{"title":"Set","description":"","frontmatter":{},"headers":[],"relativePath":"en/api/packages/datastructure/set.md","filePath":"en/api/packages/datastructure/set.md"}'),e={name:"en/api/packages/datastructure/set.md"},t=s("h1",{id:"Set",tabindex:"-1"},[a("Set "),s("a",{class:"header-anchor",href:"#Set","aria-label":'Permalink to "Set"'},"​")],-1),c=s("p",null,"Set is a data container, like list, but elements of set is not duplicate.",-1),r=s("div",{STYLE:"page-break-after: always;"},null,-1),y=s("h2",{id:"Source",tabindex:"-1"},[a("Source "),s("a",{class:"header-anchor",href:"#Source","aria-label":'Permalink to "Source"'},"​")],-1),F=s("ul",null,[s("li",null,[s("a",{href:"https://github.com/duke-git/lancet/blob/main/datastructure/set/set.go",target:"_blank",rel:"noreferrer"},"https://github.com/duke-git/lancet/blob/main/datastructure/set/set.go")])],-1),i=s("div",{STYLE:"page-break-after: always;"},null,-1),A=n(`<h2 id="Usage" tabindex="-1">Usage <a class="header-anchor" href="#Usage" aria-label="Permalink to &quot;Usage&quot;">​</a></h2><div class="language-go vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">go</span><pre class="shiki dracula-soft vp-code-dark"><code><span class="line"><span style="color:#F286C4;">import</span><span style="color:#F6F6F4;"> (</span></span>
<span class="line"><span style="color:#F6F6F4;">    set </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/set</span><span style="color:#DEE492;">&quot;</span></span>
<span class="line"><span style="color:#F6F6F4;">)</span></span></code></pre><pre class="shiki vitesse-light vp-code-light"><code><span class="line"><span style="color:#1E754F;">import</span><span style="color:#393A34;"> </span><span style="color:#999999;">(</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#59873A;">set</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/set</span><span style="color:#B5695999;">&quot;</span></span>
<span class="line"><span style="color:#999999;">)</span></span></code></pre></div>`,2),E=s("div",{STYLE:"page-break-after: always;"},null,-1),d=n('<h2 id="Index" tabindex="-1">Index <a class="header-anchor" href="#Index" aria-label="Permalink to &quot;Index&quot;">​</a></h2><ul><li><a href="#NewSet">NewSet</a></li><li><a href="#NewSetFromSlice">NewSetFromSlice</a></li><li><a href="#Values">Values</a></li><li><a href="#Add">Add</a></li><li><a href="#AddIfNotExist">AddIfNotExist</a></li><li><a href="#AddIfNotExistBy">AddIfNotExistBy</a></li><li><a href="#Delete">Delete</a></li><li><a href="#Contain">Contain</a></li><li><a href="#ContainAll">ContainAll</a></li><li><a href="#Clone">Clone</a></li><li><a href="#Size">Size</a></li><li><a href="#Equal">Equal</a></li><li><a href="#Iterate">Iterate</a></li><li><a href="#EachWithBreak">EachWithBreak</a></li><li><a href="#IsEmpty">IsEmpty</a></li><li><a href="#Union">Union</a></li><li><a href="#Intersection">Intersection</a></li><li><a href="#SymmetricDifference">SymmetricDifference</a></li><li><a href="#Minus">Minus</a></li></ul>',2),u=s("div",{STYLE:"page-break-after: always;"},null,-1),g=n(`<h2 id="Documentation" tabindex="-1">Documentation <a class="header-anchor" href="#Documentation" aria-label="Permalink to &quot;Documentation&quot;">​</a></h2><h3 id="NewSet" tabindex="-1"><span id="NewSet">NewSet</span> <a class="header-anchor" href="#NewSet" aria-label="Permalink to &quot;&lt;span id=&quot;NewSet&quot;&gt;NewSet&lt;/span&gt;&quot;">​</a></h3><p>Create a set instance</p><p><b>Signature:</b></p><div class="language-go vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">go</span><pre class="shiki dracula-soft vp-code-dark"><code><span class="line"><span style="color:#F286C4;">type</span><span style="color:#F6F6F4;"> </span><span style="color:#97E1F1;font-style:italic;">Set</span><span style="color:#F6F6F4;">[T comparable] </span><span style="color:#F286C4;">map</span><span style="color:#F6F6F4;">[T]</span><span style="color:#97E1F1;font-style:italic;">bool</span></span>
<span class="line"><span style="color:#F286C4;">func</span><span style="color:#F6F6F4;"> NewSet[T comparable](items </span><span style="color:#F286C4;">...</span><span style="color:#F6F6F4;">T) Set[T]</span></span></code></pre><pre class="shiki vitesse-light vp-code-light"><code><span class="line"><span style="color:#1E754F;">type</span><span style="color:#393A34;"> </span><span style="color:#2E8F82;">Set</span><span style="color:#999999;">[</span><span style="color:#393A34;">T comparable</span><span style="color:#999999;">]</span><span style="color:#393A34;"> </span><span style="color:#1E754F;">map</span><span style="color:#999999;">[</span><span style="color:#393A34;">T</span><span style="color:#999999;">]</span><span style="color:#AB5959;">bool</span></span>
<span class="line"><span style="color:#1E754F;">func</span><span style="color:#393A34;"> NewSet</span><span style="color:#999999;">[</span><span style="color:#393A34;">T comparable</span><span style="color:#999999;">](</span><span style="color:#393A34;">items </span><span style="color:#AB5959;">...</span><span style="color:#393A34;">T</span><span style="color:#999999;">)</span><span style="color:#393A34;"> Set</span><span style="color:#999999;">[</span><span style="color:#393A34;">T</span><span style="color:#999999;">]</span></span></code></pre></div><p><b>Example:</b></p><div class="language-go vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">go</span><pre class="shiki dracula-soft vp-code-dark"><code><span class="line"><span style="color:#F286C4;">package</span><span style="color:#F6F6F4;"> main</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F286C4;">import</span><span style="color:#F6F6F4;"> (</span></span>
<span class="line"><span style="color:#F6F6F4;">    </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">fmt</span><span style="color:#DEE492;">&quot;</span></span>
<span class="line"><span style="color:#F6F6F4;">    set </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/set</span><span style="color:#DEE492;">&quot;</span></span>
<span class="line"><span style="color:#F6F6F4;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F286C4;">func</span><span style="color:#F6F6F4;"> </span><span style="color:#62E884;">main</span><span style="color:#F6F6F4;">() {</span></span>
<span class="line"><span style="color:#F6F6F4;">    st </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> set.NewSet[</span><span style="color:#97E1F1;font-style:italic;">int</span><span style="color:#F6F6F4;">](</span><span style="color:#BF9EEE;">1</span><span style="color:#F6F6F4;">,</span><span style="color:#BF9EEE;">2</span><span style="color:#F6F6F4;">,</span><span style="color:#BF9EEE;">2</span><span style="color:#F6F6F4;">,</span><span style="color:#BF9EEE;">3</span><span style="color:#F6F6F4;">)</span></span>
<span class="line"><span style="color:#F6F6F4;">    fmt.</span><span style="color:#97E1F1;">Println</span><span style="color:#F6F6F4;">(st.</span><span style="color:#97E1F1;">Values</span><span style="color:#F6F6F4;">()) </span><span style="color:#7B7F8B;">//1,2,3</span></span>
<span class="line"><span style="color:#F6F6F4;">}</span></span></code></pre><pre class="shiki vitesse-light vp-code-light"><code><span class="line"><span style="color:#1E754F;">package</span><span style="color:#393A34;"> </span><span style="color:#59873A;">main</span></span>
<span class="line"></span>
<span class="line"><span style="color:#1E754F;">import</span><span style="color:#393A34;"> </span><span style="color:#999999;">(</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">fmt</span><span style="color:#B5695999;">&quot;</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#59873A;">set</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/set</span><span style="color:#B5695999;">&quot;</span></span>
<span class="line"><span style="color:#999999;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#1E754F;">func</span><span style="color:#393A34;"> </span><span style="color:#59873A;">main</span><span style="color:#999999;">()</span><span style="color:#393A34;"> </span><span style="color:#999999;">{</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B07D48;">st</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> set</span><span style="color:#999999;">.</span><span style="color:#393A34;">NewSet</span><span style="color:#999999;">[</span><span style="color:#AB5959;">int</span><span style="color:#999999;">](</span><span style="color:#2F798A;">1</span><span style="color:#999999;">,</span><span style="color:#2F798A;">2</span><span style="color:#999999;">,</span><span style="color:#2F798A;">2</span><span style="color:#999999;">,</span><span style="color:#2F798A;">3</span><span style="color:#999999;">)</span></span>
<span class="line"><span style="color:#393A34;">    fmt</span><span style="color:#999999;">.</span><span style="color:#998418;">Println</span><span style="color:#999999;">(</span><span style="color:#393A34;">st</span><span style="color:#999999;">.</span><span style="color:#998418;">Values</span><span style="color:#999999;">())</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">//1,2,3</span></span>
<span class="line"><span style="color:#999999;">}</span></span></code></pre></div><h3 id="NewSetFromSlice" tabindex="-1"><span id="NewSetFromSlice">NewSetFromSlice</span> <a class="header-anchor" href="#NewSetFromSlice" aria-label="Permalink to &quot;&lt;span id=&quot;NewSetFromSlice&quot;&gt;NewSetFromSlice&lt;/span&gt;&quot;">​</a></h3><p>Create a set from slice</p><p><b>Signature:</b></p><div class="language-go vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">go</span><pre class="shiki dracula-soft vp-code-dark"><code><span class="line"><span style="color:#F286C4;">func</span><span style="color:#F6F6F4;"> NewSetFromSlice[T comparable](items []T) Set[T]</span></span></code></pre><pre class="shiki vitesse-light vp-code-light"><code><span class="line"><span style="color:#1E754F;">func</span><span style="color:#393A34;"> NewSetFromSlice</span><span style="color:#999999;">[</span><span style="color:#393A34;">T comparable</span><span style="color:#999999;">](</span><span style="color:#393A34;">items </span><span style="color:#999999;">[]</span><span style="color:#393A34;">T</span><span style="color:#999999;">)</span><span style="color:#393A34;"> Set</span><span style="color:#999999;">[</span><span style="color:#393A34;">T</span><span style="color:#999999;">]</span></span></code></pre></div><p><b>Example:</b></p><div class="language-go vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">go</span><pre class="shiki dracula-soft vp-code-dark"><code><span class="line"><span style="color:#F286C4;">package</span><span style="color:#F6F6F4;"> main</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F286C4;">import</span><span style="color:#F6F6F4;"> (</span></span>
<span class="line"><span style="color:#F6F6F4;">    </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">fmt</span><span style="color:#DEE492;">&quot;</span></span>
<span class="line"><span style="color:#F6F6F4;">    set </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/set</span><span style="color:#DEE492;">&quot;</span></span>
<span class="line"><span style="color:#F6F6F4;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F286C4;">func</span><span style="color:#F6F6F4;"> </span><span style="color:#62E884;">main</span><span style="color:#F6F6F4;">() {</span></span>
<span class="line"><span style="color:#F6F6F4;">    st </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> set.</span><span style="color:#97E1F1;">NewSetFromSlice</span><span style="color:#F6F6F4;">([]</span><span style="color:#97E1F1;font-style:italic;">int</span><span style="color:#F6F6F4;">{</span><span style="color:#BF9EEE;">1</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">2</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">2</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">3</span><span style="color:#F6F6F4;">})</span></span>
<span class="line"><span style="color:#F6F6F4;">    fmt.</span><span style="color:#97E1F1;">Println</span><span style="color:#F6F6F4;">(st.</span><span style="color:#97E1F1;">Values</span><span style="color:#F6F6F4;">()) </span><span style="color:#7B7F8B;">//1,2,3</span></span>
<span class="line"><span style="color:#F6F6F4;">}</span></span></code></pre><pre class="shiki vitesse-light vp-code-light"><code><span class="line"><span style="color:#1E754F;">package</span><span style="color:#393A34;"> </span><span style="color:#59873A;">main</span></span>
<span class="line"></span>
<span class="line"><span style="color:#1E754F;">import</span><span style="color:#393A34;"> </span><span style="color:#999999;">(</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">fmt</span><span style="color:#B5695999;">&quot;</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#59873A;">set</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/set</span><span style="color:#B5695999;">&quot;</span></span>
<span class="line"><span style="color:#999999;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#1E754F;">func</span><span style="color:#393A34;"> </span><span style="color:#59873A;">main</span><span style="color:#999999;">()</span><span style="color:#393A34;"> </span><span style="color:#999999;">{</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B07D48;">st</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> set</span><span style="color:#999999;">.</span><span style="color:#998418;">NewSetFromSlice</span><span style="color:#999999;">([]</span><span style="color:#AB5959;">int</span><span style="color:#999999;">{</span><span style="color:#2F798A;">1</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#2F798A;">2</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#2F798A;">2</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#2F798A;">3</span><span style="color:#999999;">})</span></span>
<span class="line"><span style="color:#393A34;">    fmt</span><span style="color:#999999;">.</span><span style="color:#998418;">Println</span><span style="color:#999999;">(</span><span style="color:#393A34;">st</span><span style="color:#999999;">.</span><span style="color:#998418;">Values</span><span style="color:#999999;">())</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">//1,2,3</span></span>
<span class="line"><span style="color:#999999;">}</span></span></code></pre></div><h3 id="Values" tabindex="-1"><span id="Values">Values</span> <a class="header-anchor" href="#Values" aria-label="Permalink to &quot;&lt;span id=&quot;Values&quot;&gt;Values&lt;/span&gt;&quot;">​</a></h3><p>Return slice of all set data</p><p><b>Signature:</b></p><div class="language-go vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">go</span><pre class="shiki dracula-soft vp-code-dark"><code><span class="line"><span style="color:#F286C4;">func</span><span style="color:#F6F6F4;"> (s Set[T]) </span><span style="color:#62E884;">Values</span><span style="color:#F6F6F4;">() []T</span></span></code></pre><pre class="shiki vitesse-light vp-code-light"><code><span class="line"><span style="color:#1E754F;">func</span><span style="color:#393A34;"> </span><span style="color:#999999;">(</span><span style="color:#393A34;">s Set</span><span style="color:#999999;">[</span><span style="color:#393A34;">T</span><span style="color:#999999;">])</span><span style="color:#393A34;"> </span><span style="color:#59873A;">Values</span><span style="color:#999999;">()</span><span style="color:#393A34;"> </span><span style="color:#999999;">[]</span><span style="color:#393A34;">T</span></span></code></pre></div><p><b>Example:</b></p><div class="language-go vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">go</span><pre class="shiki dracula-soft vp-code-dark"><code><span class="line"><span style="color:#F286C4;">package</span><span style="color:#F6F6F4;"> main</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F286C4;">import</span><span style="color:#F6F6F4;"> (</span></span>
<span class="line"><span style="color:#F6F6F4;">    </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">fmt</span><span style="color:#DEE492;">&quot;</span></span>
<span class="line"><span style="color:#F6F6F4;">    set </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/set</span><span style="color:#DEE492;">&quot;</span></span>
<span class="line"><span style="color:#F6F6F4;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F286C4;">func</span><span style="color:#F6F6F4;"> </span><span style="color:#62E884;">main</span><span style="color:#F6F6F4;">() {</span></span>
<span class="line"><span style="color:#F6F6F4;">    st </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> set.NewSet[</span><span style="color:#97E1F1;font-style:italic;">int</span><span style="color:#F6F6F4;">](</span><span style="color:#BF9EEE;">1</span><span style="color:#F6F6F4;">,</span><span style="color:#BF9EEE;">2</span><span style="color:#F6F6F4;">,</span><span style="color:#BF9EEE;">2</span><span style="color:#F6F6F4;">,</span><span style="color:#BF9EEE;">3</span><span style="color:#F6F6F4;">)</span></span>
<span class="line"><span style="color:#F6F6F4;">    fmt.</span><span style="color:#97E1F1;">Println</span><span style="color:#F6F6F4;">(st.</span><span style="color:#97E1F1;">Values</span><span style="color:#F6F6F4;">()) </span><span style="color:#7B7F8B;">//1,2,3</span></span>
<span class="line"><span style="color:#F6F6F4;">}</span></span></code></pre><pre class="shiki vitesse-light vp-code-light"><code><span class="line"><span style="color:#1E754F;">package</span><span style="color:#393A34;"> </span><span style="color:#59873A;">main</span></span>
<span class="line"></span>
<span class="line"><span style="color:#1E754F;">import</span><span style="color:#393A34;"> </span><span style="color:#999999;">(</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">fmt</span><span style="color:#B5695999;">&quot;</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#59873A;">set</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/set</span><span style="color:#B5695999;">&quot;</span></span>
<span class="line"><span style="color:#999999;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#1E754F;">func</span><span style="color:#393A34;"> </span><span style="color:#59873A;">main</span><span style="color:#999999;">()</span><span style="color:#393A34;"> </span><span style="color:#999999;">{</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B07D48;">st</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> set</span><span style="color:#999999;">.</span><span style="color:#393A34;">NewSet</span><span style="color:#999999;">[</span><span style="color:#AB5959;">int</span><span style="color:#999999;">](</span><span style="color:#2F798A;">1</span><span style="color:#999999;">,</span><span style="color:#2F798A;">2</span><span style="color:#999999;">,</span><span style="color:#2F798A;">2</span><span style="color:#999999;">,</span><span style="color:#2F798A;">3</span><span style="color:#999999;">)</span></span>
<span class="line"><span style="color:#393A34;">    fmt</span><span style="color:#999999;">.</span><span style="color:#998418;">Println</span><span style="color:#999999;">(</span><span style="color:#393A34;">st</span><span style="color:#999999;">.</span><span style="color:#998418;">Values</span><span style="color:#999999;">())</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">//1,2,3</span></span>
<span class="line"><span style="color:#999999;">}</span></span></code></pre></div><h3 id="Add" tabindex="-1"><span id="Add">Add</span> <a class="header-anchor" href="#Add" aria-label="Permalink to &quot;&lt;span id=&quot;Add&quot;&gt;Add&lt;/span&gt;&quot;">​</a></h3><p>Add items to set</p><p><b>Signature:</b></p><div class="language-go vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">go</span><pre class="shiki dracula-soft vp-code-dark"><code><span class="line"><span style="color:#F286C4;">func</span><span style="color:#F6F6F4;"> (s Set[T]) </span><span style="color:#62E884;">Add</span><span style="color:#F6F6F4;">(items </span><span style="color:#F286C4;">...</span><span style="color:#F6F6F4;">T)</span></span></code></pre><pre class="shiki vitesse-light vp-code-light"><code><span class="line"><span style="color:#1E754F;">func</span><span style="color:#393A34;"> </span><span style="color:#999999;">(</span><span style="color:#393A34;">s Set</span><span style="color:#999999;">[</span><span style="color:#393A34;">T</span><span style="color:#999999;">])</span><span style="color:#393A34;"> </span><span style="color:#59873A;">Add</span><span style="color:#999999;">(</span><span style="color:#393A34;">items </span><span style="color:#AB5959;">...</span><span style="color:#393A34;">T</span><span style="color:#999999;">)</span></span></code></pre></div><p><b>Example:</b></p><div class="language-go vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">go</span><pre class="shiki dracula-soft vp-code-dark"><code><span class="line"><span style="color:#F286C4;">package</span><span style="color:#F6F6F4;"> main</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F286C4;">import</span><span style="color:#F6F6F4;"> (</span></span>
<span class="line"><span style="color:#F6F6F4;">    </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">fmt</span><span style="color:#DEE492;">&quot;</span></span>
<span class="line"><span style="color:#F6F6F4;">    set </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/set</span><span style="color:#DEE492;">&quot;</span></span>
<span class="line"><span style="color:#F6F6F4;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F286C4;">func</span><span style="color:#F6F6F4;"> </span><span style="color:#62E884;">main</span><span style="color:#F6F6F4;">() {</span></span>
<span class="line"><span style="color:#F6F6F4;">    st </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> set.NewSet[</span><span style="color:#97E1F1;font-style:italic;">int</span><span style="color:#F6F6F4;">]()</span></span>
<span class="line"><span style="color:#F6F6F4;">    st.</span><span style="color:#97E1F1;">Add</span><span style="color:#F6F6F4;">(</span><span style="color:#BF9EEE;">1</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">2</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">3</span><span style="color:#F6F6F4;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F6F6F4;">    fmt.</span><span style="color:#97E1F1;">Println</span><span style="color:#F6F6F4;">(st.</span><span style="color:#97E1F1;">Values</span><span style="color:#F6F6F4;">()) </span><span style="color:#7B7F8B;">//1,2,3</span></span>
<span class="line"><span style="color:#F6F6F4;">}</span></span></code></pre><pre class="shiki vitesse-light vp-code-light"><code><span class="line"><span style="color:#1E754F;">package</span><span style="color:#393A34;"> </span><span style="color:#59873A;">main</span></span>
<span class="line"></span>
<span class="line"><span style="color:#1E754F;">import</span><span style="color:#393A34;"> </span><span style="color:#999999;">(</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">fmt</span><span style="color:#B5695999;">&quot;</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#59873A;">set</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/set</span><span style="color:#B5695999;">&quot;</span></span>
<span class="line"><span style="color:#999999;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#1E754F;">func</span><span style="color:#393A34;"> </span><span style="color:#59873A;">main</span><span style="color:#999999;">()</span><span style="color:#393A34;"> </span><span style="color:#999999;">{</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B07D48;">st</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> set</span><span style="color:#999999;">.</span><span style="color:#393A34;">NewSet</span><span style="color:#999999;">[</span><span style="color:#AB5959;">int</span><span style="color:#999999;">]()</span></span>
<span class="line"><span style="color:#393A34;">    st</span><span style="color:#999999;">.</span><span style="color:#998418;">Add</span><span style="color:#999999;">(</span><span style="color:#2F798A;">1</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#2F798A;">2</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#2F798A;">3</span><span style="color:#999999;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#393A34;">    fmt</span><span style="color:#999999;">.</span><span style="color:#998418;">Println</span><span style="color:#999999;">(</span><span style="color:#393A34;">st</span><span style="color:#999999;">.</span><span style="color:#998418;">Values</span><span style="color:#999999;">())</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">//1,2,3</span></span>
<span class="line"><span style="color:#999999;">}</span></span></code></pre></div><h3 id="AddIfNotExist" tabindex="-1"><span id="AddIfNotExist">AddIfNotExist</span> <a class="header-anchor" href="#AddIfNotExist" aria-label="Permalink to &quot;&lt;span id=&quot;AddIfNotExist&quot;&gt;AddIfNotExist&lt;/span&gt;&quot;">​</a></h3><p>AddIfNotExist checks if item exists in the set, it adds the item to set and returns true if it does not exist in the set, or else it does nothing and returns false.</p><p><b>Signature:</b></p><div class="language-go vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">go</span><pre class="shiki dracula-soft vp-code-dark"><code><span class="line"><span style="color:#F286C4;">func</span><span style="color:#F6F6F4;"> (s Set[T]) </span><span style="color:#62E884;">AddIfNotExist</span><span style="color:#F6F6F4;">(item T) </span><span style="color:#97E1F1;font-style:italic;">bool</span></span></code></pre><pre class="shiki vitesse-light vp-code-light"><code><span class="line"><span style="color:#1E754F;">func</span><span style="color:#393A34;"> </span><span style="color:#999999;">(</span><span style="color:#393A34;">s Set</span><span style="color:#999999;">[</span><span style="color:#393A34;">T</span><span style="color:#999999;">])</span><span style="color:#393A34;"> </span><span style="color:#59873A;">AddIfNotExist</span><span style="color:#999999;">(</span><span style="color:#393A34;">item T</span><span style="color:#999999;">)</span><span style="color:#393A34;"> </span><span style="color:#AB5959;">bool</span></span></code></pre></div><p><b>Example:</b></p><div class="language-go vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">go</span><pre class="shiki dracula-soft vp-code-dark"><code><span class="line"><span style="color:#F286C4;">package</span><span style="color:#F6F6F4;"> main</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F286C4;">import</span><span style="color:#F6F6F4;"> (</span></span>
<span class="line"><span style="color:#F6F6F4;">    </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">fmt</span><span style="color:#DEE492;">&quot;</span></span>
<span class="line"><span style="color:#F6F6F4;">    set </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/set</span><span style="color:#DEE492;">&quot;</span></span>
<span class="line"><span style="color:#F6F6F4;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F286C4;">func</span><span style="color:#F6F6F4;"> </span><span style="color:#62E884;">main</span><span style="color:#F6F6F4;">() {</span></span>
<span class="line"><span style="color:#F6F6F4;">    st </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> set.NewSet[</span><span style="color:#97E1F1;font-style:italic;">int</span><span style="color:#F6F6F4;">]()</span></span>
<span class="line"><span style="color:#F6F6F4;">    st.</span><span style="color:#97E1F1;">Add</span><span style="color:#F6F6F4;">(</span><span style="color:#BF9EEE;">1</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">2</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">3</span><span style="color:#F6F6F4;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F6F6F4;">    r1 </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> st.</span><span style="color:#97E1F1;">AddIfNotExist</span><span style="color:#F6F6F4;">(</span><span style="color:#BF9EEE;">1</span><span style="color:#F6F6F4;">)</span></span>
<span class="line"><span style="color:#F6F6F4;">    r2 </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> st.</span><span style="color:#97E1F1;">AddIfNotExist</span><span style="color:#F6F6F4;">(</span><span style="color:#BF9EEE;">4</span><span style="color:#F6F6F4;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F6F6F4;">    fmt.</span><span style="color:#97E1F1;">Println</span><span style="color:#F6F6F4;">(r1) </span><span style="color:#7B7F8B;">// false</span></span>
<span class="line"><span style="color:#F6F6F4;">    fmt.</span><span style="color:#97E1F1;">Println</span><span style="color:#F6F6F4;">(r2) </span><span style="color:#7B7F8B;">// true</span></span>
<span class="line"><span style="color:#F6F6F4;">    fmt.</span><span style="color:#97E1F1;">Println</span><span style="color:#F6F6F4;">(st.</span><span style="color:#97E1F1;">Values</span><span style="color:#F6F6F4;">()) </span><span style="color:#7B7F8B;">// 1,2,3,4</span></span>
<span class="line"><span style="color:#F6F6F4;">}</span></span></code></pre><pre class="shiki vitesse-light vp-code-light"><code><span class="line"><span style="color:#1E754F;">package</span><span style="color:#393A34;"> </span><span style="color:#59873A;">main</span></span>
<span class="line"></span>
<span class="line"><span style="color:#1E754F;">import</span><span style="color:#393A34;"> </span><span style="color:#999999;">(</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">fmt</span><span style="color:#B5695999;">&quot;</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#59873A;">set</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/set</span><span style="color:#B5695999;">&quot;</span></span>
<span class="line"><span style="color:#999999;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#1E754F;">func</span><span style="color:#393A34;"> </span><span style="color:#59873A;">main</span><span style="color:#999999;">()</span><span style="color:#393A34;"> </span><span style="color:#999999;">{</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B07D48;">st</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> set</span><span style="color:#999999;">.</span><span style="color:#393A34;">NewSet</span><span style="color:#999999;">[</span><span style="color:#AB5959;">int</span><span style="color:#999999;">]()</span></span>
<span class="line"><span style="color:#393A34;">    st</span><span style="color:#999999;">.</span><span style="color:#998418;">Add</span><span style="color:#999999;">(</span><span style="color:#2F798A;">1</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#2F798A;">2</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#2F798A;">3</span><span style="color:#999999;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B07D48;">r1</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> st</span><span style="color:#999999;">.</span><span style="color:#998418;">AddIfNotExist</span><span style="color:#999999;">(</span><span style="color:#2F798A;">1</span><span style="color:#999999;">)</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B07D48;">r2</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> st</span><span style="color:#999999;">.</span><span style="color:#998418;">AddIfNotExist</span><span style="color:#999999;">(</span><span style="color:#2F798A;">4</span><span style="color:#999999;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#393A34;">    fmt</span><span style="color:#999999;">.</span><span style="color:#998418;">Println</span><span style="color:#999999;">(</span><span style="color:#393A34;">r1</span><span style="color:#999999;">)</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">// false</span></span>
<span class="line"><span style="color:#393A34;">    fmt</span><span style="color:#999999;">.</span><span style="color:#998418;">Println</span><span style="color:#999999;">(</span><span style="color:#393A34;">r2</span><span style="color:#999999;">)</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">// true</span></span>
<span class="line"><span style="color:#393A34;">    fmt</span><span style="color:#999999;">.</span><span style="color:#998418;">Println</span><span style="color:#999999;">(</span><span style="color:#393A34;">st</span><span style="color:#999999;">.</span><span style="color:#998418;">Values</span><span style="color:#999999;">())</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">// 1,2,3,4</span></span>
<span class="line"><span style="color:#999999;">}</span></span></code></pre></div><h3 id="AddIfNotExistBy" tabindex="-1"><span id="AddIfNotExistBy">AddIfNotExistBy</span> <a class="header-anchor" href="#AddIfNotExistBy" aria-label="Permalink to &quot;&lt;span id=&quot;AddIfNotExistBy&quot;&gt;AddIfNotExistBy&lt;/span&gt;&quot;">​</a></h3><p>AddIfNotExistBy checks if item exists in the set and pass the \`checker\` function it adds the item to set and returns true if it does not exists in the set and function \`checker\` returns true, or else it does nothing and returns false.</p><p><b>Signature:</b></p><div class="language-go vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">go</span><pre class="shiki dracula-soft vp-code-dark"><code><span class="line"><span style="color:#F286C4;">func</span><span style="color:#F6F6F4;"> (s Set[T]) </span><span style="color:#62E884;">AddIfNotExistBy</span><span style="color:#F6F6F4;">(item T, checker </span><span style="color:#F286C4;">func</span><span style="color:#F6F6F4;">(element T) </span><span style="color:#97E1F1;font-style:italic;">bool</span><span style="color:#F6F6F4;">) </span><span style="color:#97E1F1;font-style:italic;">bool</span></span></code></pre><pre class="shiki vitesse-light vp-code-light"><code><span class="line"><span style="color:#1E754F;">func</span><span style="color:#393A34;"> </span><span style="color:#999999;">(</span><span style="color:#393A34;">s Set</span><span style="color:#999999;">[</span><span style="color:#393A34;">T</span><span style="color:#999999;">])</span><span style="color:#393A34;"> </span><span style="color:#59873A;">AddIfNotExistBy</span><span style="color:#999999;">(</span><span style="color:#393A34;">item T</span><span style="color:#999999;">,</span><span style="color:#393A34;"> checker </span><span style="color:#1E754F;">func</span><span style="color:#999999;">(</span><span style="color:#393A34;">element T</span><span style="color:#999999;">)</span><span style="color:#393A34;"> </span><span style="color:#AB5959;">bool</span><span style="color:#999999;">)</span><span style="color:#393A34;"> </span><span style="color:#AB5959;">bool</span></span></code></pre></div><p><b>Example:</b></p><div class="language-go vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">go</span><pre class="shiki dracula-soft vp-code-dark"><code><span class="line"><span style="color:#F286C4;">package</span><span style="color:#F6F6F4;"> main</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F286C4;">import</span><span style="color:#F6F6F4;"> (</span></span>
<span class="line"><span style="color:#F6F6F4;">    </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">fmt</span><span style="color:#DEE492;">&quot;</span></span>
<span class="line"><span style="color:#F6F6F4;">    set </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/set</span><span style="color:#DEE492;">&quot;</span></span>
<span class="line"><span style="color:#F6F6F4;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F286C4;">func</span><span style="color:#F6F6F4;"> </span><span style="color:#62E884;">main</span><span style="color:#F6F6F4;">() {</span></span>
<span class="line"><span style="color:#F6F6F4;">    st </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> set.NewSet[</span><span style="color:#97E1F1;font-style:italic;">int</span><span style="color:#F6F6F4;">]()</span></span>
<span class="line"><span style="color:#F6F6F4;">    st.</span><span style="color:#97E1F1;">Add</span><span style="color:#F6F6F4;">(</span><span style="color:#BF9EEE;">1</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">2</span><span style="color:#F6F6F4;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F6F6F4;">    ok </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> st.</span><span style="color:#97E1F1;">AddIfNotExistBy</span><span style="color:#F6F6F4;">(</span><span style="color:#BF9EEE;">3</span><span style="color:#F6F6F4;">, </span><span style="color:#F286C4;">func</span><span style="color:#F6F6F4;">(val </span><span style="color:#97E1F1;font-style:italic;">int</span><span style="color:#F6F6F4;">) </span><span style="color:#97E1F1;font-style:italic;">bool</span><span style="color:#F6F6F4;"> {</span></span>
<span class="line"><span style="color:#F6F6F4;">        </span><span style="color:#F286C4;">return</span><span style="color:#F6F6F4;"> val</span><span style="color:#F286C4;">%</span><span style="color:#BF9EEE;">2</span><span style="color:#F6F6F4;"> </span><span style="color:#F286C4;">!=</span><span style="color:#F6F6F4;"> </span><span style="color:#BF9EEE;">0</span></span>
<span class="line"><span style="color:#F6F6F4;">    })</span></span>
<span class="line"><span style="color:#F6F6F4;">    fmt.</span><span style="color:#97E1F1;">Println</span><span style="color:#F6F6F4;">(ok) </span><span style="color:#7B7F8B;">// true</span></span>
<span class="line"></span>
<span class="line"></span>
<span class="line"><span style="color:#F6F6F4;">    notOk </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> st.</span><span style="color:#97E1F1;">AddIfNotExistBy</span><span style="color:#F6F6F4;">(</span><span style="color:#BF9EEE;">4</span><span style="color:#F6F6F4;">, </span><span style="color:#F286C4;">func</span><span style="color:#F6F6F4;">(val </span><span style="color:#97E1F1;font-style:italic;">int</span><span style="color:#F6F6F4;">) </span><span style="color:#97E1F1;font-style:italic;">bool</span><span style="color:#F6F6F4;"> {</span></span>
<span class="line"><span style="color:#F6F6F4;">        </span><span style="color:#F286C4;">return</span><span style="color:#F6F6F4;"> val</span><span style="color:#F286C4;">%</span><span style="color:#BF9EEE;">2</span><span style="color:#F6F6F4;"> </span><span style="color:#F286C4;">!=</span><span style="color:#F6F6F4;"> </span><span style="color:#BF9EEE;">0</span></span>
<span class="line"><span style="color:#F6F6F4;">    })</span></span>
<span class="line"><span style="color:#F6F6F4;">    fmt.</span><span style="color:#97E1F1;">Println</span><span style="color:#F6F6F4;">(notOk) </span><span style="color:#7B7F8B;">// false</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F6F6F4;">    fmt.</span><span style="color:#97E1F1;">Println</span><span style="color:#F6F6F4;">(st.</span><span style="color:#97E1F1;">Values</span><span style="color:#F6F6F4;">()) </span><span style="color:#7B7F8B;">// 1, 2, 3</span></span>
<span class="line"><span style="color:#F6F6F4;">}</span></span></code></pre><pre class="shiki vitesse-light vp-code-light"><code><span class="line"><span style="color:#1E754F;">package</span><span style="color:#393A34;"> </span><span style="color:#59873A;">main</span></span>
<span class="line"></span>
<span class="line"><span style="color:#1E754F;">import</span><span style="color:#393A34;"> </span><span style="color:#999999;">(</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">fmt</span><span style="color:#B5695999;">&quot;</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#59873A;">set</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/set</span><span style="color:#B5695999;">&quot;</span></span>
<span class="line"><span style="color:#999999;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#1E754F;">func</span><span style="color:#393A34;"> </span><span style="color:#59873A;">main</span><span style="color:#999999;">()</span><span style="color:#393A34;"> </span><span style="color:#999999;">{</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B07D48;">st</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> set</span><span style="color:#999999;">.</span><span style="color:#393A34;">NewSet</span><span style="color:#999999;">[</span><span style="color:#AB5959;">int</span><span style="color:#999999;">]()</span></span>
<span class="line"><span style="color:#393A34;">    st</span><span style="color:#999999;">.</span><span style="color:#998418;">Add</span><span style="color:#999999;">(</span><span style="color:#2F798A;">1</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#2F798A;">2</span><span style="color:#999999;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B07D48;">ok</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> st</span><span style="color:#999999;">.</span><span style="color:#998418;">AddIfNotExistBy</span><span style="color:#999999;">(</span><span style="color:#2F798A;">3</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#1E754F;">func</span><span style="color:#999999;">(</span><span style="color:#393A34;">val </span><span style="color:#AB5959;">int</span><span style="color:#999999;">)</span><span style="color:#393A34;"> </span><span style="color:#AB5959;">bool</span><span style="color:#393A34;"> </span><span style="color:#999999;">{</span></span>
<span class="line"><span style="color:#393A34;">        </span><span style="color:#1E754F;">return</span><span style="color:#393A34;"> val</span><span style="color:#AB5959;">%</span><span style="color:#2F798A;">2</span><span style="color:#393A34;"> </span><span style="color:#AB5959;">!=</span><span style="color:#393A34;"> </span><span style="color:#2F798A;">0</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#999999;">})</span></span>
<span class="line"><span style="color:#393A34;">    fmt</span><span style="color:#999999;">.</span><span style="color:#998418;">Println</span><span style="color:#999999;">(</span><span style="color:#393A34;">ok</span><span style="color:#999999;">)</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">// true</span></span>
<span class="line"></span>
<span class="line"></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B07D48;">notOk</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> st</span><span style="color:#999999;">.</span><span style="color:#998418;">AddIfNotExistBy</span><span style="color:#999999;">(</span><span style="color:#2F798A;">4</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#1E754F;">func</span><span style="color:#999999;">(</span><span style="color:#393A34;">val </span><span style="color:#AB5959;">int</span><span style="color:#999999;">)</span><span style="color:#393A34;"> </span><span style="color:#AB5959;">bool</span><span style="color:#393A34;"> </span><span style="color:#999999;">{</span></span>
<span class="line"><span style="color:#393A34;">        </span><span style="color:#1E754F;">return</span><span style="color:#393A34;"> val</span><span style="color:#AB5959;">%</span><span style="color:#2F798A;">2</span><span style="color:#393A34;"> </span><span style="color:#AB5959;">!=</span><span style="color:#393A34;"> </span><span style="color:#2F798A;">0</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#999999;">})</span></span>
<span class="line"><span style="color:#393A34;">    fmt</span><span style="color:#999999;">.</span><span style="color:#998418;">Println</span><span style="color:#999999;">(</span><span style="color:#393A34;">notOk</span><span style="color:#999999;">)</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">// false</span></span>
<span class="line"></span>
<span class="line"><span style="color:#393A34;">    fmt</span><span style="color:#999999;">.</span><span style="color:#998418;">Println</span><span style="color:#999999;">(</span><span style="color:#393A34;">st</span><span style="color:#999999;">.</span><span style="color:#998418;">Values</span><span style="color:#999999;">())</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">// 1, 2, 3</span></span>
<span class="line"><span style="color:#999999;">}</span></span></code></pre></div><h3 id="Delete" tabindex="-1"><span id="Delete">Delete</span> <a class="header-anchor" href="#Delete" aria-label="Permalink to &quot;&lt;span id=&quot;Delete&quot;&gt;Delete&lt;/span&gt;&quot;">​</a></h3><p>Delete item in set</p><p><b>Signature:</b></p><div class="language-go vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">go</span><pre class="shiki dracula-soft vp-code-dark"><code><span class="line"><span style="color:#F286C4;">func</span><span style="color:#F6F6F4;"> (s Set[T]) </span><span style="color:#62E884;">Delete</span><span style="color:#F6F6F4;">(items </span><span style="color:#F286C4;">...</span><span style="color:#F6F6F4;">T)</span></span></code></pre><pre class="shiki vitesse-light vp-code-light"><code><span class="line"><span style="color:#1E754F;">func</span><span style="color:#393A34;"> </span><span style="color:#999999;">(</span><span style="color:#393A34;">s Set</span><span style="color:#999999;">[</span><span style="color:#393A34;">T</span><span style="color:#999999;">])</span><span style="color:#393A34;"> </span><span style="color:#59873A;">Delete</span><span style="color:#999999;">(</span><span style="color:#393A34;">items </span><span style="color:#AB5959;">...</span><span style="color:#393A34;">T</span><span style="color:#999999;">)</span></span></code></pre></div><p><b>Example:</b></p><div class="language-go vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">go</span><pre class="shiki dracula-soft vp-code-dark"><code><span class="line"><span style="color:#F286C4;">package</span><span style="color:#F6F6F4;"> main</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F286C4;">import</span><span style="color:#F6F6F4;"> (</span></span>
<span class="line"><span style="color:#F6F6F4;">    </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">fmt</span><span style="color:#DEE492;">&quot;</span></span>
<span class="line"><span style="color:#F6F6F4;">    set </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/set</span><span style="color:#DEE492;">&quot;</span></span>
<span class="line"><span style="color:#F6F6F4;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F286C4;">func</span><span style="color:#F6F6F4;"> </span><span style="color:#62E884;">main</span><span style="color:#F6F6F4;">() {</span></span>
<span class="line"><span style="color:#F6F6F4;">    st </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> set.NewSet[</span><span style="color:#97E1F1;font-style:italic;">int</span><span style="color:#F6F6F4;">]()</span></span>
<span class="line"><span style="color:#F6F6F4;">    st.</span><span style="color:#97E1F1;">Add</span><span style="color:#F6F6F4;">(</span><span style="color:#BF9EEE;">1</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">2</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">3</span><span style="color:#F6F6F4;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F6F6F4;">    set.</span><span style="color:#97E1F1;">Delete</span><span style="color:#F6F6F4;">(</span><span style="color:#BF9EEE;">3</span><span style="color:#F6F6F4;">)</span></span>
<span class="line"><span style="color:#F6F6F4;">    fmt.</span><span style="color:#97E1F1;">Println</span><span style="color:#F6F6F4;">(st.</span><span style="color:#97E1F1;">Values</span><span style="color:#F6F6F4;">()) </span><span style="color:#7B7F8B;">//1,2</span></span>
<span class="line"><span style="color:#F6F6F4;">}</span></span></code></pre><pre class="shiki vitesse-light vp-code-light"><code><span class="line"><span style="color:#1E754F;">package</span><span style="color:#393A34;"> </span><span style="color:#59873A;">main</span></span>
<span class="line"></span>
<span class="line"><span style="color:#1E754F;">import</span><span style="color:#393A34;"> </span><span style="color:#999999;">(</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">fmt</span><span style="color:#B5695999;">&quot;</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#59873A;">set</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/set</span><span style="color:#B5695999;">&quot;</span></span>
<span class="line"><span style="color:#999999;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#1E754F;">func</span><span style="color:#393A34;"> </span><span style="color:#59873A;">main</span><span style="color:#999999;">()</span><span style="color:#393A34;"> </span><span style="color:#999999;">{</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B07D48;">st</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> set</span><span style="color:#999999;">.</span><span style="color:#393A34;">NewSet</span><span style="color:#999999;">[</span><span style="color:#AB5959;">int</span><span style="color:#999999;">]()</span></span>
<span class="line"><span style="color:#393A34;">    st</span><span style="color:#999999;">.</span><span style="color:#998418;">Add</span><span style="color:#999999;">(</span><span style="color:#2F798A;">1</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#2F798A;">2</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#2F798A;">3</span><span style="color:#999999;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#393A34;">    set</span><span style="color:#999999;">.</span><span style="color:#998418;">Delete</span><span style="color:#999999;">(</span><span style="color:#2F798A;">3</span><span style="color:#999999;">)</span></span>
<span class="line"><span style="color:#393A34;">    fmt</span><span style="color:#999999;">.</span><span style="color:#998418;">Println</span><span style="color:#999999;">(</span><span style="color:#393A34;">st</span><span style="color:#999999;">.</span><span style="color:#998418;">Values</span><span style="color:#999999;">())</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">//1,2</span></span>
<span class="line"><span style="color:#999999;">}</span></span></code></pre></div><h3 id="Contain" tabindex="-1"><span id="Contain">Contain</span> <a class="header-anchor" href="#Contain" aria-label="Permalink to &quot;&lt;span id=&quot;Contain&quot;&gt;Contain&lt;/span&gt;&quot;">​</a></h3><p>Check if item is in set or not</p><p><b>Signature:</b></p><div class="language-go vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">go</span><pre class="shiki dracula-soft vp-code-dark"><code><span class="line"><span style="color:#F286C4;">func</span><span style="color:#F6F6F4;"> (s Set[T]) </span><span style="color:#62E884;">Contain</span><span style="color:#F6F6F4;">(item T) </span><span style="color:#97E1F1;font-style:italic;">bool</span></span></code></pre><pre class="shiki vitesse-light vp-code-light"><code><span class="line"><span style="color:#1E754F;">func</span><span style="color:#393A34;"> </span><span style="color:#999999;">(</span><span style="color:#393A34;">s Set</span><span style="color:#999999;">[</span><span style="color:#393A34;">T</span><span style="color:#999999;">])</span><span style="color:#393A34;"> </span><span style="color:#59873A;">Contain</span><span style="color:#999999;">(</span><span style="color:#393A34;">item T</span><span style="color:#999999;">)</span><span style="color:#393A34;"> </span><span style="color:#AB5959;">bool</span></span></code></pre></div><p><b>Example:</b></p><div class="language-go vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">go</span><pre class="shiki dracula-soft vp-code-dark"><code><span class="line"><span style="color:#F286C4;">package</span><span style="color:#F6F6F4;"> main</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F286C4;">import</span><span style="color:#F6F6F4;"> (</span></span>
<span class="line"><span style="color:#F6F6F4;">    </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">fmt</span><span style="color:#DEE492;">&quot;</span></span>
<span class="line"><span style="color:#F6F6F4;">    set </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/set</span><span style="color:#DEE492;">&quot;</span></span>
<span class="line"><span style="color:#F6F6F4;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F286C4;">func</span><span style="color:#F6F6F4;"> </span><span style="color:#62E884;">main</span><span style="color:#F6F6F4;">() {</span></span>
<span class="line"><span style="color:#F6F6F4;">    st </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> set.NewSet[</span><span style="color:#97E1F1;font-style:italic;">int</span><span style="color:#F6F6F4;">]()</span></span>
<span class="line"><span style="color:#F6F6F4;">    st.</span><span style="color:#97E1F1;">Add</span><span style="color:#F6F6F4;">(</span><span style="color:#BF9EEE;">1</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">2</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">3</span><span style="color:#F6F6F4;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F6F6F4;">    fmt.</span><span style="color:#97E1F1;">Println</span><span style="color:#F6F6F4;">(st.</span><span style="color:#97E1F1;">Contain</span><span style="color:#F6F6F4;">(</span><span style="color:#BF9EEE;">1</span><span style="color:#F6F6F4;">)) </span><span style="color:#7B7F8B;">//true</span></span>
<span class="line"><span style="color:#F6F6F4;">    fmt.</span><span style="color:#97E1F1;">Println</span><span style="color:#F6F6F4;">(st.</span><span style="color:#97E1F1;">Contain</span><span style="color:#F6F6F4;">(</span><span style="color:#BF9EEE;">4</span><span style="color:#F6F6F4;">)) </span><span style="color:#7B7F8B;">//false</span></span>
<span class="line"><span style="color:#F6F6F4;">}</span></span></code></pre><pre class="shiki vitesse-light vp-code-light"><code><span class="line"><span style="color:#1E754F;">package</span><span style="color:#393A34;"> </span><span style="color:#59873A;">main</span></span>
<span class="line"></span>
<span class="line"><span style="color:#1E754F;">import</span><span style="color:#393A34;"> </span><span style="color:#999999;">(</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">fmt</span><span style="color:#B5695999;">&quot;</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#59873A;">set</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/set</span><span style="color:#B5695999;">&quot;</span></span>
<span class="line"><span style="color:#999999;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#1E754F;">func</span><span style="color:#393A34;"> </span><span style="color:#59873A;">main</span><span style="color:#999999;">()</span><span style="color:#393A34;"> </span><span style="color:#999999;">{</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B07D48;">st</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> set</span><span style="color:#999999;">.</span><span style="color:#393A34;">NewSet</span><span style="color:#999999;">[</span><span style="color:#AB5959;">int</span><span style="color:#999999;">]()</span></span>
<span class="line"><span style="color:#393A34;">    st</span><span style="color:#999999;">.</span><span style="color:#998418;">Add</span><span style="color:#999999;">(</span><span style="color:#2F798A;">1</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#2F798A;">2</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#2F798A;">3</span><span style="color:#999999;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#393A34;">    fmt</span><span style="color:#999999;">.</span><span style="color:#998418;">Println</span><span style="color:#999999;">(</span><span style="color:#393A34;">st</span><span style="color:#999999;">.</span><span style="color:#998418;">Contain</span><span style="color:#999999;">(</span><span style="color:#2F798A;">1</span><span style="color:#999999;">))</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">//true</span></span>
<span class="line"><span style="color:#393A34;">    fmt</span><span style="color:#999999;">.</span><span style="color:#998418;">Println</span><span style="color:#999999;">(</span><span style="color:#393A34;">st</span><span style="color:#999999;">.</span><span style="color:#998418;">Contain</span><span style="color:#999999;">(</span><span style="color:#2F798A;">4</span><span style="color:#999999;">))</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">//false</span></span>
<span class="line"><span style="color:#999999;">}</span></span></code></pre></div><h3 id="ContainAll" tabindex="-1"><span id="ContainAll">ContainAll</span> <a class="header-anchor" href="#ContainAll" aria-label="Permalink to &quot;&lt;span id=&quot;ContainAll&quot;&gt;ContainAll&lt;/span&gt;&quot;">​</a></h3><p>Checks if set contains another set</p><p><b>Signature:</b></p><div class="language-go vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">go</span><pre class="shiki dracula-soft vp-code-dark"><code><span class="line"><span style="color:#F286C4;">func</span><span style="color:#F6F6F4;"> (s Set[T]) </span><span style="color:#62E884;">ContainAll</span><span style="color:#F6F6F4;">(other Set[T]) </span><span style="color:#97E1F1;font-style:italic;">bool</span></span></code></pre><pre class="shiki vitesse-light vp-code-light"><code><span class="line"><span style="color:#1E754F;">func</span><span style="color:#393A34;"> </span><span style="color:#999999;">(</span><span style="color:#393A34;">s Set</span><span style="color:#999999;">[</span><span style="color:#393A34;">T</span><span style="color:#999999;">])</span><span style="color:#393A34;"> </span><span style="color:#59873A;">ContainAll</span><span style="color:#999999;">(</span><span style="color:#393A34;">other Set</span><span style="color:#999999;">[</span><span style="color:#393A34;">T</span><span style="color:#999999;">])</span><span style="color:#393A34;"> </span><span style="color:#AB5959;">bool</span></span></code></pre></div><p><b>Example:</b></p><div class="language-go vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">go</span><pre class="shiki dracula-soft vp-code-dark"><code><span class="line"><span style="color:#F286C4;">package</span><span style="color:#F6F6F4;"> main</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F286C4;">import</span><span style="color:#F6F6F4;"> (</span></span>
<span class="line"><span style="color:#F6F6F4;">    </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">fmt</span><span style="color:#DEE492;">&quot;</span></span>
<span class="line"><span style="color:#F6F6F4;">    set </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/set</span><span style="color:#DEE492;">&quot;</span></span>
<span class="line"><span style="color:#F6F6F4;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F286C4;">func</span><span style="color:#F6F6F4;"> </span><span style="color:#62E884;">main</span><span style="color:#F6F6F4;">() {</span></span>
<span class="line"><span style="color:#F6F6F4;">    set1 </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> set.</span><span style="color:#97E1F1;">NewSet</span><span style="color:#F6F6F4;">(</span><span style="color:#BF9EEE;">1</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">2</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">3</span><span style="color:#F6F6F4;">)</span></span>
<span class="line"><span style="color:#F6F6F4;">    set2 </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> set.</span><span style="color:#97E1F1;">NewSet</span><span style="color:#F6F6F4;">(</span><span style="color:#BF9EEE;">1</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">2</span><span style="color:#F6F6F4;">)</span></span>
<span class="line"><span style="color:#F6F6F4;">    set3 </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> set.</span><span style="color:#97E1F1;">NewSet</span><span style="color:#F6F6F4;">(</span><span style="color:#BF9EEE;">1</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">2</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">3</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">4</span><span style="color:#F6F6F4;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F6F6F4;">    fmt.</span><span style="color:#97E1F1;">Println</span><span style="color:#F6F6F4;">(set1.</span><span style="color:#97E1F1;">ContainAll</span><span style="color:#F6F6F4;">(set2)) </span><span style="color:#7B7F8B;">//true</span></span>
<span class="line"><span style="color:#F6F6F4;">    fmt.</span><span style="color:#97E1F1;">Println</span><span style="color:#F6F6F4;">(set1.</span><span style="color:#97E1F1;">ContainAll</span><span style="color:#F6F6F4;">(set3)) </span><span style="color:#7B7F8B;">//false</span></span>
<span class="line"><span style="color:#F6F6F4;">}</span></span></code></pre><pre class="shiki vitesse-light vp-code-light"><code><span class="line"><span style="color:#1E754F;">package</span><span style="color:#393A34;"> </span><span style="color:#59873A;">main</span></span>
<span class="line"></span>
<span class="line"><span style="color:#1E754F;">import</span><span style="color:#393A34;"> </span><span style="color:#999999;">(</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">fmt</span><span style="color:#B5695999;">&quot;</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#59873A;">set</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/set</span><span style="color:#B5695999;">&quot;</span></span>
<span class="line"><span style="color:#999999;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#1E754F;">func</span><span style="color:#393A34;"> </span><span style="color:#59873A;">main</span><span style="color:#999999;">()</span><span style="color:#393A34;"> </span><span style="color:#999999;">{</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B07D48;">set1</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> set</span><span style="color:#999999;">.</span><span style="color:#998418;">NewSet</span><span style="color:#999999;">(</span><span style="color:#2F798A;">1</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#2F798A;">2</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#2F798A;">3</span><span style="color:#999999;">)</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B07D48;">set2</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> set</span><span style="color:#999999;">.</span><span style="color:#998418;">NewSet</span><span style="color:#999999;">(</span><span style="color:#2F798A;">1</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#2F798A;">2</span><span style="color:#999999;">)</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B07D48;">set3</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> set</span><span style="color:#999999;">.</span><span style="color:#998418;">NewSet</span><span style="color:#999999;">(</span><span style="color:#2F798A;">1</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#2F798A;">2</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#2F798A;">3</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#2F798A;">4</span><span style="color:#999999;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#393A34;">    fmt</span><span style="color:#999999;">.</span><span style="color:#998418;">Println</span><span style="color:#999999;">(</span><span style="color:#393A34;">set1</span><span style="color:#999999;">.</span><span style="color:#998418;">ContainAll</span><span style="color:#999999;">(</span><span style="color:#393A34;">set2</span><span style="color:#999999;">))</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">//true</span></span>
<span class="line"><span style="color:#393A34;">    fmt</span><span style="color:#999999;">.</span><span style="color:#998418;">Println</span><span style="color:#999999;">(</span><span style="color:#393A34;">set1</span><span style="color:#999999;">.</span><span style="color:#998418;">ContainAll</span><span style="color:#999999;">(</span><span style="color:#393A34;">set3</span><span style="color:#999999;">))</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">//false</span></span>
<span class="line"><span style="color:#999999;">}</span></span></code></pre></div><h3 id="Size" tabindex="-1"><span id="Size">Size</span> <a class="header-anchor" href="#Size" aria-label="Permalink to &quot;&lt;span id=&quot;Size&quot;&gt;Size&lt;/span&gt;&quot;">​</a></h3><p>Get the number of elements in set</p><p><b>Signature:</b></p><div class="language-go vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">go</span><pre class="shiki dracula-soft vp-code-dark"><code><span class="line"><span style="color:#F286C4;">func</span><span style="color:#F6F6F4;"> (s Set[T]) </span><span style="color:#62E884;">Size</span><span style="color:#F6F6F4;">() </span><span style="color:#97E1F1;font-style:italic;">int</span></span></code></pre><pre class="shiki vitesse-light vp-code-light"><code><span class="line"><span style="color:#1E754F;">func</span><span style="color:#393A34;"> </span><span style="color:#999999;">(</span><span style="color:#393A34;">s Set</span><span style="color:#999999;">[</span><span style="color:#393A34;">T</span><span style="color:#999999;">])</span><span style="color:#393A34;"> </span><span style="color:#59873A;">Size</span><span style="color:#999999;">()</span><span style="color:#393A34;"> </span><span style="color:#AB5959;">int</span></span></code></pre></div><p><b>Example:</b></p><div class="language-go vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">go</span><pre class="shiki dracula-soft vp-code-dark"><code><span class="line"><span style="color:#F286C4;">package</span><span style="color:#F6F6F4;"> main</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F286C4;">import</span><span style="color:#F6F6F4;"> (</span></span>
<span class="line"><span style="color:#F6F6F4;">    </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">fmt</span><span style="color:#DEE492;">&quot;</span></span>
<span class="line"><span style="color:#F6F6F4;">    set </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/set</span><span style="color:#DEE492;">&quot;</span></span>
<span class="line"><span style="color:#F6F6F4;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F286C4;">func</span><span style="color:#F6F6F4;"> </span><span style="color:#62E884;">main</span><span style="color:#F6F6F4;">() {</span></span>
<span class="line"><span style="color:#F6F6F4;">    set1 </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> set.</span><span style="color:#97E1F1;">NewSet</span><span style="color:#F6F6F4;">(</span><span style="color:#BF9EEE;">1</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">2</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">3</span><span style="color:#F6F6F4;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F6F6F4;">    fmt.</span><span style="color:#97E1F1;">Println</span><span style="color:#F6F6F4;">(set1.</span><span style="color:#97E1F1;">Size</span><span style="color:#F6F6F4;">()) </span><span style="color:#7B7F8B;">//3</span></span>
<span class="line"><span style="color:#F6F6F4;">}</span></span></code></pre><pre class="shiki vitesse-light vp-code-light"><code><span class="line"><span style="color:#1E754F;">package</span><span style="color:#393A34;"> </span><span style="color:#59873A;">main</span></span>
<span class="line"></span>
<span class="line"><span style="color:#1E754F;">import</span><span style="color:#393A34;"> </span><span style="color:#999999;">(</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">fmt</span><span style="color:#B5695999;">&quot;</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#59873A;">set</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/set</span><span style="color:#B5695999;">&quot;</span></span>
<span class="line"><span style="color:#999999;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#1E754F;">func</span><span style="color:#393A34;"> </span><span style="color:#59873A;">main</span><span style="color:#999999;">()</span><span style="color:#393A34;"> </span><span style="color:#999999;">{</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B07D48;">set1</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> set</span><span style="color:#999999;">.</span><span style="color:#998418;">NewSet</span><span style="color:#999999;">(</span><span style="color:#2F798A;">1</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#2F798A;">2</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#2F798A;">3</span><span style="color:#999999;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#393A34;">    fmt</span><span style="color:#999999;">.</span><span style="color:#998418;">Println</span><span style="color:#999999;">(</span><span style="color:#393A34;">set1</span><span style="color:#999999;">.</span><span style="color:#998418;">Size</span><span style="color:#999999;">())</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">//3</span></span>
<span class="line"><span style="color:#999999;">}</span></span></code></pre></div><h3 id="Clone" tabindex="-1"><span id="Clone">Clone</span> <a class="header-anchor" href="#Clone" aria-label="Permalink to &quot;&lt;span id=&quot;Clone&quot;&gt;Clone&lt;/span&gt;&quot;">​</a></h3><p>Make a copy of set</p><p><b>Signature:</b></p><div class="language-go vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">go</span><pre class="shiki dracula-soft vp-code-dark"><code><span class="line"><span style="color:#F286C4;">func</span><span style="color:#F6F6F4;"> (s Set[T]) </span><span style="color:#62E884;">Clone</span><span style="color:#F6F6F4;">() Set[T]</span></span></code></pre><pre class="shiki vitesse-light vp-code-light"><code><span class="line"><span style="color:#1E754F;">func</span><span style="color:#393A34;"> </span><span style="color:#999999;">(</span><span style="color:#393A34;">s Set</span><span style="color:#999999;">[</span><span style="color:#393A34;">T</span><span style="color:#999999;">])</span><span style="color:#393A34;"> </span><span style="color:#59873A;">Clone</span><span style="color:#999999;">()</span><span style="color:#393A34;"> Set</span><span style="color:#999999;">[</span><span style="color:#393A34;">T</span><span style="color:#999999;">]</span></span></code></pre></div><p><b>Example:</b></p><div class="language-go vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">go</span><pre class="shiki dracula-soft vp-code-dark"><code><span class="line"><span style="color:#F286C4;">package</span><span style="color:#F6F6F4;"> main</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F286C4;">import</span><span style="color:#F6F6F4;"> (</span></span>
<span class="line"><span style="color:#F6F6F4;">    </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">fmt</span><span style="color:#DEE492;">&quot;</span></span>
<span class="line"><span style="color:#F6F6F4;">    set </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/set</span><span style="color:#DEE492;">&quot;</span></span>
<span class="line"><span style="color:#F6F6F4;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F286C4;">func</span><span style="color:#F6F6F4;"> </span><span style="color:#62E884;">main</span><span style="color:#F6F6F4;">() {</span></span>
<span class="line"><span style="color:#F6F6F4;">    set1 </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> set.</span><span style="color:#97E1F1;">NewSet</span><span style="color:#F6F6F4;">(</span><span style="color:#BF9EEE;">1</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">2</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">3</span><span style="color:#F6F6F4;">)</span></span>
<span class="line"><span style="color:#F6F6F4;">    set2 </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> set1.</span><span style="color:#97E1F1;">Clone</span><span style="color:#F6F6F4;">()</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F6F6F4;">    fmt.</span><span style="color:#97E1F1;">Println</span><span style="color:#F6F6F4;">(set1.</span><span style="color:#97E1F1;">Size</span><span style="color:#F6F6F4;">() </span><span style="color:#F286C4;">==</span><span style="color:#F6F6F4;"> set2.</span><span style="color:#97E1F1;">Size</span><span style="color:#F6F6F4;">()) </span><span style="color:#7B7F8B;">//true</span></span>
<span class="line"><span style="color:#F6F6F4;">    fmt.</span><span style="color:#97E1F1;">Println</span><span style="color:#F6F6F4;">(set1.</span><span style="color:#97E1F1;">ContainAll</span><span style="color:#F6F6F4;">(set2)) </span><span style="color:#7B7F8B;">//true</span></span>
<span class="line"><span style="color:#F6F6F4;">}</span></span></code></pre><pre class="shiki vitesse-light vp-code-light"><code><span class="line"><span style="color:#1E754F;">package</span><span style="color:#393A34;"> </span><span style="color:#59873A;">main</span></span>
<span class="line"></span>
<span class="line"><span style="color:#1E754F;">import</span><span style="color:#393A34;"> </span><span style="color:#999999;">(</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">fmt</span><span style="color:#B5695999;">&quot;</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#59873A;">set</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/set</span><span style="color:#B5695999;">&quot;</span></span>
<span class="line"><span style="color:#999999;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#1E754F;">func</span><span style="color:#393A34;"> </span><span style="color:#59873A;">main</span><span style="color:#999999;">()</span><span style="color:#393A34;"> </span><span style="color:#999999;">{</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B07D48;">set1</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> set</span><span style="color:#999999;">.</span><span style="color:#998418;">NewSet</span><span style="color:#999999;">(</span><span style="color:#2F798A;">1</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#2F798A;">2</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#2F798A;">3</span><span style="color:#999999;">)</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B07D48;">set2</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> set1</span><span style="color:#999999;">.</span><span style="color:#998418;">Clone</span><span style="color:#999999;">()</span></span>
<span class="line"></span>
<span class="line"><span style="color:#393A34;">    fmt</span><span style="color:#999999;">.</span><span style="color:#998418;">Println</span><span style="color:#999999;">(</span><span style="color:#393A34;">set1</span><span style="color:#999999;">.</span><span style="color:#998418;">Size</span><span style="color:#999999;">()</span><span style="color:#393A34;"> </span><span style="color:#AB5959;">==</span><span style="color:#393A34;"> set2</span><span style="color:#999999;">.</span><span style="color:#998418;">Size</span><span style="color:#999999;">())</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">//true</span></span>
<span class="line"><span style="color:#393A34;">    fmt</span><span style="color:#999999;">.</span><span style="color:#998418;">Println</span><span style="color:#999999;">(</span><span style="color:#393A34;">set1</span><span style="color:#999999;">.</span><span style="color:#998418;">ContainAll</span><span style="color:#999999;">(</span><span style="color:#393A34;">set2</span><span style="color:#999999;">))</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">//true</span></span>
<span class="line"><span style="color:#999999;">}</span></span></code></pre></div><h3 id="Equal" tabindex="-1"><span id="Equal">Equal</span> <a class="header-anchor" href="#Equal" aria-label="Permalink to &quot;&lt;span id=&quot;Equal&quot;&gt;Equal&lt;/span&gt;&quot;">​</a></h3><p>Check if two sets has same elements or not</p><p><b>Signature:</b></p><div class="language-go vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">go</span><pre class="shiki dracula-soft vp-code-dark"><code><span class="line"><span style="color:#F286C4;">func</span><span style="color:#F6F6F4;"> (s Set[T]) </span><span style="color:#62E884;">Equal</span><span style="color:#F6F6F4;">(other Set[T]) </span><span style="color:#97E1F1;font-style:italic;">bool</span></span></code></pre><pre class="shiki vitesse-light vp-code-light"><code><span class="line"><span style="color:#1E754F;">func</span><span style="color:#393A34;"> </span><span style="color:#999999;">(</span><span style="color:#393A34;">s Set</span><span style="color:#999999;">[</span><span style="color:#393A34;">T</span><span style="color:#999999;">])</span><span style="color:#393A34;"> </span><span style="color:#59873A;">Equal</span><span style="color:#999999;">(</span><span style="color:#393A34;">other Set</span><span style="color:#999999;">[</span><span style="color:#393A34;">T</span><span style="color:#999999;">])</span><span style="color:#393A34;"> </span><span style="color:#AB5959;">bool</span></span></code></pre></div><p><b>Example:</b></p><div class="language-go vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">go</span><pre class="shiki dracula-soft vp-code-dark"><code><span class="line"><span style="color:#F286C4;">package</span><span style="color:#F6F6F4;"> main</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F286C4;">import</span><span style="color:#F6F6F4;"> (</span></span>
<span class="line"><span style="color:#F6F6F4;">    </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">fmt</span><span style="color:#DEE492;">&quot;</span></span>
<span class="line"><span style="color:#F6F6F4;">    set </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/set</span><span style="color:#DEE492;">&quot;</span></span>
<span class="line"><span style="color:#F6F6F4;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F286C4;">func</span><span style="color:#F6F6F4;"> </span><span style="color:#62E884;">main</span><span style="color:#F6F6F4;">() {</span></span>
<span class="line"><span style="color:#F6F6F4;">    set1 </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> set.</span><span style="color:#97E1F1;">NewSet</span><span style="color:#F6F6F4;">(</span><span style="color:#BF9EEE;">1</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">2</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">3</span><span style="color:#F6F6F4;">)</span></span>
<span class="line"><span style="color:#F6F6F4;">    set2 </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> set.</span><span style="color:#97E1F1;">NewSet</span><span style="color:#F6F6F4;">(</span><span style="color:#BF9EEE;">1</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">2</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">3</span><span style="color:#F6F6F4;">)</span></span>
<span class="line"><span style="color:#F6F6F4;">    set3 </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> set.</span><span style="color:#97E1F1;">NewSet</span><span style="color:#F6F6F4;">(</span><span style="color:#BF9EEE;">1</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">2</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">3</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">4</span><span style="color:#F6F6F4;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F6F6F4;">    fmt.</span><span style="color:#97E1F1;">Println</span><span style="color:#F6F6F4;">(set1.</span><span style="color:#97E1F1;">Equal</span><span style="color:#F6F6F4;">(set2)) </span><span style="color:#7B7F8B;">//true</span></span>
<span class="line"><span style="color:#F6F6F4;">    fmt.</span><span style="color:#97E1F1;">Println</span><span style="color:#F6F6F4;">(set1.</span><span style="color:#97E1F1;">Equal</span><span style="color:#F6F6F4;">(set3)) </span><span style="color:#7B7F8B;">//false</span></span>
<span class="line"><span style="color:#F6F6F4;">}</span></span></code></pre><pre class="shiki vitesse-light vp-code-light"><code><span class="line"><span style="color:#1E754F;">package</span><span style="color:#393A34;"> </span><span style="color:#59873A;">main</span></span>
<span class="line"></span>
<span class="line"><span style="color:#1E754F;">import</span><span style="color:#393A34;"> </span><span style="color:#999999;">(</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">fmt</span><span style="color:#B5695999;">&quot;</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#59873A;">set</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/set</span><span style="color:#B5695999;">&quot;</span></span>
<span class="line"><span style="color:#999999;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#1E754F;">func</span><span style="color:#393A34;"> </span><span style="color:#59873A;">main</span><span style="color:#999999;">()</span><span style="color:#393A34;"> </span><span style="color:#999999;">{</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B07D48;">set1</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> set</span><span style="color:#999999;">.</span><span style="color:#998418;">NewSet</span><span style="color:#999999;">(</span><span style="color:#2F798A;">1</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#2F798A;">2</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#2F798A;">3</span><span style="color:#999999;">)</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B07D48;">set2</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> set</span><span style="color:#999999;">.</span><span style="color:#998418;">NewSet</span><span style="color:#999999;">(</span><span style="color:#2F798A;">1</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#2F798A;">2</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#2F798A;">3</span><span style="color:#999999;">)</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B07D48;">set3</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> set</span><span style="color:#999999;">.</span><span style="color:#998418;">NewSet</span><span style="color:#999999;">(</span><span style="color:#2F798A;">1</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#2F798A;">2</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#2F798A;">3</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#2F798A;">4</span><span style="color:#999999;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#393A34;">    fmt</span><span style="color:#999999;">.</span><span style="color:#998418;">Println</span><span style="color:#999999;">(</span><span style="color:#393A34;">set1</span><span style="color:#999999;">.</span><span style="color:#998418;">Equal</span><span style="color:#999999;">(</span><span style="color:#393A34;">set2</span><span style="color:#999999;">))</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">//true</span></span>
<span class="line"><span style="color:#393A34;">    fmt</span><span style="color:#999999;">.</span><span style="color:#998418;">Println</span><span style="color:#999999;">(</span><span style="color:#393A34;">set1</span><span style="color:#999999;">.</span><span style="color:#998418;">Equal</span><span style="color:#999999;">(</span><span style="color:#393A34;">set3</span><span style="color:#999999;">))</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">//false</span></span>
<span class="line"><span style="color:#999999;">}</span></span></code></pre></div><h3 id="Iterate" tabindex="-1"><span id="Iterate">Iterate</span> <a class="header-anchor" href="#Iterate" aria-label="Permalink to &quot;&lt;span id=&quot;Iterate&quot;&gt;Iterate&lt;/span&gt;&quot;">​</a></h3><p>Call function by every element of set</p><p><b>Signature:</b></p><div class="language-go vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">go</span><pre class="shiki dracula-soft vp-code-dark"><code><span class="line"><span style="color:#F286C4;">func</span><span style="color:#F6F6F4;"> (s Set[T]) </span><span style="color:#62E884;">Iterate</span><span style="color:#F6F6F4;">(fn </span><span style="color:#F286C4;">func</span><span style="color:#F6F6F4;">(item T))</span></span></code></pre><pre class="shiki vitesse-light vp-code-light"><code><span class="line"><span style="color:#1E754F;">func</span><span style="color:#393A34;"> </span><span style="color:#999999;">(</span><span style="color:#393A34;">s Set</span><span style="color:#999999;">[</span><span style="color:#393A34;">T</span><span style="color:#999999;">])</span><span style="color:#393A34;"> </span><span style="color:#59873A;">Iterate</span><span style="color:#999999;">(</span><span style="color:#393A34;">fn </span><span style="color:#1E754F;">func</span><span style="color:#999999;">(</span><span style="color:#393A34;">item T</span><span style="color:#999999;">))</span></span></code></pre></div><p><b>Example:</b></p><div class="language-go vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">go</span><pre class="shiki dracula-soft vp-code-dark"><code><span class="line"><span style="color:#F286C4;">package</span><span style="color:#F6F6F4;"> main</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F286C4;">import</span><span style="color:#F6F6F4;"> (</span></span>
<span class="line"><span style="color:#F6F6F4;">    </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">fmt</span><span style="color:#DEE492;">&quot;</span></span>
<span class="line"><span style="color:#F6F6F4;">    set </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/set</span><span style="color:#DEE492;">&quot;</span></span>
<span class="line"><span style="color:#F6F6F4;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F286C4;">func</span><span style="color:#F6F6F4;"> </span><span style="color:#62E884;">main</span><span style="color:#F6F6F4;">() {</span></span>
<span class="line"><span style="color:#F6F6F4;">    set1 </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> set.</span><span style="color:#97E1F1;">NewSet</span><span style="color:#F6F6F4;">(</span><span style="color:#BF9EEE;">1</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">2</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">3</span><span style="color:#F6F6F4;">)</span></span>
<span class="line"><span style="color:#F6F6F4;">    arr </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> []</span><span style="color:#97E1F1;font-style:italic;">int</span><span style="color:#F6F6F4;">{}</span></span>
<span class="line"><span style="color:#F6F6F4;">    set.</span><span style="color:#97E1F1;">Iterate</span><span style="color:#F6F6F4;">(</span><span style="color:#F286C4;">func</span><span style="color:#F6F6F4;">(item </span><span style="color:#97E1F1;font-style:italic;">int</span><span style="color:#F6F6F4;">) {</span></span>
<span class="line"><span style="color:#F6F6F4;">        arr </span><span style="color:#F286C4;">=</span><span style="color:#F6F6F4;"> </span><span style="color:#97E1F1;">append</span><span style="color:#F6F6F4;">(arr, item)</span></span>
<span class="line"><span style="color:#F6F6F4;">    })</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F6F6F4;">    fmt.</span><span style="color:#97E1F1;">Println</span><span style="color:#F6F6F4;">(arr) </span><span style="color:#7B7F8B;">//1,2,3</span></span>
<span class="line"><span style="color:#F6F6F4;">}</span></span></code></pre><pre class="shiki vitesse-light vp-code-light"><code><span class="line"><span style="color:#1E754F;">package</span><span style="color:#393A34;"> </span><span style="color:#59873A;">main</span></span>
<span class="line"></span>
<span class="line"><span style="color:#1E754F;">import</span><span style="color:#393A34;"> </span><span style="color:#999999;">(</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">fmt</span><span style="color:#B5695999;">&quot;</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#59873A;">set</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/set</span><span style="color:#B5695999;">&quot;</span></span>
<span class="line"><span style="color:#999999;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#1E754F;">func</span><span style="color:#393A34;"> </span><span style="color:#59873A;">main</span><span style="color:#999999;">()</span><span style="color:#393A34;"> </span><span style="color:#999999;">{</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B07D48;">set1</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> set</span><span style="color:#999999;">.</span><span style="color:#998418;">NewSet</span><span style="color:#999999;">(</span><span style="color:#2F798A;">1</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#2F798A;">2</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#2F798A;">3</span><span style="color:#999999;">)</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B07D48;">arr</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> </span><span style="color:#999999;">[]</span><span style="color:#AB5959;">int</span><span style="color:#999999;">{}</span></span>
<span class="line"><span style="color:#393A34;">    set</span><span style="color:#999999;">.</span><span style="color:#998418;">Iterate</span><span style="color:#999999;">(</span><span style="color:#1E754F;">func</span><span style="color:#999999;">(</span><span style="color:#393A34;">item </span><span style="color:#AB5959;">int</span><span style="color:#999999;">)</span><span style="color:#393A34;"> </span><span style="color:#999999;">{</span></span>
<span class="line"><span style="color:#393A34;">        </span><span style="color:#B07D48;">arr</span><span style="color:#393A34;"> </span><span style="color:#999999;">=</span><span style="color:#393A34;"> </span><span style="color:#998418;">append</span><span style="color:#999999;">(</span><span style="color:#393A34;">arr</span><span style="color:#999999;">,</span><span style="color:#393A34;"> item</span><span style="color:#999999;">)</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#999999;">})</span></span>
<span class="line"></span>
<span class="line"><span style="color:#393A34;">    fmt</span><span style="color:#999999;">.</span><span style="color:#998418;">Println</span><span style="color:#999999;">(</span><span style="color:#393A34;">arr</span><span style="color:#999999;">)</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">//1,2,3</span></span>
<span class="line"><span style="color:#999999;">}</span></span></code></pre></div><h3 id="EachWithBreak" tabindex="-1"><span id="EachWithBreak">EachWithBreak</span> <a class="header-anchor" href="#EachWithBreak" aria-label="Permalink to &quot;&lt;span id=&quot;EachWithBreak&quot;&gt;EachWithBreak&lt;/span&gt;&quot;">​</a></h3><p>Iterates over elements of a set and invokes function for each element, when iteratee return false, will break the for each loop.</p><p><b>Signature:</b></p><div class="language-go vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">go</span><pre class="shiki dracula-soft vp-code-dark"><code><span class="line"><span style="color:#F286C4;">func</span><span style="color:#F6F6F4;"> (s Set[T]) </span><span style="color:#62E884;">EachWithBreak</span><span style="color:#F6F6F4;">(iteratee </span><span style="color:#F286C4;">func</span><span style="color:#F6F6F4;">(item T) </span><span style="color:#97E1F1;font-style:italic;">bool</span><span style="color:#F6F6F4;">)</span></span></code></pre><pre class="shiki vitesse-light vp-code-light"><code><span class="line"><span style="color:#1E754F;">func</span><span style="color:#393A34;"> </span><span style="color:#999999;">(</span><span style="color:#393A34;">s Set</span><span style="color:#999999;">[</span><span style="color:#393A34;">T</span><span style="color:#999999;">])</span><span style="color:#393A34;"> </span><span style="color:#59873A;">EachWithBreak</span><span style="color:#999999;">(</span><span style="color:#393A34;">iteratee </span><span style="color:#1E754F;">func</span><span style="color:#999999;">(</span><span style="color:#393A34;">item T</span><span style="color:#999999;">)</span><span style="color:#393A34;"> </span><span style="color:#AB5959;">bool</span><span style="color:#999999;">)</span></span></code></pre></div><p><b>Example:</b></p><div class="language-go vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">go</span><pre class="shiki dracula-soft vp-code-dark"><code><span class="line"><span style="color:#F286C4;">package</span><span style="color:#F6F6F4;"> main</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F286C4;">import</span><span style="color:#F6F6F4;"> (</span></span>
<span class="line"><span style="color:#F6F6F4;">    </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">fmt</span><span style="color:#DEE492;">&quot;</span></span>
<span class="line"><span style="color:#F6F6F4;">    set </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/set</span><span style="color:#DEE492;">&quot;</span></span>
<span class="line"><span style="color:#F6F6F4;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F286C4;">func</span><span style="color:#F6F6F4;"> </span><span style="color:#62E884;">main</span><span style="color:#F6F6F4;">() {</span></span>
<span class="line"><span style="color:#F6F6F4;">    s </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> set.</span><span style="color:#97E1F1;">NewSet</span><span style="color:#F6F6F4;">(</span><span style="color:#BF9EEE;">1</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">2</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">3</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">4</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">5</span><span style="color:#F6F6F4;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F6F6F4;">    </span><span style="color:#F286C4;">var</span><span style="color:#F6F6F4;"> sum </span><span style="color:#97E1F1;font-style:italic;">int</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F6F6F4;">    s.</span><span style="color:#97E1F1;">EachWithBreak</span><span style="color:#F6F6F4;">(</span><span style="color:#F286C4;">func</span><span style="color:#F6F6F4;">(n </span><span style="color:#97E1F1;font-style:italic;">int</span><span style="color:#F6F6F4;">) </span><span style="color:#97E1F1;font-style:italic;">bool</span><span style="color:#F6F6F4;"> {</span></span>
<span class="line"><span style="color:#F6F6F4;">        </span><span style="color:#F286C4;">if</span><span style="color:#F6F6F4;"> n </span><span style="color:#F286C4;">&gt;</span><span style="color:#F6F6F4;"> </span><span style="color:#BF9EEE;">3</span><span style="color:#F6F6F4;"> {</span></span>
<span class="line"><span style="color:#F6F6F4;">            </span><span style="color:#F286C4;">return</span><span style="color:#F6F6F4;"> </span><span style="color:#BF9EEE;">false</span></span>
<span class="line"><span style="color:#F6F6F4;">        }</span></span>
<span class="line"><span style="color:#F6F6F4;">        sum </span><span style="color:#F286C4;">+=</span><span style="color:#F6F6F4;"> n</span></span>
<span class="line"><span style="color:#F6F6F4;">        </span><span style="color:#F286C4;">return</span><span style="color:#F6F6F4;"> </span><span style="color:#BF9EEE;">true</span></span>
<span class="line"><span style="color:#F6F6F4;">    })</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F6F6F4;">    fmt.</span><span style="color:#97E1F1;">Println</span><span style="color:#F6F6F4;">(sum) </span><span style="color:#7B7F8B;">//6</span></span>
<span class="line"><span style="color:#F6F6F4;">}</span></span></code></pre><pre class="shiki vitesse-light vp-code-light"><code><span class="line"><span style="color:#1E754F;">package</span><span style="color:#393A34;"> </span><span style="color:#59873A;">main</span></span>
<span class="line"></span>
<span class="line"><span style="color:#1E754F;">import</span><span style="color:#393A34;"> </span><span style="color:#999999;">(</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">fmt</span><span style="color:#B5695999;">&quot;</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#59873A;">set</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/set</span><span style="color:#B5695999;">&quot;</span></span>
<span class="line"><span style="color:#999999;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#1E754F;">func</span><span style="color:#393A34;"> </span><span style="color:#59873A;">main</span><span style="color:#999999;">()</span><span style="color:#393A34;"> </span><span style="color:#999999;">{</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B07D48;">s</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> set</span><span style="color:#999999;">.</span><span style="color:#998418;">NewSet</span><span style="color:#999999;">(</span><span style="color:#2F798A;">1</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#2F798A;">2</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#2F798A;">3</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#2F798A;">4</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#2F798A;">5</span><span style="color:#999999;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#1E754F;">var</span><span style="color:#393A34;"> </span><span style="color:#B07D48;">sum</span><span style="color:#393A34;"> </span><span style="color:#AB5959;">int</span></span>
<span class="line"></span>
<span class="line"><span style="color:#393A34;">    s</span><span style="color:#999999;">.</span><span style="color:#998418;">EachWithBreak</span><span style="color:#999999;">(</span><span style="color:#1E754F;">func</span><span style="color:#999999;">(</span><span style="color:#393A34;">n </span><span style="color:#AB5959;">int</span><span style="color:#999999;">)</span><span style="color:#393A34;"> </span><span style="color:#AB5959;">bool</span><span style="color:#393A34;"> </span><span style="color:#999999;">{</span></span>
<span class="line"><span style="color:#393A34;">        </span><span style="color:#1E754F;">if</span><span style="color:#393A34;"> n </span><span style="color:#AB5959;">&gt;</span><span style="color:#393A34;"> </span><span style="color:#2F798A;">3</span><span style="color:#393A34;"> </span><span style="color:#999999;">{</span></span>
<span class="line"><span style="color:#393A34;">            </span><span style="color:#1E754F;">return</span><span style="color:#393A34;"> </span><span style="color:#1E754F;">false</span></span>
<span class="line"><span style="color:#393A34;">        </span><span style="color:#999999;">}</span></span>
<span class="line"><span style="color:#393A34;">        sum </span><span style="color:#999999;">+=</span><span style="color:#393A34;"> n</span></span>
<span class="line"><span style="color:#393A34;">        </span><span style="color:#1E754F;">return</span><span style="color:#393A34;"> </span><span style="color:#1E754F;">true</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#999999;">})</span></span>
<span class="line"></span>
<span class="line"><span style="color:#393A34;">    fmt</span><span style="color:#999999;">.</span><span style="color:#998418;">Println</span><span style="color:#999999;">(</span><span style="color:#393A34;">sum</span><span style="color:#999999;">)</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">//6</span></span>
<span class="line"><span style="color:#999999;">}</span></span></code></pre></div><h3 id="IsEmpty" tabindex="-1"><span id="IsEmpty">IsEmpty</span> <a class="header-anchor" href="#IsEmpty" aria-label="Permalink to &quot;&lt;span id=&quot;IsEmpty&quot;&gt;IsEmpty&lt;/span&gt;&quot;">​</a></h3><p>Check if the set is empty or not</p><p><b>Signature:</b></p><div class="language-go vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">go</span><pre class="shiki dracula-soft vp-code-dark"><code><span class="line"><span style="color:#F286C4;">func</span><span style="color:#F6F6F4;"> (s Set[T]) </span><span style="color:#62E884;">IsEmpty</span><span style="color:#F6F6F4;">() </span><span style="color:#97E1F1;font-style:italic;">bool</span></span></code></pre><pre class="shiki vitesse-light vp-code-light"><code><span class="line"><span style="color:#1E754F;">func</span><span style="color:#393A34;"> </span><span style="color:#999999;">(</span><span style="color:#393A34;">s Set</span><span style="color:#999999;">[</span><span style="color:#393A34;">T</span><span style="color:#999999;">])</span><span style="color:#393A34;"> </span><span style="color:#59873A;">IsEmpty</span><span style="color:#999999;">()</span><span style="color:#393A34;"> </span><span style="color:#AB5959;">bool</span></span></code></pre></div><p><b>Example:</b></p><div class="language-go vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">go</span><pre class="shiki dracula-soft vp-code-dark"><code><span class="line"><span style="color:#F286C4;">package</span><span style="color:#F6F6F4;"> main</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F286C4;">import</span><span style="color:#F6F6F4;"> (</span></span>
<span class="line"><span style="color:#F6F6F4;">    </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">fmt</span><span style="color:#DEE492;">&quot;</span></span>
<span class="line"><span style="color:#F6F6F4;">    set </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/set</span><span style="color:#DEE492;">&quot;</span></span>
<span class="line"><span style="color:#F6F6F4;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F286C4;">func</span><span style="color:#F6F6F4;"> </span><span style="color:#62E884;">main</span><span style="color:#F6F6F4;">() {</span></span>
<span class="line"><span style="color:#F6F6F4;">    set1 </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> set.</span><span style="color:#97E1F1;">NewSet</span><span style="color:#F6F6F4;">(</span><span style="color:#BF9EEE;">1</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">2</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">3</span><span style="color:#F6F6F4;">)</span></span>
<span class="line"><span style="color:#F6F6F4;">    set2 </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> set.</span><span style="color:#97E1F1;">NewSet</span><span style="color:#F6F6F4;">()</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F6F6F4;">    fmt.</span><span style="color:#97E1F1;">Println</span><span style="color:#F6F6F4;">(set1.</span><span style="color:#97E1F1;">IsEmpty</span><span style="color:#F6F6F4;">()) </span><span style="color:#7B7F8B;">//false</span></span>
<span class="line"><span style="color:#F6F6F4;">    fmt.</span><span style="color:#97E1F1;">Println</span><span style="color:#F6F6F4;">(set2.</span><span style="color:#97E1F1;">IsEmpty</span><span style="color:#F6F6F4;">()) </span><span style="color:#7B7F8B;">//true</span></span>
<span class="line"><span style="color:#F6F6F4;">}</span></span></code></pre><pre class="shiki vitesse-light vp-code-light"><code><span class="line"><span style="color:#1E754F;">package</span><span style="color:#393A34;"> </span><span style="color:#59873A;">main</span></span>
<span class="line"></span>
<span class="line"><span style="color:#1E754F;">import</span><span style="color:#393A34;"> </span><span style="color:#999999;">(</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">fmt</span><span style="color:#B5695999;">&quot;</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#59873A;">set</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/set</span><span style="color:#B5695999;">&quot;</span></span>
<span class="line"><span style="color:#999999;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#1E754F;">func</span><span style="color:#393A34;"> </span><span style="color:#59873A;">main</span><span style="color:#999999;">()</span><span style="color:#393A34;"> </span><span style="color:#999999;">{</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B07D48;">set1</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> set</span><span style="color:#999999;">.</span><span style="color:#998418;">NewSet</span><span style="color:#999999;">(</span><span style="color:#2F798A;">1</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#2F798A;">2</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#2F798A;">3</span><span style="color:#999999;">)</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B07D48;">set2</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> set</span><span style="color:#999999;">.</span><span style="color:#998418;">NewSet</span><span style="color:#999999;">()</span></span>
<span class="line"></span>
<span class="line"><span style="color:#393A34;">    fmt</span><span style="color:#999999;">.</span><span style="color:#998418;">Println</span><span style="color:#999999;">(</span><span style="color:#393A34;">set1</span><span style="color:#999999;">.</span><span style="color:#998418;">IsEmpty</span><span style="color:#999999;">())</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">//false</span></span>
<span class="line"><span style="color:#393A34;">    fmt</span><span style="color:#999999;">.</span><span style="color:#998418;">Println</span><span style="color:#999999;">(</span><span style="color:#393A34;">set2</span><span style="color:#999999;">.</span><span style="color:#998418;">IsEmpty</span><span style="color:#999999;">())</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">//true</span></span>
<span class="line"><span style="color:#999999;">}</span></span></code></pre></div><h3 id="Union" tabindex="-1"><span id="Union">Union</span> <a class="header-anchor" href="#Union" aria-label="Permalink to &quot;&lt;span id=&quot;Union&quot;&gt;Union&lt;/span&gt;&quot;">​</a></h3><p>Create a new set contain all element of set s and other</p><p><b>Signature:</b></p><div class="language-go vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">go</span><pre class="shiki dracula-soft vp-code-dark"><code><span class="line"><span style="color:#F286C4;">func</span><span style="color:#F6F6F4;"> (s Set[T]) </span><span style="color:#62E884;">Union</span><span style="color:#F6F6F4;">(other Set[T]) Set[T]</span></span></code></pre><pre class="shiki vitesse-light vp-code-light"><code><span class="line"><span style="color:#1E754F;">func</span><span style="color:#393A34;"> </span><span style="color:#999999;">(</span><span style="color:#393A34;">s Set</span><span style="color:#999999;">[</span><span style="color:#393A34;">T</span><span style="color:#999999;">])</span><span style="color:#393A34;"> </span><span style="color:#59873A;">Union</span><span style="color:#999999;">(</span><span style="color:#393A34;">other Set</span><span style="color:#999999;">[</span><span style="color:#393A34;">T</span><span style="color:#999999;">])</span><span style="color:#393A34;"> Set</span><span style="color:#999999;">[</span><span style="color:#393A34;">T</span><span style="color:#999999;">]</span></span></code></pre></div><p><b>Example:</b></p><div class="language-go vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">go</span><pre class="shiki dracula-soft vp-code-dark"><code><span class="line"><span style="color:#F286C4;">package</span><span style="color:#F6F6F4;"> main</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F286C4;">import</span><span style="color:#F6F6F4;"> (</span></span>
<span class="line"><span style="color:#F6F6F4;">    </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">fmt</span><span style="color:#DEE492;">&quot;</span></span>
<span class="line"><span style="color:#F6F6F4;">    set </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/set</span><span style="color:#DEE492;">&quot;</span></span>
<span class="line"><span style="color:#F6F6F4;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F286C4;">func</span><span style="color:#F6F6F4;"> </span><span style="color:#62E884;">main</span><span style="color:#F6F6F4;">() {</span></span>
<span class="line"><span style="color:#F6F6F4;">    set1 </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> set.</span><span style="color:#97E1F1;">NewSet</span><span style="color:#F6F6F4;">(</span><span style="color:#BF9EEE;">1</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">2</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">3</span><span style="color:#F6F6F4;">)</span></span>
<span class="line"><span style="color:#F6F6F4;">    set2 </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> set.</span><span style="color:#97E1F1;">NewSet</span><span style="color:#F6F6F4;">(</span><span style="color:#BF9EEE;">2</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">3</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">4</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">5</span><span style="color:#F6F6F4;">)</span></span>
<span class="line"><span style="color:#F6F6F4;">    set3 </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> set1.</span><span style="color:#97E1F1;">Union</span><span style="color:#F6F6F4;">(set2)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F6F6F4;">    fmt.</span><span style="color:#97E1F1;">Println</span><span style="color:#F6F6F4;">(set3.</span><span style="color:#97E1F1;">Values</span><span style="color:#F6F6F4;">()) </span><span style="color:#7B7F8B;">//1,2,3,4,5</span></span>
<span class="line"><span style="color:#F6F6F4;">}</span></span></code></pre><pre class="shiki vitesse-light vp-code-light"><code><span class="line"><span style="color:#1E754F;">package</span><span style="color:#393A34;"> </span><span style="color:#59873A;">main</span></span>
<span class="line"></span>
<span class="line"><span style="color:#1E754F;">import</span><span style="color:#393A34;"> </span><span style="color:#999999;">(</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">fmt</span><span style="color:#B5695999;">&quot;</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#59873A;">set</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/set</span><span style="color:#B5695999;">&quot;</span></span>
<span class="line"><span style="color:#999999;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#1E754F;">func</span><span style="color:#393A34;"> </span><span style="color:#59873A;">main</span><span style="color:#999999;">()</span><span style="color:#393A34;"> </span><span style="color:#999999;">{</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B07D48;">set1</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> set</span><span style="color:#999999;">.</span><span style="color:#998418;">NewSet</span><span style="color:#999999;">(</span><span style="color:#2F798A;">1</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#2F798A;">2</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#2F798A;">3</span><span style="color:#999999;">)</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B07D48;">set2</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> set</span><span style="color:#999999;">.</span><span style="color:#998418;">NewSet</span><span style="color:#999999;">(</span><span style="color:#2F798A;">2</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#2F798A;">3</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#2F798A;">4</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#2F798A;">5</span><span style="color:#999999;">)</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B07D48;">set3</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> set1</span><span style="color:#999999;">.</span><span style="color:#998418;">Union</span><span style="color:#999999;">(</span><span style="color:#393A34;">set2</span><span style="color:#999999;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#393A34;">    fmt</span><span style="color:#999999;">.</span><span style="color:#998418;">Println</span><span style="color:#999999;">(</span><span style="color:#393A34;">set3</span><span style="color:#999999;">.</span><span style="color:#998418;">Values</span><span style="color:#999999;">())</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">//1,2,3,4,5</span></span>
<span class="line"><span style="color:#999999;">}</span></span></code></pre></div><h3 id="Intersection" tabindex="-1"><span id="Intersection">Intersection</span> <a class="header-anchor" href="#Intersection" aria-label="Permalink to &quot;&lt;span id=&quot;Intersection&quot;&gt;Intersection&lt;/span&gt;&quot;">​</a></h3><p>Create a new set whose element both be contained in set s and other</p><p><b>Signature:</b></p><div class="language-go vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">go</span><pre class="shiki dracula-soft vp-code-dark"><code><span class="line"><span style="color:#F286C4;">func</span><span style="color:#F6F6F4;"> (s Set[T]) </span><span style="color:#62E884;">Intersection</span><span style="color:#F6F6F4;">(other Set[T]) Set[T]</span></span></code></pre><pre class="shiki vitesse-light vp-code-light"><code><span class="line"><span style="color:#1E754F;">func</span><span style="color:#393A34;"> </span><span style="color:#999999;">(</span><span style="color:#393A34;">s Set</span><span style="color:#999999;">[</span><span style="color:#393A34;">T</span><span style="color:#999999;">])</span><span style="color:#393A34;"> </span><span style="color:#59873A;">Intersection</span><span style="color:#999999;">(</span><span style="color:#393A34;">other Set</span><span style="color:#999999;">[</span><span style="color:#393A34;">T</span><span style="color:#999999;">])</span><span style="color:#393A34;"> Set</span><span style="color:#999999;">[</span><span style="color:#393A34;">T</span><span style="color:#999999;">]</span></span></code></pre></div><p><b>Example:</b></p><div class="language-go vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">go</span><pre class="shiki dracula-soft vp-code-dark"><code><span class="line"><span style="color:#F286C4;">package</span><span style="color:#F6F6F4;"> main</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F286C4;">import</span><span style="color:#F6F6F4;"> (</span></span>
<span class="line"><span style="color:#F6F6F4;">    </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">fmt</span><span style="color:#DEE492;">&quot;</span></span>
<span class="line"><span style="color:#F6F6F4;">    set </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/set</span><span style="color:#DEE492;">&quot;</span></span>
<span class="line"><span style="color:#F6F6F4;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F286C4;">func</span><span style="color:#F6F6F4;"> </span><span style="color:#62E884;">main</span><span style="color:#F6F6F4;">() {</span></span>
<span class="line"><span style="color:#F6F6F4;">    set1 </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> set.</span><span style="color:#97E1F1;">NewSet</span><span style="color:#F6F6F4;">(</span><span style="color:#BF9EEE;">1</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">2</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">3</span><span style="color:#F6F6F4;">)</span></span>
<span class="line"><span style="color:#F6F6F4;">    set2 </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> set.</span><span style="color:#97E1F1;">NewSet</span><span style="color:#F6F6F4;">(</span><span style="color:#BF9EEE;">2</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">3</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">4</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">5</span><span style="color:#F6F6F4;">)</span></span>
<span class="line"><span style="color:#F6F6F4;">    set3 </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> set1.</span><span style="color:#97E1F1;">Intersection</span><span style="color:#F6F6F4;">(set2)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F6F6F4;">    fmt.</span><span style="color:#97E1F1;">Println</span><span style="color:#F6F6F4;">(set3.</span><span style="color:#97E1F1;">Values</span><span style="color:#F6F6F4;">()) </span><span style="color:#7B7F8B;">//2,3</span></span>
<span class="line"><span style="color:#F6F6F4;">}</span></span></code></pre><pre class="shiki vitesse-light vp-code-light"><code><span class="line"><span style="color:#1E754F;">package</span><span style="color:#393A34;"> </span><span style="color:#59873A;">main</span></span>
<span class="line"></span>
<span class="line"><span style="color:#1E754F;">import</span><span style="color:#393A34;"> </span><span style="color:#999999;">(</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">fmt</span><span style="color:#B5695999;">&quot;</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#59873A;">set</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/set</span><span style="color:#B5695999;">&quot;</span></span>
<span class="line"><span style="color:#999999;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#1E754F;">func</span><span style="color:#393A34;"> </span><span style="color:#59873A;">main</span><span style="color:#999999;">()</span><span style="color:#393A34;"> </span><span style="color:#999999;">{</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B07D48;">set1</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> set</span><span style="color:#999999;">.</span><span style="color:#998418;">NewSet</span><span style="color:#999999;">(</span><span style="color:#2F798A;">1</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#2F798A;">2</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#2F798A;">3</span><span style="color:#999999;">)</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B07D48;">set2</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> set</span><span style="color:#999999;">.</span><span style="color:#998418;">NewSet</span><span style="color:#999999;">(</span><span style="color:#2F798A;">2</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#2F798A;">3</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#2F798A;">4</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#2F798A;">5</span><span style="color:#999999;">)</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B07D48;">set3</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> set1</span><span style="color:#999999;">.</span><span style="color:#998418;">Intersection</span><span style="color:#999999;">(</span><span style="color:#393A34;">set2</span><span style="color:#999999;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#393A34;">    fmt</span><span style="color:#999999;">.</span><span style="color:#998418;">Println</span><span style="color:#999999;">(</span><span style="color:#393A34;">set3</span><span style="color:#999999;">.</span><span style="color:#998418;">Values</span><span style="color:#999999;">())</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">//2,3</span></span>
<span class="line"><span style="color:#999999;">}</span></span></code></pre></div><h3 id="SymmetricDifference" tabindex="-1"><span id="SymmetricDifference">SymmetricDifference</span> <a class="header-anchor" href="#SymmetricDifference" aria-label="Permalink to &quot;&lt;span id=&quot;SymmetricDifference&quot;&gt;SymmetricDifference&lt;/span&gt;&quot;">​</a></h3><p>Create a new set whose element is in set1 or set2, but not in both set1 and set2</p><p><b>Signature:</b></p><div class="language-go vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">go</span><pre class="shiki dracula-soft vp-code-dark"><code><span class="line"><span style="color:#F286C4;">func</span><span style="color:#F6F6F4;"> (s Set[T]) </span><span style="color:#62E884;">SymmetricDifference</span><span style="color:#F6F6F4;">(other Set[T]) Set[T]</span></span></code></pre><pre class="shiki vitesse-light vp-code-light"><code><span class="line"><span style="color:#1E754F;">func</span><span style="color:#393A34;"> </span><span style="color:#999999;">(</span><span style="color:#393A34;">s Set</span><span style="color:#999999;">[</span><span style="color:#393A34;">T</span><span style="color:#999999;">])</span><span style="color:#393A34;"> </span><span style="color:#59873A;">SymmetricDifference</span><span style="color:#999999;">(</span><span style="color:#393A34;">other Set</span><span style="color:#999999;">[</span><span style="color:#393A34;">T</span><span style="color:#999999;">])</span><span style="color:#393A34;"> Set</span><span style="color:#999999;">[</span><span style="color:#393A34;">T</span><span style="color:#999999;">]</span></span></code></pre></div><p><b>Example:</b></p><div class="language-go vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">go</span><pre class="shiki dracula-soft vp-code-dark"><code><span class="line"><span style="color:#F286C4;">package</span><span style="color:#F6F6F4;"> main</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F286C4;">import</span><span style="color:#F6F6F4;"> (</span></span>
<span class="line"><span style="color:#F6F6F4;">    </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">fmt</span><span style="color:#DEE492;">&quot;</span></span>
<span class="line"><span style="color:#F6F6F4;">    set </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/set</span><span style="color:#DEE492;">&quot;</span></span>
<span class="line"><span style="color:#F6F6F4;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F286C4;">func</span><span style="color:#F6F6F4;"> </span><span style="color:#62E884;">main</span><span style="color:#F6F6F4;">() {</span></span>
<span class="line"><span style="color:#F6F6F4;">    set1 </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> set.</span><span style="color:#97E1F1;">NewSet</span><span style="color:#F6F6F4;">(</span><span style="color:#BF9EEE;">1</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">2</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">3</span><span style="color:#F6F6F4;">)</span></span>
<span class="line"><span style="color:#F6F6F4;">    set2 </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> set.</span><span style="color:#97E1F1;">NewSet</span><span style="color:#F6F6F4;">(</span><span style="color:#BF9EEE;">2</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">3</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">4</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">5</span><span style="color:#F6F6F4;">)</span></span>
<span class="line"><span style="color:#F6F6F4;">    set3 </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> set1.</span><span style="color:#97E1F1;">SymmetricDifference</span><span style="color:#F6F6F4;">(set2)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F6F6F4;">    fmt.</span><span style="color:#97E1F1;">Println</span><span style="color:#F6F6F4;">(set3.</span><span style="color:#97E1F1;">Values</span><span style="color:#F6F6F4;">()) </span><span style="color:#7B7F8B;">//1,4,5</span></span>
<span class="line"><span style="color:#F6F6F4;">}</span></span></code></pre><pre class="shiki vitesse-light vp-code-light"><code><span class="line"><span style="color:#1E754F;">package</span><span style="color:#393A34;"> </span><span style="color:#59873A;">main</span></span>
<span class="line"></span>
<span class="line"><span style="color:#1E754F;">import</span><span style="color:#393A34;"> </span><span style="color:#999999;">(</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">fmt</span><span style="color:#B5695999;">&quot;</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#59873A;">set</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/set</span><span style="color:#B5695999;">&quot;</span></span>
<span class="line"><span style="color:#999999;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#1E754F;">func</span><span style="color:#393A34;"> </span><span style="color:#59873A;">main</span><span style="color:#999999;">()</span><span style="color:#393A34;"> </span><span style="color:#999999;">{</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B07D48;">set1</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> set</span><span style="color:#999999;">.</span><span style="color:#998418;">NewSet</span><span style="color:#999999;">(</span><span style="color:#2F798A;">1</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#2F798A;">2</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#2F798A;">3</span><span style="color:#999999;">)</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B07D48;">set2</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> set</span><span style="color:#999999;">.</span><span style="color:#998418;">NewSet</span><span style="color:#999999;">(</span><span style="color:#2F798A;">2</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#2F798A;">3</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#2F798A;">4</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#2F798A;">5</span><span style="color:#999999;">)</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B07D48;">set3</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> set1</span><span style="color:#999999;">.</span><span style="color:#998418;">SymmetricDifference</span><span style="color:#999999;">(</span><span style="color:#393A34;">set2</span><span style="color:#999999;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#393A34;">    fmt</span><span style="color:#999999;">.</span><span style="color:#998418;">Println</span><span style="color:#999999;">(</span><span style="color:#393A34;">set3</span><span style="color:#999999;">.</span><span style="color:#998418;">Values</span><span style="color:#999999;">())</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">//1,4,5</span></span>
<span class="line"><span style="color:#999999;">}</span></span></code></pre></div><h3 id="Minus" tabindex="-1"><span id="Minus">Minus</span> <a class="header-anchor" href="#Minus" aria-label="Permalink to &quot;&lt;span id=&quot;Minus&quot;&gt;Minus&lt;/span&gt;&quot;">​</a></h3><p>Create an set of whose element in origin set but not in compared set</p><p><b>Signature:</b></p><div class="language-go vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">go</span><pre class="shiki dracula-soft vp-code-dark"><code><span class="line"><span style="color:#F286C4;">func</span><span style="color:#F6F6F4;"> (s Set[T]) </span><span style="color:#62E884;">Minus</span><span style="color:#F6F6F4;">(comparedSet Set[T]) Set[T]</span></span></code></pre><pre class="shiki vitesse-light vp-code-light"><code><span class="line"><span style="color:#1E754F;">func</span><span style="color:#393A34;"> </span><span style="color:#999999;">(</span><span style="color:#393A34;">s Set</span><span style="color:#999999;">[</span><span style="color:#393A34;">T</span><span style="color:#999999;">])</span><span style="color:#393A34;"> </span><span style="color:#59873A;">Minus</span><span style="color:#999999;">(</span><span style="color:#393A34;">comparedSet Set</span><span style="color:#999999;">[</span><span style="color:#393A34;">T</span><span style="color:#999999;">])</span><span style="color:#393A34;"> Set</span><span style="color:#999999;">[</span><span style="color:#393A34;">T</span><span style="color:#999999;">]</span></span></code></pre></div><p><b>Example:</b></p><div class="language-go vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">go</span><pre class="shiki dracula-soft vp-code-dark"><code><span class="line"><span style="color:#F286C4;">package</span><span style="color:#F6F6F4;"> main</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F286C4;">import</span><span style="color:#F6F6F4;"> (</span></span>
<span class="line"><span style="color:#F6F6F4;">    </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">fmt</span><span style="color:#DEE492;">&quot;</span></span>
<span class="line"><span style="color:#F6F6F4;">    set </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/set</span><span style="color:#DEE492;">&quot;</span></span>
<span class="line"><span style="color:#F6F6F4;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F286C4;">func</span><span style="color:#F6F6F4;"> </span><span style="color:#62E884;">main</span><span style="color:#F6F6F4;">() {</span></span>
<span class="line"><span style="color:#F6F6F4;">    set1 </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> set.</span><span style="color:#97E1F1;">NewSet</span><span style="color:#F6F6F4;">(</span><span style="color:#BF9EEE;">1</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">2</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">3</span><span style="color:#F6F6F4;">)</span></span>
<span class="line"><span style="color:#F6F6F4;">    set2 </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> set.</span><span style="color:#97E1F1;">NewSet</span><span style="color:#F6F6F4;">(</span><span style="color:#BF9EEE;">2</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">3</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">4</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">5</span><span style="color:#F6F6F4;">)</span></span>
<span class="line"><span style="color:#F6F6F4;">    set3 </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> set.</span><span style="color:#97E1F1;">NewSet</span><span style="color:#F6F6F4;">(</span><span style="color:#BF9EEE;">2</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">3</span><span style="color:#F6F6F4;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F6F6F4;">    res1 </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> set1.</span><span style="color:#97E1F1;">Minus</span><span style="color:#F6F6F4;">(set2)</span></span>
<span class="line"><span style="color:#F6F6F4;">    fmt.</span><span style="color:#97E1F1;">Println</span><span style="color:#F6F6F4;">(res1.</span><span style="color:#97E1F1;">Values</span><span style="color:#F6F6F4;">()) </span><span style="color:#7B7F8B;">//1</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F6F6F4;">    res2 </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> set2.</span><span style="color:#97E1F1;">Minus</span><span style="color:#F6F6F4;">(set3)</span></span>
<span class="line"><span style="color:#F6F6F4;">    fmt.</span><span style="color:#97E1F1;">Println</span><span style="color:#F6F6F4;">(res2.</span><span style="color:#97E1F1;">Values</span><span style="color:#F6F6F4;">()) </span><span style="color:#7B7F8B;">//4,5</span></span>
<span class="line"><span style="color:#F6F6F4;">}</span></span></code></pre><pre class="shiki vitesse-light vp-code-light"><code><span class="line"><span style="color:#1E754F;">package</span><span style="color:#393A34;"> </span><span style="color:#59873A;">main</span></span>
<span class="line"></span>
<span class="line"><span style="color:#1E754F;">import</span><span style="color:#393A34;"> </span><span style="color:#999999;">(</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">fmt</span><span style="color:#B5695999;">&quot;</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#59873A;">set</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/set</span><span style="color:#B5695999;">&quot;</span></span>
<span class="line"><span style="color:#999999;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#1E754F;">func</span><span style="color:#393A34;"> </span><span style="color:#59873A;">main</span><span style="color:#999999;">()</span><span style="color:#393A34;"> </span><span style="color:#999999;">{</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B07D48;">set1</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> set</span><span style="color:#999999;">.</span><span style="color:#998418;">NewSet</span><span style="color:#999999;">(</span><span style="color:#2F798A;">1</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#2F798A;">2</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#2F798A;">3</span><span style="color:#999999;">)</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B07D48;">set2</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> set</span><span style="color:#999999;">.</span><span style="color:#998418;">NewSet</span><span style="color:#999999;">(</span><span style="color:#2F798A;">2</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#2F798A;">3</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#2F798A;">4</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#2F798A;">5</span><span style="color:#999999;">)</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B07D48;">set3</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> set</span><span style="color:#999999;">.</span><span style="color:#998418;">NewSet</span><span style="color:#999999;">(</span><span style="color:#2F798A;">2</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#2F798A;">3</span><span style="color:#999999;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B07D48;">res1</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> set1</span><span style="color:#999999;">.</span><span style="color:#998418;">Minus</span><span style="color:#999999;">(</span><span style="color:#393A34;">set2</span><span style="color:#999999;">)</span></span>
<span class="line"><span style="color:#393A34;">    fmt</span><span style="color:#999999;">.</span><span style="color:#998418;">Println</span><span style="color:#999999;">(</span><span style="color:#393A34;">res1</span><span style="color:#999999;">.</span><span style="color:#998418;">Values</span><span style="color:#999999;">())</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">//1</span></span>
<span class="line"></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B07D48;">res2</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> set2</span><span style="color:#999999;">.</span><span style="color:#998418;">Minus</span><span style="color:#999999;">(</span><span style="color:#393A34;">set3</span><span style="color:#999999;">)</span></span>
<span class="line"><span style="color:#393A34;">    fmt</span><span style="color:#999999;">.</span><span style="color:#998418;">Println</span><span style="color:#999999;">(</span><span style="color:#393A34;">res2</span><span style="color:#999999;">.</span><span style="color:#998418;">Values</span><span style="color:#999999;">())</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">//4,5</span></span>
<span class="line"><span style="color:#999999;">}</span></span></code></pre></div><h3 id="Pop" tabindex="-1"><span id="Pop">Pop</span> <a class="header-anchor" href="#Pop" aria-label="Permalink to &quot;&lt;span id=&quot;Pop&quot;&gt;Pop&lt;/span&gt;&quot;">​</a></h3><p>Delete the top element of set then return it, if set is empty, return nil-value of T and false.</p><p><b>Signature:</b></p><div class="language-go vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">go</span><pre class="shiki dracula-soft vp-code-dark"><code><span class="line"><span style="color:#F286C4;">func</span><span style="color:#F6F6F4;"> (s Set[T]) </span><span style="color:#62E884;">Pop</span><span style="color:#F6F6F4;">() (v T, ok </span><span style="color:#97E1F1;font-style:italic;">bool</span><span style="color:#F6F6F4;">)</span></span></code></pre><pre class="shiki vitesse-light vp-code-light"><code><span class="line"><span style="color:#1E754F;">func</span><span style="color:#393A34;"> </span><span style="color:#999999;">(</span><span style="color:#393A34;">s Set</span><span style="color:#999999;">[</span><span style="color:#393A34;">T</span><span style="color:#999999;">])</span><span style="color:#393A34;"> </span><span style="color:#59873A;">Pop</span><span style="color:#999999;">()</span><span style="color:#393A34;"> </span><span style="color:#999999;">(</span><span style="color:#393A34;">v T</span><span style="color:#999999;">,</span><span style="color:#393A34;"> ok </span><span style="color:#AB5959;">bool</span><span style="color:#999999;">)</span></span></code></pre></div><p><b>Example:</b></p><div class="language-go vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">go</span><pre class="shiki dracula-soft vp-code-dark"><code><span class="line"><span style="color:#F286C4;">package</span><span style="color:#F6F6F4;"> main</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F286C4;">import</span><span style="color:#F6F6F4;"> (</span></span>
<span class="line"><span style="color:#F6F6F4;">    </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">fmt</span><span style="color:#DEE492;">&quot;</span></span>
<span class="line"><span style="color:#F6F6F4;">    set </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/set</span><span style="color:#DEE492;">&quot;</span></span>
<span class="line"><span style="color:#F6F6F4;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F286C4;">func</span><span style="color:#F6F6F4;"> </span><span style="color:#62E884;">main</span><span style="color:#F6F6F4;">() {</span></span>
<span class="line"><span style="color:#F6F6F4;">    s </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> set.NewSet[</span><span style="color:#97E1F1;font-style:italic;">int</span><span style="color:#F6F6F4;">]()</span></span>
<span class="line"><span style="color:#F6F6F4;">    s.</span><span style="color:#97E1F1;">Add</span><span style="color:#F6F6F4;">(</span><span style="color:#BF9EEE;">1</span><span style="color:#F6F6F4;">)</span></span>
<span class="line"><span style="color:#F6F6F4;">    s.</span><span style="color:#97E1F1;">Add</span><span style="color:#F6F6F4;">(</span><span style="color:#BF9EEE;">2</span><span style="color:#F6F6F4;">)</span></span>
<span class="line"><span style="color:#F6F6F4;">    s.</span><span style="color:#97E1F1;">Add</span><span style="color:#F6F6F4;">(</span><span style="color:#BF9EEE;">3</span><span style="color:#F6F6F4;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F6F6F4;">    val, ok </span><span style="color:#F286C4;">=</span><span style="color:#F6F6F4;"> s.</span><span style="color:#97E1F1;">Pop</span><span style="color:#F6F6F4;">()</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F6F6F4;">    fmt.</span><span style="color:#97E1F1;">Println</span><span style="color:#F6F6F4;">(val) </span><span style="color:#7B7F8B;">// 3</span></span>
<span class="line"><span style="color:#F6F6F4;">    fmt.</span><span style="color:#97E1F1;">Println</span><span style="color:#F6F6F4;">(ok) </span><span style="color:#7B7F8B;">// true</span></span>
<span class="line"><span style="color:#F6F6F4;">}</span></span></code></pre><pre class="shiki vitesse-light vp-code-light"><code><span class="line"><span style="color:#1E754F;">package</span><span style="color:#393A34;"> </span><span style="color:#59873A;">main</span></span>
<span class="line"></span>
<span class="line"><span style="color:#1E754F;">import</span><span style="color:#393A34;"> </span><span style="color:#999999;">(</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">fmt</span><span style="color:#B5695999;">&quot;</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#59873A;">set</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/set</span><span style="color:#B5695999;">&quot;</span></span>
<span class="line"><span style="color:#999999;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#1E754F;">func</span><span style="color:#393A34;"> </span><span style="color:#59873A;">main</span><span style="color:#999999;">()</span><span style="color:#393A34;"> </span><span style="color:#999999;">{</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B07D48;">s</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> set</span><span style="color:#999999;">.</span><span style="color:#393A34;">NewSet</span><span style="color:#999999;">[</span><span style="color:#AB5959;">int</span><span style="color:#999999;">]()</span></span>
<span class="line"><span style="color:#393A34;">    s</span><span style="color:#999999;">.</span><span style="color:#998418;">Add</span><span style="color:#999999;">(</span><span style="color:#2F798A;">1</span><span style="color:#999999;">)</span></span>
<span class="line"><span style="color:#393A34;">    s</span><span style="color:#999999;">.</span><span style="color:#998418;">Add</span><span style="color:#999999;">(</span><span style="color:#2F798A;">2</span><span style="color:#999999;">)</span></span>
<span class="line"><span style="color:#393A34;">    s</span><span style="color:#999999;">.</span><span style="color:#998418;">Add</span><span style="color:#999999;">(</span><span style="color:#2F798A;">3</span><span style="color:#999999;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B07D48;">val</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#B07D48;">ok</span><span style="color:#393A34;"> </span><span style="color:#999999;">=</span><span style="color:#393A34;"> s</span><span style="color:#999999;">.</span><span style="color:#998418;">Pop</span><span style="color:#999999;">()</span></span>
<span class="line"></span>
<span class="line"><span style="color:#393A34;">    fmt</span><span style="color:#999999;">.</span><span style="color:#998418;">Println</span><span style="color:#999999;">(</span><span style="color:#393A34;">val</span><span style="color:#999999;">)</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">// 3</span></span>
<span class="line"><span style="color:#393A34;">    fmt</span><span style="color:#999999;">.</span><span style="color:#998418;">Println</span><span style="color:#999999;">(</span><span style="color:#393A34;">ok</span><span style="color:#999999;">)</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">// true</span></span>
<span class="line"><span style="color:#999999;">}</span></span></code></pre></div>`,121),m=[t,c,r,y,F,i,A,E,d,u,g];function h(f,B,v,b,C,k){return p(),o("div",null,m)}const D=l(e,[["render",h]]);export{S as __pageData,D as default};
