import{_ as l,o as p,c as o,k as s,a,X as n}from"./chunks/framework.6e839c56.js";const k=JSON.parse('{"title":"List","description":"","frontmatter":{},"headers":[],"relativePath":"en/api/packages/datastructure/list.md","filePath":"en/api/packages/datastructure/list.md"}'),e={name:"en/api/packages/datastructure/list.md"},t=s("h1",{id:"List",tabindex:"-1"},[a("List "),s("a",{class:"header-anchor",href:"#List","aria-label":'Permalink to "List"'},"​")],-1),c=s("p",null,"List is a linear table, implemented with slice.",-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/list/list.go",target:"_blank",rel:"noreferrer"},"https://github.com/duke-git/lancet/blob/main/datastructure/list/list.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;">    list </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/list</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;">list</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/list</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),u=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="#NewList">NewList</a></li><li><a href="#Contain">Contain</a></li><li><a href="#Data">Data</a></li><li><a href="#ValueOf">ValueOf</a></li><li><a href="#IndexOf">IndexOf</a></li><li><a href="#LastIndexOf">LastIndexOf</a></li><li><a href="#IndexOfFunc">IndexOfFunc</a></li><li><a href="#LastIndexOfFunc">LastIndexOfFunc</a></li><li><a href="#Push">Push</a></li><li><a href="#PopFirst">PopFirst</a></li><li><a href="#PopLast">PopLast</a></li><li><a href="#DeleteAt">DeleteAt</a></li><li><a href="#InsertAt">InsertAt</a></li><li><a href="#UpdateAt">UpdateAt</a></li><li><a href="#Equal">Equal</a></li><li><a href="#IsEmpty">IsEmpty</a></li><li><a href="#Clear">Clear</a></li><li><a href="#Clone">Clone</a></li><li><a href="#Merge">Merge</a></li><li><a href="#Size">Size</a></li><li><a href="#Cap">Cap</a></li><li><a href="#Swap">Swap</a></li><li><a href="#Reverse">Reverse</a></li><li><a href="#Unique">Unique</a></li><li><a href="#Union">Union</a></li><li><a href="#Intersection">Intersection</a></li><li><a href="#Difference">Difference</a></li><li><a href="#SymmetricDifference">SymmetricDifference</a></li><li><a href="#RetainAll">RetainAll</a></li><li><a href="#DeleteAll">DeleteAll</a></li><li><a href="#ForEach">ForEach</a></li><li><a href="#Iterator">Iterator</a></li><li><a href="#ListToMap">ListToMap</a></li><li><a href="#SubList">SubList</a></li><li><a href="#DeleteIf">DeleteIf</a></li></ul>',2),d=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="NewList" tabindex="-1"><span id="NewList">NewList</span> <a class="header-anchor" href="#NewList" aria-label="Permalink to &quot;&lt;span id=&quot;NewList&quot;&gt;NewList&lt;/span&gt;&quot;">​</a></h3><p>List is a linear table, implemented with slice. NewList function return a list pointer</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;">List</span><span style="color:#F6F6F4;">[T any] </span><span style="color:#F286C4;">struct</span><span style="color:#F6F6F4;"> {</span></span>
<span class="line"><span style="color:#F6F6F4;">    data []T</span></span>
<span class="line"><span style="color:#F6F6F4;">}</span></span>
<span class="line"><span style="color:#F286C4;">func</span><span style="color:#F6F6F4;"> NewList[T any](data []T) </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">List[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;">List</span><span style="color:#999999;">[</span><span style="color:#393A34;">T any</span><span style="color:#999999;">]</span><span style="color:#393A34;"> </span><span style="color:#1E754F;">struct</span><span style="color:#393A34;"> </span><span style="color:#999999;">{</span></span>
<span class="line"><span style="color:#393A34;">    data </span><span style="color:#999999;">[]</span><span style="color:#393A34;">T</span></span>
<span class="line"><span style="color:#999999;">}</span></span>
<span class="line"><span style="color:#1E754F;">func</span><span style="color:#393A34;"> NewList</span><span style="color:#999999;">[</span><span style="color:#393A34;">T any</span><span style="color:#999999;">](</span><span style="color:#393A34;">data </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;">*</span><span style="color:#393A34;">List</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;">    list </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/list</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;">    li </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> list.</span><span style="color:#97E1F1;">NewList</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;">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;">(li)</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;">list</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/list</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;">li</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> list</span><span style="color:#999999;">.</span><span style="color:#998418;">NewList</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;">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;">li</span><span style="color:#999999;">)</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 the value in the list 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;"> (l </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">List[T]) </span><span style="color:#62E884;">Contain</span><span style="color:#F6F6F4;">(value 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;">l </span><span style="color:#AB5959;">*</span><span style="color:#393A34;">List</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;">value 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;">    list </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/list</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;">    li </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> list.</span><span style="color:#97E1F1;">NewList</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;">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;">(li.</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;">(li.</span><span style="color:#97E1F1;">Contain</span><span style="color:#F6F6F4;">(</span><span style="color:#BF9EEE;">0</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;">list</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/list</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;">li</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> list</span><span style="color:#999999;">.</span><span style="color:#998418;">NewList</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;">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;">li</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;">li</span><span style="color:#999999;">.</span><span style="color:#998418;">Contain</span><span style="color:#999999;">(</span><span style="color:#2F798A;">0</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="Data" tabindex="-1"><span id="Data">Data</span> <a class="header-anchor" href="#Data" aria-label="Permalink to &quot;&lt;span id=&quot;Data&quot;&gt;Data&lt;/span&gt;&quot;">​</a></h3><p>Return slice of list 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;"> (l </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">List[T]) </span><span style="color:#62E884;">Data</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;">l </span><span style="color:#AB5959;">*</span><span style="color:#393A34;">List</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;">Data</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;">    list </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/list</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;">    li </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> list.</span><span style="color:#97E1F1;">NewList</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;">3</span><span style="color:#F6F6F4;">})</span></span>
<span class="line"><span style="color:#F6F6F4;">    data </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> li.</span><span style="color:#97E1F1;">Data</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;">(data) </span><span style="color:#7B7F8B;">//[]int{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;">list</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/list</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;">li</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> list</span><span style="color:#999999;">.</span><span style="color:#998418;">NewList</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;">3</span><span style="color:#999999;">})</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B07D48;">data</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> li</span><span style="color:#999999;">.</span><span style="color:#998418;">Data</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;">data</span><span style="color:#999999;">)</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">//[]int{1, 2, 3}</span></span>
<span class="line"><span style="color:#999999;">}</span></span></code></pre></div><h3 id="ValueOf" tabindex="-1"><span id="ValueOf">ValueOf</span> <a class="header-anchor" href="#ValueOf" aria-label="Permalink to &quot;&lt;span id=&quot;ValueOf&quot;&gt;ValueOf&lt;/span&gt;&quot;">​</a></h3><p>Return the value pointer at index in list</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;"> (l </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">List[T]) </span><span style="color:#62E884;">ValueOf</span><span style="color:#F6F6F4;">(index </span><span style="color:#97E1F1;font-style:italic;">int</span><span style="color:#F6F6F4;">) (</span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">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;">l </span><span style="color:#AB5959;">*</span><span style="color:#393A34;">List</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;">ValueOf</span><span style="color:#999999;">(</span><span style="color:#393A34;">index </span><span style="color:#AB5959;">int</span><span style="color:#999999;">)</span><span style="color:#393A34;"> </span><span style="color:#999999;">(</span><span style="color:#AB5959;">*</span><span style="color:#393A34;">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;">    list </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/list</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;">    li </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> list.</span><span style="color:#97E1F1;">NewList</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;">3</span><span style="color:#F6F6F4;">})</span></span>
<span class="line"><span style="color:#F6F6F4;">    v, ok </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> li.</span><span style="color:#97E1F1;">ValueOf</span><span style="color:#F6F6F4;">(</span><span style="color:#BF9EEE;">0</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;">(</span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">v) </span><span style="color:#7B7F8B;">//1</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;">list</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/list</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;">li</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> list</span><span style="color:#999999;">.</span><span style="color:#998418;">NewList</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;">3</span><span style="color:#999999;">})</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B07D48;">v</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;"> li</span><span style="color:#999999;">.</span><span style="color:#998418;">ValueOf</span><span style="color:#999999;">(</span><span style="color:#2F798A;">0</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:#AB5959;">*</span><span style="color:#393A34;">v</span><span style="color:#999999;">)</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">//1</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><h3 id="IndexOf" tabindex="-1"><span id="IndexOf">IndexOf</span> <a class="header-anchor" href="#IndexOf" aria-label="Permalink to &quot;&lt;span id=&quot;IndexOf&quot;&gt;IndexOf&lt;/span&gt;&quot;">​</a></h3><p>Returns the index of value in the list. if not found return -1</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;"> (l </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">List[T]) </span><span style="color:#62E884;">IndexOf</span><span style="color:#F6F6F4;">(value T) </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;">l </span><span style="color:#AB5959;">*</span><span style="color:#393A34;">List</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;">IndexOf</span><span style="color:#999999;">(</span><span style="color:#393A34;">value T</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;">    list </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/list</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;">    li </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> list.</span><span style="color:#97E1F1;">NewList</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;">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;">(li.</span><span style="color:#97E1F1;">IndexOf</span><span style="color:#F6F6F4;">(</span><span style="color:#BF9EEE;">1</span><span style="color:#F6F6F4;">)) </span><span style="color:#7B7F8B;">//0</span></span>
<span class="line"><span style="color:#F6F6F4;">    fmt.</span><span style="color:#97E1F1;">Println</span><span style="color:#F6F6F4;">(li.</span><span style="color:#97E1F1;">IndexOf</span><span style="color:#F6F6F4;">(</span><span style="color:#BF9EEE;">0</span><span style="color:#F6F6F4;">)) </span><span style="color:#7B7F8B;">//-1</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;">list</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/list</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;">li</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> list</span><span style="color:#999999;">.</span><span style="color:#998418;">NewList</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;">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;">li</span><span style="color:#999999;">.</span><span style="color:#998418;">IndexOf</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;">//0</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;">li</span><span style="color:#999999;">.</span><span style="color:#998418;">IndexOf</span><span style="color:#999999;">(</span><span style="color:#2F798A;">0</span><span style="color:#999999;">))</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">//-1</span></span>
<span class="line"><span style="color:#999999;">}</span></span></code></pre></div><h3 id="LastIndexOf" tabindex="-1"><span id="LastIndexOf">LastIndexOf</span> <a class="header-anchor" href="#LastIndexOf" aria-label="Permalink to &quot;&lt;span id=&quot;LastIndexOf&quot;&gt;LastIndexOf&lt;/span&gt;&quot;">​</a></h3><p> Returns the index of the last occurrence of the value in this list if not found return -1</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;"> (l </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">List[T]) </span><span style="color:#62E884;">LastIndexOf</span><span style="color:#F6F6F4;">(value T) </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;">l </span><span style="color:#AB5959;">*</span><span style="color:#393A34;">List</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;">LastIndexOf</span><span style="color:#999999;">(</span><span style="color:#393A34;">value T</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;">    list </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/list</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;">    li </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> list.</span><span style="color:#97E1F1;">NewList</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;">3</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">1</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;">(li.</span><span style="color:#97E1F1;">LastIndexOf</span><span style="color:#F6F6F4;">(</span><span style="color:#BF9EEE;">1</span><span style="color:#F6F6F4;">)) </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;">(li.</span><span style="color:#97E1F1;">LastIndexOf</span><span style="color:#F6F6F4;">(</span><span style="color:#BF9EEE;">0</span><span style="color:#F6F6F4;">)) </span><span style="color:#7B7F8B;">//-1</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;">list</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/list</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;">li</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> list</span><span style="color:#999999;">.</span><span style="color:#998418;">NewList</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;">3</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#2F798A;">1</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;">li</span><span style="color:#999999;">.</span><span style="color:#998418;">LastIndexOf</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;">// 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;">li</span><span style="color:#999999;">.</span><span style="color:#998418;">LastIndexOf</span><span style="color:#999999;">(</span><span style="color:#2F798A;">0</span><span style="color:#999999;">))</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">//-1</span></span>
<span class="line"><span style="color:#999999;">}</span></span></code></pre></div><h3 id="IndexOfFunc" tabindex="-1"><span id="IndexOfFunc">IndexOfFunc</span> <a class="header-anchor" href="#IndexOfFunc" aria-label="Permalink to &quot;&lt;span id=&quot;IndexOfFunc&quot;&gt;IndexOfFunc&lt;/span&gt;&quot;">​</a></h3><p> IndexOfFunc returns the first index satisfying f(v). if not found return -1</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;"> (l </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">List[T]) </span><span style="color:#62E884;">IndexOfFunc</span><span style="color:#F6F6F4;">(f </span><span style="color:#F286C4;">func</span><span style="color:#F6F6F4;">(T) </span><span style="color:#97E1F1;font-style:italic;">bool</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;">l </span><span style="color:#AB5959;">*</span><span style="color:#393A34;">List</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;">IndexOfFunc</span><span style="color:#999999;">(</span><span style="color:#393A34;">f </span><span style="color:#1E754F;">func</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 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;">    list </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/list</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;">    li </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> list.</span><span style="color:#97E1F1;">NewList</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;">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;">(li.</span><span style="color:#97E1F1;">IndexOfFunc</span><span style="color:#F6F6F4;">(</span><span style="color:#F286C4;">func</span><span style="color:#F6F6F4;">(a </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 style="color:#F286C4;">return</span><span style="color:#F6F6F4;"> a </span><span style="color:#F286C4;">==</span><span style="color:#F6F6F4;"> </span><span style="color:#BF9EEE;">1</span><span style="color:#F6F6F4;"> })) </span><span style="color:#7B7F8B;">//0</span></span>
<span class="line"><span style="color:#F6F6F4;">    fmt.</span><span style="color:#97E1F1;">Println</span><span style="color:#F6F6F4;">(li.</span><span style="color:#97E1F1;">IndexOfFunc</span><span style="color:#F6F6F4;">(</span><span style="color:#F286C4;">func</span><span style="color:#F6F6F4;">(a </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 style="color:#F286C4;">return</span><span style="color:#F6F6F4;"> a </span><span style="color:#F286C4;">==</span><span style="color:#F6F6F4;"> </span><span style="color:#BF9EEE;">0</span><span style="color:#F6F6F4;"> })) </span><span style="color:#7B7F8B;">//-1</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;">list</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/list</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;">li</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> list</span><span style="color:#999999;">.</span><span style="color:#998418;">NewList</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;">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;">li</span><span style="color:#999999;">.</span><span style="color:#998418;">IndexOfFunc</span><span style="color:#999999;">(</span><span style="color:#1E754F;">func</span><span style="color:#999999;">(</span><span style="color:#393A34;">a </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 style="color:#393A34;"> </span><span style="color:#1E754F;">return</span><span style="color:#393A34;"> a </span><span style="color:#AB5959;">==</span><span style="color:#393A34;"> </span><span style="color:#2F798A;">1</span><span style="color:#393A34;"> </span><span style="color:#999999;">}))</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">//0</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;">li</span><span style="color:#999999;">.</span><span style="color:#998418;">IndexOfFunc</span><span style="color:#999999;">(</span><span style="color:#1E754F;">func</span><span style="color:#999999;">(</span><span style="color:#393A34;">a </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 style="color:#393A34;"> </span><span style="color:#1E754F;">return</span><span style="color:#393A34;"> a </span><span style="color:#AB5959;">==</span><span style="color:#393A34;"> </span><span style="color:#2F798A;">0</span><span style="color:#393A34;"> </span><span style="color:#999999;">}))</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">//-1</span></span>
<span class="line"><span style="color:#999999;">}</span></span></code></pre></div><h3 id="LastIndexOfFunc" tabindex="-1"><span id="LastIndexOfFunc">LastIndexOfFunc</span> <a class="header-anchor" href="#LastIndexOfFunc" aria-label="Permalink to &quot;&lt;span id=&quot;LastIndexOfFunc&quot;&gt;LastIndexOfFunc&lt;/span&gt;&quot;">​</a></h3><p>LastIndexOfFunc returns the index of the last occurrence of the value in this list satisfying f(data[i]). if not found return -1</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;"> (l </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">List[T]) </span><span style="color:#62E884;">LastIndexOfFunc</span><span style="color:#F6F6F4;">(f </span><span style="color:#F286C4;">func</span><span style="color:#F6F6F4;">(T) </span><span style="color:#97E1F1;font-style:italic;">bool</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;">l </span><span style="color:#AB5959;">*</span><span style="color:#393A34;">List</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;">LastIndexOfFunc</span><span style="color:#999999;">(</span><span style="color:#393A34;">f </span><span style="color:#1E754F;">func</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 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;">    list </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/list</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;">    li </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> list.</span><span style="color:#97E1F1;">NewList</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;">3</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">1</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;">(li.</span><span style="color:#97E1F1;">LastIndexOfFunc</span><span style="color:#F6F6F4;">(</span><span style="color:#F286C4;">func</span><span style="color:#F6F6F4;">(a </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 style="color:#F286C4;">return</span><span style="color:#F6F6F4;"> a </span><span style="color:#F286C4;">==</span><span style="color:#F6F6F4;"> </span><span style="color:#BF9EEE;">1</span><span style="color:#F6F6F4;"> })) </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;">(li.</span><span style="color:#97E1F1;">LastIndexOfFunc</span><span style="color:#F6F6F4;">(</span><span style="color:#F286C4;">func</span><span style="color:#F6F6F4;">(a </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 style="color:#F286C4;">return</span><span style="color:#F6F6F4;"> a </span><span style="color:#F286C4;">==</span><span style="color:#F6F6F4;"> </span><span style="color:#BF9EEE;">0</span><span style="color:#F6F6F4;"> })) </span><span style="color:#7B7F8B;">//-1</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;">list</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/list</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;">li</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> list</span><span style="color:#999999;">.</span><span style="color:#998418;">NewList</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;">3</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#2F798A;">1</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;">li</span><span style="color:#999999;">.</span><span style="color:#998418;">LastIndexOfFunc</span><span style="color:#999999;">(</span><span style="color:#1E754F;">func</span><span style="color:#999999;">(</span><span style="color:#393A34;">a </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 style="color:#393A34;"> </span><span style="color:#1E754F;">return</span><span style="color:#393A34;"> a </span><span style="color:#AB5959;">==</span><span style="color:#393A34;"> </span><span style="color:#2F798A;">1</span><span style="color:#393A34;"> </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;">li</span><span style="color:#999999;">.</span><span style="color:#998418;">LastIndexOfFunc</span><span style="color:#999999;">(</span><span style="color:#1E754F;">func</span><span style="color:#999999;">(</span><span style="color:#393A34;">a </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 style="color:#393A34;"> </span><span style="color:#1E754F;">return</span><span style="color:#393A34;"> a </span><span style="color:#AB5959;">==</span><span style="color:#393A34;"> </span><span style="color:#2F798A;">0</span><span style="color:#393A34;"> </span><span style="color:#999999;">}))</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">//-1</span></span>
<span class="line"><span style="color:#999999;">}</span></span></code></pre></div><h3 id="Push" tabindex="-1"><span id="Push">Push</span> <a class="header-anchor" href="#Push" aria-label="Permalink to &quot;&lt;span id=&quot;Push&quot;&gt;Push&lt;/span&gt;&quot;">​</a></h3><p>Append value to the list</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;"> (l </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">List[T]) </span><span style="color:#62E884;">Push</span><span style="color:#F6F6F4;">(value 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;">l </span><span style="color:#AB5959;">*</span><span style="color:#393A34;">List</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;">Push</span><span style="color:#999999;">(</span><span style="color:#393A34;">value 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;">    list </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/list</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;">    li </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> list.</span><span style="color:#97E1F1;">NewList</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;">3</span><span style="color:#F6F6F4;">})</span></span>
<span class="line"><span style="color:#F6F6F4;">    li.</span><span style="color:#97E1F1;">Push</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;">(li.</span><span style="color:#97E1F1;">Data</span><span style="color:#F6F6F4;">()) </span><span style="color:#7B7F8B;">//[]int{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;">list</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/list</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;">li</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> list</span><span style="color:#999999;">.</span><span style="color:#998418;">NewList</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;">3</span><span style="color:#999999;">})</span></span>
<span class="line"><span style="color:#393A34;">    li</span><span style="color:#999999;">.</span><span style="color:#998418;">Push</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;">li</span><span style="color:#999999;">.</span><span style="color:#998418;">Data</span><span style="color:#999999;">())</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">//[]int{1, 2, 3, 4}</span></span>
<span class="line"><span style="color:#999999;">}</span></span></code></pre></div><h3 id="PopFirst" tabindex="-1"><span id="PopFirst">PopFirst</span> <a class="header-anchor" href="#PopFirst" aria-label="Permalink to &quot;&lt;span id=&quot;PopFirst&quot;&gt;PopFirst&lt;/span&gt;&quot;">​</a></h3><p>Delete the first value of list and return it</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;"> (l </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">List[T]) </span><span style="color:#62E884;">PopFirst</span><span style="color:#F6F6F4;">() (</span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">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;">l </span><span style="color:#AB5959;">*</span><span style="color:#393A34;">List</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;">PopFirst</span><span style="color:#999999;">()</span><span style="color:#393A34;"> </span><span style="color:#999999;">(</span><span style="color:#AB5959;">*</span><span style="color:#393A34;">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;">    list </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/list</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;">    li </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> list.</span><span style="color:#97E1F1;">NewList</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;">3</span><span style="color:#F6F6F4;">})</span></span>
<span class="line"><span style="color:#F6F6F4;">    v, ok </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> li.</span><span style="color:#97E1F1;">PopFirst</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;">(</span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">v) </span><span style="color:#7B7F8B;">//1</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;">    fmt.</span><span style="color:#97E1F1;">Println</span><span style="color:#F6F6F4;">(li.</span><span style="color:#97E1F1;">Data</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;">list</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/list</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;">li</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> list</span><span style="color:#999999;">.</span><span style="color:#998418;">NewList</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;">3</span><span style="color:#999999;">})</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B07D48;">v</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;"> li</span><span style="color:#999999;">.</span><span style="color:#998418;">PopFirst</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:#AB5959;">*</span><span style="color:#393A34;">v</span><span style="color:#999999;">)</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">//1</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:#393A34;">    fmt</span><span style="color:#999999;">.</span><span style="color:#998418;">Println</span><span style="color:#999999;">(</span><span style="color:#393A34;">li</span><span style="color:#999999;">.</span><span style="color:#998418;">Data</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="PopFirst-1" tabindex="-1"><span id="PopLast">PopFirst</span> <a class="header-anchor" href="#PopFirst-1" aria-label="Permalink to &quot;&lt;span id=&quot;PopLast&quot;&gt;PopFirst&lt;/span&gt;&quot;">​</a></h3><p>Delete the last value of list and return it</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;"> (l </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">List[T]) </span><span style="color:#62E884;">PopLast</span><span style="color:#F6F6F4;">() (</span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">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;">l </span><span style="color:#AB5959;">*</span><span style="color:#393A34;">List</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;">PopLast</span><span style="color:#999999;">()</span><span style="color:#393A34;"> </span><span style="color:#999999;">(</span><span style="color:#AB5959;">*</span><span style="color:#393A34;">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;">    list </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/list</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;">    li </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> list.</span><span style="color:#97E1F1;">NewList</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;">3</span><span style="color:#F6F6F4;">})</span></span>
<span class="line"><span style="color:#F6F6F4;">    v, ok </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> li.</span><span style="color:#97E1F1;">PopLast</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;">(</span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">v) </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;">    fmt.</span><span style="color:#97E1F1;">Println</span><span style="color:#F6F6F4;">(li.</span><span style="color:#97E1F1;">Data</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;">list</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/list</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;">li</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> list</span><span style="color:#999999;">.</span><span style="color:#998418;">NewList</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;">3</span><span style="color:#999999;">})</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B07D48;">v</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;"> li</span><span style="color:#999999;">.</span><span style="color:#998418;">PopLast</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:#AB5959;">*</span><span style="color:#393A34;">v</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:#393A34;">    fmt</span><span style="color:#999999;">.</span><span style="color:#998418;">Println</span><span style="color:#999999;">(</span><span style="color:#393A34;">li</span><span style="color:#999999;">.</span><span style="color:#998418;">Data</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="DeleteAt" tabindex="-1"><span id="DeleteAt">DeleteAt</span> <a class="header-anchor" href="#DeleteAt" aria-label="Permalink to &quot;&lt;span id=&quot;DeleteAt&quot;&gt;DeleteAt&lt;/span&gt;&quot;">​</a></h3><p>Delete the value of list at index, if index is not between 0 and length of list data, do nothing</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;"> (l </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">List[T]) </span><span style="color:#62E884;">DeleteAt</span><span style="color:#F6F6F4;">(index </span><span style="color:#97E1F1;font-style:italic;">int</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;">l </span><span style="color:#AB5959;">*</span><span style="color:#393A34;">List</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;">DeleteAt</span><span style="color:#999999;">(</span><span style="color:#393A34;">index </span><span style="color:#AB5959;">int</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;">    list </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/list</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;">    li </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> list.</span><span style="color:#97E1F1;">NewList</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;">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;">    li.</span><span style="color:#97E1F1;">DeleteAt</span><span style="color:#F6F6F4;">(</span><span style="color:#F286C4;">-</span><span style="color:#BF9EEE;">1</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;">(li.</span><span style="color:#97E1F1;">Data</span><span style="color:#F6F6F4;">()) </span><span style="color:#7B7F8B;">//1,2,3,4</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F6F6F4;">    li.</span><span style="color:#97E1F1;">DeleteAt</span><span style="color:#F6F6F4;">(</span><span style="color:#BF9EEE;">4</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;">(li.</span><span style="color:#97E1F1;">Data</span><span style="color:#F6F6F4;">()) </span><span style="color:#7B7F8B;">//1,2,3,4</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F6F6F4;">    li.</span><span style="color:#97E1F1;">DeleteAt</span><span style="color:#F6F6F4;">(</span><span style="color:#BF9EEE;">0</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;">(li.</span><span style="color:#97E1F1;">Data</span><span style="color:#F6F6F4;">()) </span><span style="color:#7B7F8B;">//2,3,4</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F6F6F4;">    li.</span><span style="color:#97E1F1;">DeleteAt</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;">    fmt.</span><span style="color:#97E1F1;">Println</span><span style="color:#F6F6F4;">(li.</span><span style="color:#97E1F1;">Data</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;">list</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/list</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;">li</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> list</span><span style="color:#999999;">.</span><span style="color:#998418;">NewList</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;">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;">    li</span><span style="color:#999999;">.</span><span style="color:#998418;">DeleteAt</span><span style="color:#999999;">(</span><span style="color:#AB5959;">-</span><span style="color:#2F798A;">1</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;">li</span><span style="color:#999999;">.</span><span style="color:#998418;">Data</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>
<span class="line"><span style="color:#393A34;">    li</span><span style="color:#999999;">.</span><span style="color:#998418;">DeleteAt</span><span style="color:#999999;">(</span><span style="color:#2F798A;">4</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;">li</span><span style="color:#999999;">.</span><span style="color:#998418;">Data</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>
<span class="line"><span style="color:#393A34;">    li</span><span style="color:#999999;">.</span><span style="color:#998418;">DeleteAt</span><span style="color:#999999;">(</span><span style="color:#2F798A;">0</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;">li</span><span style="color:#999999;">.</span><span style="color:#998418;">Data</span><span style="color:#999999;">())</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">//2,3,4</span></span>
<span class="line"></span>
<span class="line"><span style="color:#393A34;">    li</span><span style="color:#999999;">.</span><span style="color:#998418;">DeleteAt</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;">    fmt</span><span style="color:#999999;">.</span><span style="color:#998418;">Println</span><span style="color:#999999;">(</span><span style="color:#393A34;">li</span><span style="color:#999999;">.</span><span style="color:#998418;">Data</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="InsertAt" tabindex="-1"><span id="InsertAt">InsertAt</span> <a class="header-anchor" href="#InsertAt" aria-label="Permalink to &quot;&lt;span id=&quot;InsertAt&quot;&gt;InsertAt&lt;/span&gt;&quot;">​</a></h3><p>Insert value into list at index, if index is not between 0 and length of list data, do nothing</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;"> (l </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">List[T]) </span><span style="color:#62E884;">InsertAt</span><span style="color:#F6F6F4;">(index </span><span style="color:#97E1F1;font-style:italic;">int</span><span style="color:#F6F6F4;">, value 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;">l </span><span style="color:#AB5959;">*</span><span style="color:#393A34;">List</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;">InsertAt</span><span style="color:#999999;">(</span><span style="color:#393A34;">index </span><span style="color:#AB5959;">int</span><span style="color:#999999;">,</span><span style="color:#393A34;"> value 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;">    list </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/list</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;">    li </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> list.</span><span style="color:#97E1F1;">NewList</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;">3</span><span style="color:#F6F6F4;">})</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F6F6F4;">    li.</span><span style="color:#97E1F1;">InsertAt</span><span style="color:#F6F6F4;">(</span><span style="color:#F286C4;">-</span><span style="color:#BF9EEE;">1</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">0</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;">(li.</span><span style="color:#97E1F1;">Data</span><span style="color:#F6F6F4;">()) </span><span style="color:#7B7F8B;">//1,2,3</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F6F6F4;">    li.</span><span style="color:#97E1F1;">InsertAt</span><span style="color:#F6F6F4;">(</span><span style="color:#BF9EEE;">4</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">0</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;">(li.</span><span style="color:#97E1F1;">Data</span><span style="color:#F6F6F4;">()) </span><span style="color:#7B7F8B;">//1,2,3</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F6F6F4;">    li.</span><span style="color:#97E1F1;">InsertAt</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 style="color:#F6F6F4;">    fmt.</span><span style="color:#97E1F1;">Println</span><span style="color:#F6F6F4;">(li.</span><span style="color:#97E1F1;">Data</span><span style="color:#F6F6F4;">()) </span><span style="color:#7B7F8B;">//1,2,3,4</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F6F6F4;">    </span><span style="color:#7B7F8B;">// li.InsertAt(2, 4)</span></span>
<span class="line"><span style="color:#F6F6F4;">    </span><span style="color:#7B7F8B;">// fmt.Println(li.Data()) //1,2,4,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;">list</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/list</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;">li</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> list</span><span style="color:#999999;">.</span><span style="color:#998418;">NewList</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;">3</span><span style="color:#999999;">})</span></span>
<span class="line"></span>
<span class="line"><span style="color:#393A34;">    li</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAt</span><span style="color:#999999;">(</span><span style="color:#AB5959;">-</span><span style="color:#2F798A;">1</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#2F798A;">0</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;">li</span><span style="color:#999999;">.</span><span style="color:#998418;">Data</span><span style="color:#999999;">())</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">//1,2,3</span></span>
<span class="line"></span>
<span class="line"><span style="color:#393A34;">    li</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAt</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:#2F798A;">0</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;">li</span><span style="color:#999999;">.</span><span style="color:#998418;">Data</span><span style="color:#999999;">())</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">//1,2,3</span></span>
<span class="line"></span>
<span class="line"><span style="color:#393A34;">    li</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAt</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:#2F798A;">4</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;">li</span><span style="color:#999999;">.</span><span style="color:#998418;">Data</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>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#A0ADA0;">// li.InsertAt(2, 4)</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#A0ADA0;">// fmt.Println(li.Data()) //1,2,4,3</span></span>
<span class="line"><span style="color:#999999;">}</span></span></code></pre></div><h3 id="UpdateAt" tabindex="-1"><span id="UpdateAt">UpdateAt</span> <a class="header-anchor" href="#UpdateAt" aria-label="Permalink to &quot;&lt;span id=&quot;UpdateAt&quot;&gt;UpdateAt&lt;/span&gt;&quot;">​</a></h3><p>Update value of list at index, index shoud between 0 and list size - 1</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;"> (l </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">List[T]) </span><span style="color:#62E884;">UpdateAt</span><span style="color:#F6F6F4;">(index </span><span style="color:#97E1F1;font-style:italic;">int</span><span style="color:#F6F6F4;">, value 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;">l </span><span style="color:#AB5959;">*</span><span style="color:#393A34;">List</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;">UpdateAt</span><span style="color:#999999;">(</span><span style="color:#393A34;">index </span><span style="color:#AB5959;">int</span><span style="color:#999999;">,</span><span style="color:#393A34;"> value 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;">    list </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/list</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;">    li </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> list.</span><span style="color:#97E1F1;">NewList</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;">3</span><span style="color:#F6F6F4;">})</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F6F6F4;">    li.</span><span style="color:#97E1F1;">UpdateAt</span><span style="color:#F6F6F4;">(</span><span style="color:#F286C4;">-</span><span style="color:#BF9EEE;">1</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">0</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;">(li.</span><span style="color:#97E1F1;">Data</span><span style="color:#F6F6F4;">()) </span><span style="color:#7B7F8B;">//1,2,3</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F6F6F4;">    li.</span><span style="color:#97E1F1;">UpdateAt</span><span style="color:#F6F6F4;">(</span><span style="color:#BF9EEE;">2</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">4</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;">(li.</span><span style="color:#97E1F1;">Data</span><span style="color:#F6F6F4;">()) </span><span style="color:#7B7F8B;">//1,2,4</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F6F6F4;">    li.</span><span style="color:#97E1F1;">UpdateAt</span><span style="color:#F6F6F4;">(</span><span style="color:#BF9EEE;">3</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;">    fmt.</span><span style="color:#97E1F1;">Println</span><span style="color:#F6F6F4;">(li.</span><span style="color:#97E1F1;">Data</span><span style="color:#F6F6F4;">()) </span><span style="color:#7B7F8B;">//1,2,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;">list</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/list</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;">li</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> list</span><span style="color:#999999;">.</span><span style="color:#998418;">NewList</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;">3</span><span style="color:#999999;">})</span></span>
<span class="line"></span>
<span class="line"><span style="color:#393A34;">    li</span><span style="color:#999999;">.</span><span style="color:#998418;">UpdateAt</span><span style="color:#999999;">(</span><span style="color:#AB5959;">-</span><span style="color:#2F798A;">1</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#2F798A;">0</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;">li</span><span style="color:#999999;">.</span><span style="color:#998418;">Data</span><span style="color:#999999;">())</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">//1,2,3</span></span>
<span class="line"></span>
<span class="line"><span style="color:#393A34;">    li</span><span style="color:#999999;">.</span><span style="color:#998418;">UpdateAt</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;">4</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;">li</span><span style="color:#999999;">.</span><span style="color:#998418;">Data</span><span style="color:#999999;">())</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">//1,2,4</span></span>
<span class="line"></span>
<span class="line"><span style="color:#393A34;">    li</span><span style="color:#999999;">.</span><span style="color:#998418;">UpdateAt</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:#2F798A;">5</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;">li</span><span style="color:#999999;">.</span><span style="color:#998418;">Data</span><span style="color:#999999;">())</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">//1,2,4</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>Compare a list to another list, use reflect.DeepEqual on every element</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;"> (l </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">List[T]) </span><span style="color:#62E884;">Equal</span><span style="color:#F6F6F4;">(other </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">List[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;">l </span><span style="color:#AB5959;">*</span><span style="color:#393A34;">List</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 </span><span style="color:#AB5959;">*</span><span style="color:#393A34;">List</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;">    list </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/list</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;">    li1 </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> list.</span><span style="color:#97E1F1;">NewList</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;">3</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">4</span><span style="color:#F6F6F4;">})</span></span>
<span class="line"><span style="color:#F6F6F4;">    li2 </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> list.</span><span style="color:#97E1F1;">NewList</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;">3</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">4</span><span style="color:#F6F6F4;">})</span></span>
<span class="line"><span style="color:#F6F6F4;">    li3 </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> list.</span><span style="color:#97E1F1;">NewList</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;">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;">(li1.</span><span style="color:#97E1F1;">Equal</span><span style="color:#F6F6F4;">(li2)) </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;">(li1.</span><span style="color:#97E1F1;">Equal</span><span style="color:#F6F6F4;">(li3)) </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;">list</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/list</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;">li1</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> list</span><span style="color:#999999;">.</span><span style="color:#998418;">NewList</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;">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 style="color:#393A34;">    </span><span style="color:#B07D48;">li2</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> list</span><span style="color:#999999;">.</span><span style="color:#998418;">NewList</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;">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 style="color:#393A34;">    </span><span style="color:#B07D48;">li3</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> list</span><span style="color:#999999;">.</span><span style="color:#998418;">NewList</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;">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;">li1</span><span style="color:#999999;">.</span><span style="color:#998418;">Equal</span><span style="color:#999999;">(</span><span style="color:#393A34;">li2</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;">li1</span><span style="color:#999999;">.</span><span style="color:#998418;">Equal</span><span style="color:#999999;">(</span><span style="color:#393A34;">li3</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="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 a list 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;"> (l </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">List[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;">l </span><span style="color:#AB5959;">*</span><span style="color:#393A34;">List</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;">    list </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/list</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;">    li1 </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> list.</span><span style="color:#97E1F1;">NewList</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;">3</span><span style="color:#F6F6F4;">})</span></span>
<span class="line"><span style="color:#F6F6F4;">    li2 </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> list.</span><span style="color:#97E1F1;">NewList</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>
<span class="line"><span style="color:#F6F6F4;">    fmt.</span><span style="color:#97E1F1;">Println</span><span style="color:#F6F6F4;">(li1.</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;">(li2.</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;">list</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/list</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;">li1</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> list</span><span style="color:#999999;">.</span><span style="color:#998418;">NewList</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;">3</span><span style="color:#999999;">})</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B07D48;">li2</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> list</span><span style="color:#999999;">.</span><span style="color:#998418;">NewList</span><span style="color:#999999;">([]</span><span style="color:#AB5959;">int</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;">li1</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;">li2</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="Clear" tabindex="-1"><span id="Clear">Clear</span> <a class="header-anchor" href="#Clear" aria-label="Permalink to &quot;&lt;span id=&quot;Clear&quot;&gt;Clear&lt;/span&gt;&quot;">​</a></h3><p>Clear the data of list</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;"> (l </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">List[T]) </span><span style="color:#62E884;">Clear</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;">l </span><span style="color:#AB5959;">*</span><span style="color:#393A34;">List</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;">Clear</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;">    list </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/list</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;">    li </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> list.</span><span style="color:#97E1F1;">NewList</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;">3</span><span style="color:#F6F6F4;">})</span></span>
<span class="line"><span style="color:#F6F6F4;">    li.</span><span style="color:#97E1F1;">Clear</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;">(li.</span><span style="color:#97E1F1;">Data</span><span style="color:#F6F6F4;">()) </span><span style="color:#7B7F8B;">// empty</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;">list</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/list</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;">li</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> list</span><span style="color:#999999;">.</span><span style="color:#998418;">NewList</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;">3</span><span style="color:#999999;">})</span></span>
<span class="line"><span style="color:#393A34;">    li</span><span style="color:#999999;">.</span><span style="color:#998418;">Clear</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;">li</span><span style="color:#999999;">.</span><span style="color:#998418;">Data</span><span style="color:#999999;">())</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">// empty</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>Return a copy of list</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;"> (l </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">List[T]) </span><span style="color:#62E884;">Clone</span><span style="color:#F6F6F4;">() </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">List[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;">l </span><span style="color:#AB5959;">*</span><span style="color:#393A34;">List</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;"> </span><span style="color:#AB5959;">*</span><span style="color:#393A34;">List</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;">    list </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/list</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;">    li </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> list.</span><span style="color:#97E1F1;">NewList</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;">3</span><span style="color:#F6F6F4;">})</span></span>
<span class="line"><span style="color:#F6F6F4;">    cloneList </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> li.</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;">(cloneList.</span><span style="color:#97E1F1;">Data</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;">list</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/list</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;">li</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> list</span><span style="color:#999999;">.</span><span style="color:#998418;">NewList</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;">3</span><span style="color:#999999;">})</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B07D48;">cloneList</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> li</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;">cloneList</span><span style="color:#999999;">.</span><span style="color:#998418;">Data</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="Merge" tabindex="-1"><span id="Merge">Merge</span> <a class="header-anchor" href="#Merge" aria-label="Permalink to &quot;&lt;span id=&quot;Merge&quot;&gt;Merge&lt;/span&gt;&quot;">​</a></h3><p>Merge two list, return new list, don&#39;t change original list</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;"> (l </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">List[T]) </span><span style="color:#62E884;">Merge</span><span style="color:#F6F6F4;">(other </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">List[T]) </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">List[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;">l </span><span style="color:#AB5959;">*</span><span style="color:#393A34;">List</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;">Merge</span><span style="color:#999999;">(</span><span style="color:#393A34;">other </span><span style="color:#AB5959;">*</span><span style="color:#393A34;">List</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;">*</span><span style="color:#393A34;">List</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;">    list </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/list</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;">    li1 </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> list.</span><span style="color:#97E1F1;">NewList</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;">3</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">4</span><span style="color:#F6F6F4;">})</span></span>
<span class="line"><span style="color:#F6F6F4;">    li2 </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> list.</span><span style="color:#97E1F1;">NewList</span><span style="color:#F6F6F4;">([]</span><span style="color:#97E1F1;font-style:italic;">int</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 style="color:#BF9EEE;">6</span><span style="color:#F6F6F4;">})</span></span>
<span class="line"><span style="color:#F6F6F4;">    li3 </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> li1.</span><span style="color:#97E1F1;">Merge</span><span style="color:#F6F6F4;">(li2)</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;">(li3.</span><span style="color:#97E1F1;">Data</span><span style="color:#F6F6F4;">()) </span><span style="color:#7B7F8B;">//1, 2, 3, 4, 4, 5, 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;">list</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/list</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;">li1</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> list</span><span style="color:#999999;">.</span><span style="color:#998418;">NewList</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;">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 style="color:#393A34;">    </span><span style="color:#B07D48;">li2</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> list</span><span style="color:#999999;">.</span><span style="color:#998418;">NewList</span><span style="color:#999999;">([]</span><span style="color:#AB5959;">int</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:#2F798A;">5</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#2F798A;">6</span><span style="color:#999999;">})</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B07D48;">li3</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> li1</span><span style="color:#999999;">.</span><span style="color:#998418;">Merge</span><span style="color:#999999;">(</span><span style="color:#393A34;">li2</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;">li3</span><span style="color:#999999;">.</span><span style="color:#998418;">Data</span><span style="color:#999999;">())</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">//1, 2, 3, 4, 4, 5, 6</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>Return number of list data items</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;"> (l </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">List[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;">l </span><span style="color:#AB5959;">*</span><span style="color:#393A34;">List</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;">    list </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/list</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;">    li </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> list.</span><span style="color:#97E1F1;">NewList</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;">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;">(li.</span><span style="color:#97E1F1;">Size</span><span style="color:#F6F6F4;">()) </span><span style="color:#7B7F8B;">//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;">list</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/list</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;">li</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> list</span><span style="color:#999999;">.</span><span style="color:#998418;">NewList</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;">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;">li</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;">//4</span></span>
<span class="line"><span style="color:#999999;">}</span></span></code></pre></div><h3 id="Cap" tabindex="-1"><span id="Cap">Cap</span> <a class="header-anchor" href="#Cap" aria-label="Permalink to &quot;&lt;span id=&quot;Cap&quot;&gt;Cap&lt;/span&gt;&quot;">​</a></h3><p>Cap return cap of the inner 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;"> (l </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">List[T]) </span><span style="color:#62E884;">Cap</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;">l </span><span style="color:#AB5959;">*</span><span style="color:#393A34;">List</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;">Cap</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;">    list </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/list</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;">    data </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> </span><span style="color:#97E1F1;">make</span><span style="color:#F6F6F4;">([]</span><span style="color:#97E1F1;font-style:italic;">int</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">0</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">100</span><span style="color:#F6F6F4;">)</span></span>
<span class="line"><span style="color:#F6F6F4;">    </span></span>
<span class="line"><span style="color:#F6F6F4;">    li </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> list.</span><span style="color:#97E1F1;">NewList</span><span style="color:#F6F6F4;">(data)</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;">(li.</span><span style="color:#97E1F1;">Cap</span><span style="color:#F6F6F4;">()) </span><span style="color:#7B7F8B;">// 100</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;">list</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/list</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;">data</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> </span><span style="color:#998418;">make</span><span style="color:#999999;">([]</span><span style="color:#AB5959;">int</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#2F798A;">0</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#2F798A;">100</span><span style="color:#999999;">)</span></span>
<span class="line"><span style="color:#393A34;">    </span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B07D48;">li</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> list</span><span style="color:#999999;">.</span><span style="color:#998418;">NewList</span><span style="color:#999999;">(</span><span style="color:#393A34;">data</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;">li</span><span style="color:#999999;">.</span><span style="color:#998418;">Cap</span><span style="color:#999999;">())</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">// 100</span></span>
<span class="line"><span style="color:#999999;">}</span></span></code></pre></div><h3 id="Swap" tabindex="-1"><span id="Swap">Swap</span> <a class="header-anchor" href="#Swap" aria-label="Permalink to &quot;&lt;span id=&quot;Swap&quot;&gt;Swap&lt;/span&gt;&quot;">​</a></h3><p>Swap the value at two index in list</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;"> (l </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">List[T]) </span><span style="color:#62E884;">Swap</span><span style="color:#F6F6F4;">(i, j </span><span style="color:#97E1F1;font-style:italic;">int</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;">l </span><span style="color:#AB5959;">*</span><span style="color:#393A34;">List</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;">Swap</span><span style="color:#999999;">(</span><span style="color:#393A34;">i</span><span style="color:#999999;">,</span><span style="color:#393A34;"> j </span><span style="color:#AB5959;">int</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;">    list </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/list</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;">    li </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> list.</span><span style="color:#97E1F1;">NewList</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;">3</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">4</span><span style="color:#F6F6F4;">})</span></span>
<span class="line"><span style="color:#F6F6F4;">    li.</span><span style="color:#97E1F1;">Swap</span><span style="color:#F6F6F4;">(</span><span style="color:#BF9EEE;">0</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;">(li.</span><span style="color:#97E1F1;">Data</span><span style="color:#F6F6F4;">()) </span><span style="color:#7B7F8B;">//4, 2, 3, 1</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;">list</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/list</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;">li</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> list</span><span style="color:#999999;">.</span><span style="color:#998418;">NewList</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;">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 style="color:#393A34;">    li</span><span style="color:#999999;">.</span><span style="color:#998418;">Swap</span><span style="color:#999999;">(</span><span style="color:#2F798A;">0</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;">li</span><span style="color:#999999;">.</span><span style="color:#998418;">Data</span><span style="color:#999999;">())</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">//4, 2, 3, 1</span></span>
<span class="line"><span style="color:#999999;">}</span></span></code></pre></div><h3 id="Reverse" tabindex="-1"><span id="Reverse">Reverse</span> <a class="header-anchor" href="#Reverse" aria-label="Permalink to &quot;&lt;span id=&quot;Reverse&quot;&gt;Reverse&lt;/span&gt;&quot;">​</a></h3><p>Reverse the data item order of list</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;"> (l </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">List[T]) </span><span style="color:#62E884;">Reverse</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;">l </span><span style="color:#AB5959;">*</span><span style="color:#393A34;">List</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;">Reverse</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;">    list </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/list</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;">    li </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> list.</span><span style="color:#97E1F1;">NewList</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;">3</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">4</span><span style="color:#F6F6F4;">})</span></span>
<span class="line"><span style="color:#F6F6F4;">    li.</span><span style="color:#97E1F1;">Reverse</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;">(li.</span><span style="color:#97E1F1;">Data</span><span style="color:#F6F6F4;">()) </span><span style="color:#7B7F8B;">//4, 3, 2, 1</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;">list</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/list</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;">li</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> list</span><span style="color:#999999;">.</span><span style="color:#998418;">NewList</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;">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 style="color:#393A34;">    li</span><span style="color:#999999;">.</span><span style="color:#998418;">Reverse</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;">li</span><span style="color:#999999;">.</span><span style="color:#998418;">Data</span><span style="color:#999999;">())</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">//4, 3, 2, 1</span></span>
<span class="line"><span style="color:#999999;">}</span></span></code></pre></div><h3 id="Unique" tabindex="-1"><span id="Unique">Unique</span> <a class="header-anchor" href="#Unique" aria-label="Permalink to &quot;&lt;span id=&quot;Unique&quot;&gt;Unique&lt;/span&gt;&quot;">​</a></h3><p>Remove duplicate items in list</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;"> (l </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">List[T]) </span><span style="color:#62E884;">Unique</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;">l </span><span style="color:#AB5959;">*</span><span style="color:#393A34;">List</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;">Unique</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;">    list </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/list</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;">    li </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> list.</span><span style="color:#97E1F1;">NewList</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 style="color:#BF9EEE;">4</span><span style="color:#F6F6F4;">})</span></span>
<span class="line"><span style="color:#F6F6F4;">    li.</span><span style="color:#97E1F1;">Unique</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;">(li.</span><span style="color:#97E1F1;">Data</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;">list</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/list</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;">li</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> list</span><span style="color:#999999;">.</span><span style="color:#998418;">NewList</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 style="color:#393A34;"> </span><span style="color:#2F798A;">4</span><span style="color:#999999;">})</span></span>
<span class="line"><span style="color:#393A34;">    li</span><span style="color:#999999;">.</span><span style="color:#998418;">Unique</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;">li</span><span style="color:#999999;">.</span><span style="color:#998418;">Data</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="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>Creates a new list contain all elements in list l and other, remove duplicate element</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;"> (l </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">List[T]) </span><span style="color:#62E884;">Union</span><span style="color:#F6F6F4;">(other </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">List[T]) </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">List[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;">l </span><span style="color:#AB5959;">*</span><span style="color:#393A34;">List</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 </span><span style="color:#AB5959;">*</span><span style="color:#393A34;">List</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;">*</span><span style="color:#393A34;">List</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;">    list </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/list</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;">    li1 </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> list.</span><span style="color:#97E1F1;">NewList</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;">3</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">4</span><span style="color:#F6F6F4;">})</span></span>
<span class="line"><span style="color:#F6F6F4;">    li2 </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> list.</span><span style="color:#97E1F1;">NewList</span><span style="color:#F6F6F4;">([]</span><span style="color:#97E1F1;font-style:italic;">int</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 style="color:#BF9EEE;">6</span><span style="color:#F6F6F4;">})</span></span>
<span class="line"><span style="color:#F6F6F4;">    li3 </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> li1.</span><span style="color:#97E1F1;">Union</span><span style="color:#F6F6F4;">(li2)</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;">(li3.</span><span style="color:#97E1F1;">Data</span><span style="color:#F6F6F4;">()) </span><span style="color:#7B7F8B;">//1,2,3,4,5,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;">list</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/list</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;">li1</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> list</span><span style="color:#999999;">.</span><span style="color:#998418;">NewList</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;">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 style="color:#393A34;">    </span><span style="color:#B07D48;">li2</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> list</span><span style="color:#999999;">.</span><span style="color:#998418;">NewList</span><span style="color:#999999;">([]</span><span style="color:#AB5959;">int</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:#2F798A;">5</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#2F798A;">6</span><span style="color:#999999;">})</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B07D48;">li3</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> li1</span><span style="color:#999999;">.</span><span style="color:#998418;">Union</span><span style="color:#999999;">(</span><span style="color:#393A34;">li2</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;">li3</span><span style="color:#999999;">.</span><span style="color:#998418;">Data</span><span style="color:#999999;">())</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">//1,2,3,4,5,6</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>Creates a new list whose element both be contained in list l 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;"> (l </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">List[T]) </span><span style="color:#62E884;">Intersection</span><span style="color:#F6F6F4;">(other </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">List[T]) </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">List[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;">l </span><span style="color:#AB5959;">*</span><span style="color:#393A34;">List</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 </span><span style="color:#AB5959;">*</span><span style="color:#393A34;">List</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;">*</span><span style="color:#393A34;">List</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;">    list </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/list</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;">    li1 </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> list.</span><span style="color:#97E1F1;">NewList</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;">3</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">4</span><span style="color:#F6F6F4;">})</span></span>
<span class="line"><span style="color:#F6F6F4;">    li2 </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> list.</span><span style="color:#97E1F1;">NewList</span><span style="color:#F6F6F4;">([]</span><span style="color:#97E1F1;font-style:italic;">int</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 style="color:#BF9EEE;">6</span><span style="color:#F6F6F4;">})</span></span>
<span class="line"><span style="color:#F6F6F4;">    li3 </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> li1.</span><span style="color:#97E1F1;">Intersection</span><span style="color:#F6F6F4;">(li2)</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;">(li3.</span><span style="color:#97E1F1;">Data</span><span style="color:#F6F6F4;">()) </span><span style="color:#7B7F8B;">//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;">list</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/list</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;">li1</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> list</span><span style="color:#999999;">.</span><span style="color:#998418;">NewList</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;">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 style="color:#393A34;">    </span><span style="color:#B07D48;">li2</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> list</span><span style="color:#999999;">.</span><span style="color:#998418;">NewList</span><span style="color:#999999;">([]</span><span style="color:#AB5959;">int</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:#2F798A;">5</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#2F798A;">6</span><span style="color:#999999;">})</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B07D48;">li3</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> li1</span><span style="color:#999999;">.</span><span style="color:#998418;">Intersection</span><span style="color:#999999;">(</span><span style="color:#393A34;">li2</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;">li3</span><span style="color:#999999;">.</span><span style="color:#998418;">Data</span><span style="color:#999999;">())</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">//4</span></span>
<span class="line"><span style="color:#999999;">}</span></span></code></pre></div><h3 id="Difference" tabindex="-1"><span id="Difference">Difference</span> <a class="header-anchor" href="#Difference" aria-label="Permalink to &quot;&lt;span id=&quot;Difference&quot;&gt;Difference&lt;/span&gt;&quot;">​</a></h3><p>Return a list whose element in the original list, not in the given list.</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;"> (l </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">List[T]) </span><span style="color:#62E884;">Difference</span><span style="color:#F6F6F4;">(other </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">List[T]) </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">List[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;">l </span><span style="color:#AB5959;">*</span><span style="color:#393A34;">List</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;">Difference</span><span style="color:#999999;">(</span><span style="color:#393A34;">other </span><span style="color:#AB5959;">*</span><span style="color:#393A34;">List</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;">*</span><span style="color:#393A34;">List</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;">    list </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/list</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;">    list1 </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> </span><span style="color:#97E1F1;">NewList</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;">3</span><span style="color:#F6F6F4;">})</span></span>
<span class="line"><span style="color:#F6F6F4;">    list2 </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> </span><span style="color:#97E1F1;">NewList</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;">4</span><span style="color:#F6F6F4;">})</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F6F6F4;">    list3 </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> list1.</span><span style="color:#97E1F1;">Intersection</span><span style="color:#F6F6F4;">(list2)</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;">(list3.</span><span style="color:#97E1F1;">Data</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;">list</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/list</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;">list1</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> </span><span style="color:#998418;">NewList</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;">3</span><span style="color:#999999;">})</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B07D48;">list2</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> </span><span style="color:#998418;">NewList</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;">4</span><span style="color:#999999;">})</span></span>
<span class="line"></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B07D48;">list3</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> list1</span><span style="color:#999999;">.</span><span style="color:#998418;">Intersection</span><span style="color:#999999;">(</span><span style="color:#393A34;">list2</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;">list3</span><span style="color:#999999;">.</span><span style="color:#998418;">Data</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="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>Oppoiste operation of intersection function.</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;"> (l </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">List[T]) </span><span style="color:#62E884;">SymmetricDifference</span><span style="color:#F6F6F4;">(other </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">List[T]) </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">List[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;">l </span><span style="color:#AB5959;">*</span><span style="color:#393A34;">List</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 </span><span style="color:#AB5959;">*</span><span style="color:#393A34;">List</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;">*</span><span style="color:#393A34;">List</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;">    list </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/list</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;">    list1 </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> </span><span style="color:#97E1F1;">NewList</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;">3</span><span style="color:#F6F6F4;">})</span></span>
<span class="line"><span style="color:#F6F6F4;">    list2 </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> </span><span style="color:#97E1F1;">NewList</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;">4</span><span style="color:#F6F6F4;">})</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F6F6F4;">    list3 </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> list1.</span><span style="color:#97E1F1;">Intersection</span><span style="color:#F6F6F4;">(list2)</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;">(list3.</span><span style="color:#97E1F1;">Data</span><span style="color:#F6F6F4;">()) </span><span style="color:#7B7F8B;">//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;">list</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/list</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;">list1</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> </span><span style="color:#998418;">NewList</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;">3</span><span style="color:#999999;">})</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B07D48;">list2</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> </span><span style="color:#998418;">NewList</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;">4</span><span style="color:#999999;">})</span></span>
<span class="line"></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B07D48;">list3</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> list1</span><span style="color:#999999;">.</span><span style="color:#998418;">Intersection</span><span style="color:#999999;">(</span><span style="color:#393A34;">list2</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;">list3</span><span style="color:#999999;">.</span><span style="color:#998418;">Data</span><span style="color:#999999;">())</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">//3, 4</span></span>
<span class="line"><span style="color:#999999;">}</span></span></code></pre></div><h3 id="RetainAll" tabindex="-1"><span id="RetainAll">RetainAll</span> <a class="header-anchor" href="#RetainAll" aria-label="Permalink to &quot;&lt;span id=&quot;RetainAll&quot;&gt;RetainAll&lt;/span&gt;&quot;">​</a></h3><p>Retains only the elements in this list that are contained in the given list.</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;"> (l </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">List[T]) </span><span style="color:#62E884;">RetainAll</span><span style="color:#F6F6F4;">(list </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">List[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;">l </span><span style="color:#AB5959;">*</span><span style="color:#393A34;">List</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;">RetainAll</span><span style="color:#999999;">(</span><span style="color:#393A34;">list </span><span style="color:#AB5959;">*</span><span style="color:#393A34;">List</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;">    list </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/list</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;">    list </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> </span><span style="color:#97E1F1;">NewList</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;">3</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">4</span><span style="color:#F6F6F4;">})</span></span>
<span class="line"><span style="color:#F6F6F4;">    list1 </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> </span><span style="color:#97E1F1;">NewList</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;">3</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">4</span><span style="color:#F6F6F4;">})</span></span>
<span class="line"><span style="color:#F6F6F4;">    list2 </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> </span><span style="color:#97E1F1;">NewList</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;">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;">    retain </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> </span><span style="color:#97E1F1;">NewList</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>
<span class="line"><span style="color:#F6F6F4;">    retain1 </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> </span><span style="color:#97E1F1;">NewList</span><span style="color:#F6F6F4;">([]</span><span style="color:#97E1F1;font-style:italic;">int</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;">    retain2 </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> </span><span style="color:#97E1F1;">NewList</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;">5</span><span style="color:#F6F6F4;">})</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F6F6F4;">    list.</span><span style="color:#97E1F1;">RetainAll</span><span style="color:#F6F6F4;">(retain)</span></span>
<span class="line"><span style="color:#F6F6F4;">    list1.</span><span style="color:#97E1F1;">RetainAll</span><span style="color:#F6F6F4;">(retain1)</span></span>
<span class="line"><span style="color:#F6F6F4;">    list2.</span><span style="color:#97E1F1;">RetainAll</span><span style="color:#F6F6F4;">(retain2)</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;">(list.</span><span style="color:#97E1F1;">Data</span><span style="color:#F6F6F4;">()) </span><span style="color:#7B7F8B;">//1, 2</span></span>
<span class="line"><span style="color:#F6F6F4;">    fmt.</span><span style="color:#97E1F1;">Println</span><span style="color:#F6F6F4;">(list1.</span><span style="color:#97E1F1;">Data</span><span style="color:#F6F6F4;">()) </span><span style="color:#7B7F8B;">//2, 3</span></span>
<span class="line"><span style="color:#F6F6F4;">    fmt.</span><span style="color:#97E1F1;">Println</span><span style="color:#F6F6F4;">(list2.</span><span style="color:#97E1F1;">Data</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;">list</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/list</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;">list</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> </span><span style="color:#998418;">NewList</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;">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 style="color:#393A34;">    </span><span style="color:#B07D48;">list1</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> </span><span style="color:#998418;">NewList</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;">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 style="color:#393A34;">    </span><span style="color:#B07D48;">list2</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> </span><span style="color:#998418;">NewList</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;">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;">    </span><span style="color:#B07D48;">retain</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> </span><span style="color:#998418;">NewList</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>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B07D48;">retain1</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> </span><span style="color:#998418;">NewList</span><span style="color:#999999;">([]</span><span style="color:#AB5959;">int</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 style="color:#393A34;">    </span><span style="color:#B07D48;">retain2</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> </span><span style="color:#998418;">NewList</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;">5</span><span style="color:#999999;">})</span></span>
<span class="line"></span>
<span class="line"><span style="color:#393A34;">    list</span><span style="color:#999999;">.</span><span style="color:#998418;">RetainAll</span><span style="color:#999999;">(</span><span style="color:#393A34;">retain</span><span style="color:#999999;">)</span></span>
<span class="line"><span style="color:#393A34;">    list1</span><span style="color:#999999;">.</span><span style="color:#998418;">RetainAll</span><span style="color:#999999;">(</span><span style="color:#393A34;">retain1</span><span style="color:#999999;">)</span></span>
<span class="line"><span style="color:#393A34;">    list2</span><span style="color:#999999;">.</span><span style="color:#998418;">RetainAll</span><span style="color:#999999;">(</span><span style="color:#393A34;">retain2</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;">list</span><span style="color:#999999;">.</span><span style="color:#998418;">Data</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:#393A34;">    fmt</span><span style="color:#999999;">.</span><span style="color:#998418;">Println</span><span style="color:#999999;">(</span><span style="color:#393A34;">list1</span><span style="color:#999999;">.</span><span style="color:#998418;">Data</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:#393A34;">    fmt</span><span style="color:#999999;">.</span><span style="color:#998418;">Println</span><span style="color:#999999;">(</span><span style="color:#393A34;">list2</span><span style="color:#999999;">.</span><span style="color:#998418;">Data</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="DeleteAll" tabindex="-1"><span id="DeleteAll">DeleteAll</span> <a class="header-anchor" href="#DeleteAll" aria-label="Permalink to &quot;&lt;span id=&quot;DeleteAll&quot;&gt;DeleteAll&lt;/span&gt;&quot;">​</a></h3><p>Removes from this list all of its elements that are contained in the given list.</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;"> (l </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">List[T]) </span><span style="color:#62E884;">DeleteAll</span><span style="color:#F6F6F4;">(list </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">List[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;">l </span><span style="color:#AB5959;">*</span><span style="color:#393A34;">List</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;">DeleteAll</span><span style="color:#999999;">(</span><span style="color:#393A34;">list </span><span style="color:#AB5959;">*</span><span style="color:#393A34;">List</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;">    list </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/list</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;">    list </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> </span><span style="color:#97E1F1;">NewList</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;">3</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">4</span><span style="color:#F6F6F4;">})</span></span>
<span class="line"><span style="color:#F6F6F4;">    list1 </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> </span><span style="color:#97E1F1;">NewList</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;">3</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">4</span><span style="color:#F6F6F4;">})</span></span>
<span class="line"><span style="color:#F6F6F4;">    list2 </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> </span><span style="color:#97E1F1;">NewList</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;">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;">    del </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> </span><span style="color:#97E1F1;">NewList</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>
<span class="line"><span style="color:#F6F6F4;">    del1 </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> </span><span style="color:#97E1F1;">NewList</span><span style="color:#F6F6F4;">([]</span><span style="color:#97E1F1;font-style:italic;">int</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;">    del2 </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> </span><span style="color:#97E1F1;">NewList</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;">5</span><span style="color:#F6F6F4;">})</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F6F6F4;">    list.</span><span style="color:#97E1F1;">DeleteAll</span><span style="color:#F6F6F4;">(del)</span></span>
<span class="line"><span style="color:#F6F6F4;">    list1.</span><span style="color:#97E1F1;">DeleteAll</span><span style="color:#F6F6F4;">(del1)</span></span>
<span class="line"><span style="color:#F6F6F4;">    list2.</span><span style="color:#97E1F1;">DeleteAll</span><span style="color:#F6F6F4;">(del2)</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;">(list.</span><span style="color:#97E1F1;">Data</span><span style="color:#F6F6F4;">()) </span><span style="color:#7B7F8B;">//2,3,4</span></span>
<span class="line"><span style="color:#F6F6F4;">    fmt.</span><span style="color:#97E1F1;">Println</span><span style="color:#F6F6F4;">(list1.</span><span style="color:#97E1F1;">Data</span><span style="color:#F6F6F4;">()) </span><span style="color:#7B7F8B;">//1,4</span></span>
<span class="line"><span style="color:#F6F6F4;">    fmt.</span><span style="color:#97E1F1;">Println</span><span style="color:#F6F6F4;">(list2.</span><span style="color:#97E1F1;">Data</span><span style="color:#F6F6F4;">()) </span><span style="color:#7B7F8B;">//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;">list</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/list</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;">list</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> </span><span style="color:#998418;">NewList</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;">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 style="color:#393A34;">    </span><span style="color:#B07D48;">list1</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> </span><span style="color:#998418;">NewList</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;">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 style="color:#393A34;">    </span><span style="color:#B07D48;">list2</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> </span><span style="color:#998418;">NewList</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;">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;">    </span><span style="color:#B07D48;">del</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> </span><span style="color:#998418;">NewList</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>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B07D48;">del1</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> </span><span style="color:#998418;">NewList</span><span style="color:#999999;">([]</span><span style="color:#AB5959;">int</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 style="color:#393A34;">    </span><span style="color:#B07D48;">del2</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> </span><span style="color:#998418;">NewList</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;">5</span><span style="color:#999999;">})</span></span>
<span class="line"></span>
<span class="line"><span style="color:#393A34;">    list</span><span style="color:#999999;">.</span><span style="color:#998418;">DeleteAll</span><span style="color:#999999;">(</span><span style="color:#393A34;">del</span><span style="color:#999999;">)</span></span>
<span class="line"><span style="color:#393A34;">    list1</span><span style="color:#999999;">.</span><span style="color:#998418;">DeleteAll</span><span style="color:#999999;">(</span><span style="color:#393A34;">del1</span><span style="color:#999999;">)</span></span>
<span class="line"><span style="color:#393A34;">    list2</span><span style="color:#999999;">.</span><span style="color:#998418;">DeleteAll</span><span style="color:#999999;">(</span><span style="color:#393A34;">del2</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;">list</span><span style="color:#999999;">.</span><span style="color:#998418;">Data</span><span style="color:#999999;">())</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">//2,3,4</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;">list1</span><span style="color:#999999;">.</span><span style="color:#998418;">Data</span><span style="color:#999999;">())</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">//1,4</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;">list2</span><span style="color:#999999;">.</span><span style="color:#998418;">Data</span><span style="color:#999999;">())</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">//3,4</span></span>
<span class="line"><span style="color:#999999;">}</span></span></code></pre></div><h3 id="ForEach" tabindex="-1"><span id="ForEach">ForEach</span> <a class="header-anchor" href="#ForEach" aria-label="Permalink to &quot;&lt;span id=&quot;ForEach&quot;&gt;ForEach&lt;/span&gt;&quot;">​</a></h3><p>Performs the given action for each element of the list.</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;"> (l </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">List[T]) </span><span style="color:#62E884;">ForEach</span><span style="color:#F6F6F4;">(consumer </span><span style="color:#F286C4;">func</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;">l </span><span style="color:#AB5959;">*</span><span style="color:#393A34;">List</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;">ForEach</span><span style="color:#999999;">(</span><span style="color:#393A34;">consumer </span><span style="color:#1E754F;">func</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;">    list </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/list</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;">    list </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> </span><span style="color:#97E1F1;">NewList</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;">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;">    result </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> </span><span style="color:#97E1F1;">make</span><span style="color:#F6F6F4;">([]</span><span style="color:#97E1F1;font-style:italic;">int</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">0</span><span style="color:#F6F6F4;">)</span></span>
<span class="line"><span style="color:#F6F6F4;">    list.</span><span style="color:#97E1F1;">ForEach</span><span style="color:#F6F6F4;">(</span><span style="color:#F286C4;">func</span><span style="color:#F6F6F4;">(i </span><span style="color:#97E1F1;font-style:italic;">int</span><span style="color:#F6F6F4;">) {</span></span>
<span class="line"><span style="color:#F6F6F4;">        result </span><span style="color:#F286C4;">=</span><span style="color:#F6F6F4;"> </span><span style="color:#97E1F1;">append</span><span style="color:#F6F6F4;">(result, i)</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;">(result.</span><span style="color:#97E1F1;">Data</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;">list</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/list</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;">list</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> </span><span style="color:#998418;">NewList</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;">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;">    </span><span style="color:#B07D48;">result</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> </span><span style="color:#998418;">make</span><span style="color:#999999;">([]</span><span style="color:#AB5959;">int</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#2F798A;">0</span><span style="color:#999999;">)</span></span>
<span class="line"><span style="color:#393A34;">    list</span><span style="color:#999999;">.</span><span style="color:#998418;">ForEach</span><span style="color:#999999;">(</span><span style="color:#1E754F;">func</span><span style="color:#999999;">(</span><span style="color:#393A34;">i </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;">result</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;">result</span><span style="color:#999999;">,</span><span style="color:#393A34;"> i</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;">result</span><span style="color:#999999;">.</span><span style="color:#998418;">Data</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="Iterator" tabindex="-1"><span id="Iterator">Iterator</span> <a class="header-anchor" href="#Iterator" aria-label="Permalink to &quot;&lt;span id=&quot;Iterator&quot;&gt;Iterator&lt;/span&gt;&quot;">​</a></h3><p>Returns an iterator over the elements in this list in proper sequence.</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;"> (l </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">List[T]) </span><span style="color:#62E884;">Iterator</span><span style="color:#F6F6F4;">() iterator.Iterator[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;">l </span><span style="color:#AB5959;">*</span><span style="color:#393A34;">List</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;">Iterator</span><span style="color:#999999;">()</span><span style="color:#393A34;"> iterator</span><span style="color:#999999;">.</span><span style="color:#393A34;">Iterator</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;">    list </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/list</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;">    list </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> </span><span style="color:#97E1F1;">NewList</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;">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;">    iterator </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> list.</span><span style="color:#97E1F1;">Iterator</span><span style="color:#F6F6F4;">()</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F6F6F4;">    result </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> </span><span style="color:#97E1F1;">make</span><span style="color:#F6F6F4;">([]</span><span style="color:#97E1F1;font-style:italic;">int</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">0</span><span style="color:#F6F6F4;">)</span></span>
<span class="line"><span style="color:#F6F6F4;">    </span><span style="color:#F286C4;">for</span><span style="color:#F6F6F4;"> iterator.</span><span style="color:#97E1F1;">HasNext</span><span style="color:#F6F6F4;">() {</span></span>
<span class="line"><span style="color:#F6F6F4;">        item, _ </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> iterator.</span><span style="color:#97E1F1;">Next</span><span style="color:#F6F6F4;">()</span></span>
<span class="line"><span style="color:#F6F6F4;">        result </span><span style="color:#F286C4;">=</span><span style="color:#F6F6F4;"> </span><span style="color:#97E1F1;">append</span><span style="color:#F6F6F4;">(result, 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;">(result.</span><span style="color:#97E1F1;">Data</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;">list</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/list</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;">list</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> </span><span style="color:#998418;">NewList</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;">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;">    </span><span style="color:#B07D48;">iterator</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> list</span><span style="color:#999999;">.</span><span style="color:#998418;">Iterator</span><span style="color:#999999;">()</span></span>
<span class="line"></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B07D48;">result</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> </span><span style="color:#998418;">make</span><span style="color:#999999;">([]</span><span style="color:#AB5959;">int</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#2F798A;">0</span><span style="color:#999999;">)</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#1E754F;">for</span><span style="color:#393A34;"> iterator</span><span style="color:#999999;">.</span><span style="color:#998418;">HasNext</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;">item</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#B07D48;">_</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> iterator</span><span style="color:#999999;">.</span><span style="color:#998418;">Next</span><span style="color:#999999;">()</span></span>
<span class="line"><span style="color:#393A34;">        </span><span style="color:#B07D48;">result</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;">result</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;">result</span><span style="color:#999999;">.</span><span style="color:#998418;">Data</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="ListToMap" tabindex="-1"><span id="ListToMap">ListToMap</span> <a class="header-anchor" href="#ListToMap" aria-label="Permalink to &quot;&lt;span id=&quot;ListToMap&quot;&gt;ListToMap&lt;/span&gt;&quot;">​</a></h3><p>Converts a list to a map based on iteratee function.</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;"> ListToMap[T any, K comparable, V any](list </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">List[T], iteratee </span><span style="color:#F286C4;">func</span><span style="color:#F6F6F4;">(T) (K, V)) </span><span style="color:#F286C4;">map</span><span style="color:#F6F6F4;">[K]V</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;"> ListToMap</span><span style="color:#999999;">[</span><span style="color:#393A34;">T any</span><span style="color:#999999;">,</span><span style="color:#393A34;"> K comparable</span><span style="color:#999999;">,</span><span style="color:#393A34;"> V any</span><span style="color:#999999;">](</span><span style="color:#393A34;">list </span><span style="color:#AB5959;">*</span><span style="color:#393A34;">List</span><span style="color:#999999;">[</span><span style="color:#393A34;">T</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;">T</span><span style="color:#999999;">)</span><span style="color:#393A34;"> </span><span style="color:#999999;">(</span><span style="color:#393A34;">K</span><span style="color:#999999;">,</span><span style="color:#393A34;"> V</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;">K</span><span style="color:#999999;">]</span><span style="color:#393A34;">V</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;">    list </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/list</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;">    list </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> </span><span style="color:#97E1F1;">NewList</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;">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;">    result </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> </span><span style="color:#97E1F1;">ListToMap</span><span style="color:#F6F6F4;">(list, </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;">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;"> n, n </span><span style="color:#F286C4;">&gt;</span><span style="color:#F6F6F4;"> </span><span style="color:#BF9EEE;">1</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;">(result) </span><span style="color:#7B7F8B;">//map[int]bool{1: false, 2: true, 3: true, 4: 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;">list</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/list</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;">list</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> </span><span style="color:#998418;">NewList</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;">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;">    </span><span style="color:#B07D48;">result</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> </span><span style="color:#998418;">ListToMap</span><span style="color:#999999;">(</span><span style="color:#393A34;">list</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;">n </span><span style="color:#AB5959;">int</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 style="color:#393A34;"> </span><span style="color:#AB5959;">bool</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:#1E754F;">return</span><span style="color:#393A34;"> n</span><span style="color:#999999;">,</span><span style="color:#393A34;"> n </span><span style="color:#AB5959;">&gt;</span><span style="color:#393A34;"> </span><span style="color:#2F798A;">1</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;">result</span><span style="color:#999999;">)</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">//map[int]bool{1: false, 2: true, 3: true, 4: true}</span></span>
<span class="line"><span style="color:#999999;">}</span></span></code></pre></div><h3 id="SubList" tabindex="-1"><span id="SubList">SubList</span> <a class="header-anchor" href="#SubList" aria-label="Permalink to &quot;&lt;span id=&quot;SubList&quot;&gt;SubList&lt;/span&gt;&quot;">​</a></h3><p>SubList returns a sub list of the original list between the specified fromIndex, inclusive, and toIndex, exclusive.</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;"> (l </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">List[T]) </span><span style="color:#62E884;">SubList</span><span style="color:#F6F6F4;">(fromIndex, toIndex </span><span style="color:#97E1F1;font-style:italic;">int</span><span style="color:#F6F6F4;">) </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">List[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;">l </span><span style="color:#AB5959;">*</span><span style="color:#393A34;">List</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;">SubList</span><span style="color:#999999;">(</span><span style="color:#393A34;">fromIndex</span><span style="color:#999999;">,</span><span style="color:#393A34;"> toIndex </span><span style="color:#AB5959;">int</span><span style="color:#999999;">)</span><span style="color:#393A34;"> </span><span style="color:#AB5959;">*</span><span style="color:#393A34;">List</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;">    list </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/list</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;">    l </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> list.</span><span style="color:#97E1F1;">NewList</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;">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 style="color:#BF9EEE;">6</span><span style="color:#F6F6F4;">})</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;">(l.</span><span style="color:#97E1F1;">SubList</span><span style="color:#F6F6F4;">(</span><span style="color:#BF9EEE;">2</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">5</span><span style="color:#F6F6F4;">)) </span><span style="color:#7B7F8B;">// []int{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;">list</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/list</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;">l</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> list</span><span style="color:#999999;">.</span><span style="color:#998418;">NewList</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;">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 style="color:#393A34;"> </span><span style="color:#2F798A;">6</span><span style="color:#999999;">})</span></span>
<span class="line"><span style="color:#393A34;">   </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;">l</span><span style="color:#999999;">.</span><span style="color:#998418;">SubList</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;">5</span><span style="color:#999999;">))</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">// []int{3, 4, 5}</span></span>
<span class="line"><span style="color:#999999;">}</span></span></code></pre></div><h3 id="DeleteIf" tabindex="-1"><span id="DeleteIf">DeleteIf</span> <a class="header-anchor" href="#DeleteIf" aria-label="Permalink to &quot;&lt;span id=&quot;DeleteIf&quot;&gt;DeleteIf&lt;/span&gt;&quot;">​</a></h3><p>DeleteIf delete all satisfying f(data[i]), returns count of removed elements</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;"> (l </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">List[T]) </span><span style="color:#62E884;">DeleteIf</span><span style="color:#F6F6F4;">(f </span><span style="color:#F286C4;">func</span><span style="color:#F6F6F4;">(T) </span><span style="color:#97E1F1;font-style:italic;">bool</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;">l </span><span style="color:#AB5959;">*</span><span style="color:#393A34;">List</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;">DeleteIf</span><span style="color:#999999;">(</span><span style="color:#393A34;">f </span><span style="color:#1E754F;">func</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 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;">    list </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/list</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;">    l </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> list.</span><span style="color:#97E1F1;">NewList</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;">1</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">1</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;">1</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">1</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">4</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">1</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">1</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">1</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">1</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">1</span><span style="color:#F6F6F4;">, </span><span style="color:#BF9EEE;">1</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;">(l.</span><span style="color:#97E1F1;">DeleteIf</span><span style="color:#F6F6F4;">(</span><span style="color:#F286C4;">func</span><span style="color:#F6F6F4;">(a </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 style="color:#F286C4;">return</span><span style="color:#F6F6F4;"> a </span><span style="color:#F286C4;">==</span><span style="color:#F6F6F4;"> </span><span style="color:#BF9EEE;">1</span><span style="color:#F6F6F4;"> })) </span><span style="color:#7B7F8B;">// 12 </span></span>
<span class="line"><span style="color:#F6F6F4;">    fmt.</span><span style="color:#97E1F1;">Println</span><span style="color:#F6F6F4;">(l.</span><span style="color:#97E1F1;">Data</span><span style="color:#F6F6F4;">()) </span><span style="color:#7B7F8B;">// []int{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;">list</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/list</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;">l</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> list</span><span style="color:#999999;">.</span><span style="color:#998418;">NewList</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;">1</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#2F798A;">1</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </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;">1</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#2F798A;">1</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;">1</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#2F798A;">1</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#2F798A;">1</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#2F798A;">1</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#2F798A;">1</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#2F798A;">1</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;">l</span><span style="color:#999999;">.</span><span style="color:#998418;">DeleteIf</span><span style="color:#999999;">(</span><span style="color:#1E754F;">func</span><span style="color:#999999;">(</span><span style="color:#393A34;">a </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 style="color:#393A34;"> </span><span style="color:#1E754F;">return</span><span style="color:#393A34;"> a </span><span style="color:#AB5959;">==</span><span style="color:#393A34;"> </span><span style="color:#2F798A;">1</span><span style="color:#393A34;"> </span><span style="color:#999999;">}))</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">// 12 </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;">l</span><span style="color:#999999;">.</span><span style="color:#998418;">Data</span><span style="color:#999999;">())</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">// []int{2, 3, 4}</span></span>
<span class="line"><span style="color:#999999;">}</span></span></code></pre></div>`,211),f=[t,c,r,y,F,i,A,E,u,d,g];function h(m,B,v,b,C,q){return p(),o("div",null,f)}const L=l(e,[["render",h]]);export{k as __pageData,L as default};
