import{_ as l,o as p,c as o,k as s,a,X as n}from"./chunks/framework.6e839c56.js";const C=JSON.parse('{"title":"Linklist","description":"","frontmatter":{},"headers":[],"relativePath":"en/api/packages/datastructure/link.md","filePath":"en/api/packages/datastructure/link.md"}'),e={name:"en/api/packages/datastructure/link.md"},t=s("h1",{id:"Linklist",tabindex:"-1"},[a("Linklist "),s("a",{class:"header-anchor",href:"#Linklist","aria-label":'Permalink to "Linklist"'},"​")],-1),c=s("p",null,"Linklist a linked list, whose node has a value and a pointer points to next node of the link.",-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),i=s("ul",null,[s("li",null,[s("a",{href:"https://github.com/duke-git/lancet/blob/main/datastructure/link/singlylink.go",target:"_blank",rel:"noreferrer"},"https://github.com/duke-git/lancet/blob/main/datastructure/link/singlylink.go")]),s("li",null,[s("a",{href:"https://github.com/duke-git/lancet/blob/main/datastructure/link/doublylink.go",target:"_blank",rel:"noreferrer"},"https://github.com/duke-git/lancet/blob/main/datastructure/link/doublylink.go")])],-1),F=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;">    link </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/link</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;">link</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/link</span><span style="color:#B5695999;">&quot;</span></span>
<span class="line"><span style="color:#999999;">)</span></span></code></pre></div>`,2),u=s("div",{STYLE:"page-break-after: always;"},null,-1),d=n('<h2 id="Index" tabindex="-1">Index <a class="header-anchor" href="#Index" aria-label="Permalink to &quot;Index&quot;">​</a></h2><h3 id="_1-SinglyLink" tabindex="-1">1. SinglyLink <a class="header-anchor" href="#_1-SinglyLink" aria-label="Permalink to &quot;1. SinglyLink&quot;">​</a></h3><ul><li><a href="#NewSinglyLink">NewSinglyLink</a></li><li><a href="#SinglyLink_Values">Values</a></li><li><a href="#SinglyLink_InsertAt">InsertAt</a></li><li><a href="#SinglyLink_InsertAtHead">InsertAtHead</a></li><li><a href="#SinglyLink_InsertAtTail">InsertAtTail</a></li><li><a href="#SinglyLink_DeleteAt">DeleteAt</a></li><li><a href="#SinglyLink_DeleteAtHead">DeleteAtHead</a></li><li><a href="#SinglyLink_DeleteAtTail">DeleteAtTail</a></li><li><a href="#SinglyLink_DeleteValue">DeleteValue</a></li><li><a href="#SinglyLink_Reverse">Reverse</a></li><li><a href="#SinglyLink_GetMiddleNode">GetMiddleNode</a></li><li><a href="#SinglyLink_Size">Size</a></li><li><a href="#SinglyLink_IsEmpty">IsEmpty</a></li><li><a href="#SinglyLink_Clear">Clear</a></li><li><a href="#SinglyLink_Print">Print</a></li></ul><h3 id="_2-DoublyLink" tabindex="-1">2. DoublyLink <a class="header-anchor" href="#_2-DoublyLink" aria-label="Permalink to &quot;2. DoublyLink&quot;">​</a></h3><ul><li><a href="#NewDoublyLink">NewDoublyLink</a></li><li><a href="#DoublyLink_Values">Values</a></li><li><a href="#DoublyLink_InsertAt">InsertAt</a></li><li><a href="#DoublyLink_InsertAtHead">InsertAtHead</a></li><li><a href="#DoublyLink_InsertAtTail">InsertAtTail</a></li><li><a href="#DoublyLink_DeleteAt">DeleteAt</a></li><li><a href="#DoublyLink_DeleteAtHead">DeleteAtHead</a></li><li><a href="#DoublyLink_DeleteAtTail">DeleteAtTail</a></li><li><a href="#DoublyLink_Reverse">Reverse</a></li><li><a href="#DoublyLink_GetMiddleNode">GetMiddleNode</a></li><li><a href="#DoublyLink_Size">Size</a></li><li><a href="#DoublyLink_IsEmpty">IsEmpty</a></li><li><a href="#DoublyLink_Clear">Clear</a></li><li><a href="#DoublyLink_Print">Print</a></li></ul>',5),k=s("div",{STYLE:"page-break-after: always;"},null,-1),E=n(`<h2 id="Documentation" tabindex="-1">Documentation <a class="header-anchor" href="#Documentation" aria-label="Permalink to &quot;Documentation&quot;">​</a></h2><h3 id="_1-SinglyLink-1" tabindex="-1">1. SinglyLink <a class="header-anchor" href="#_1-SinglyLink-1" aria-label="Permalink to &quot;1. SinglyLink&quot;">​</a></h3><p>SinglyLink a linked list, whose node has a value and a pointer points to next node of the link.</p><h3 id="NewSinglyLink" tabindex="-1"><span id="NewSinglyLink">NewSinglyLink</span> <a class="header-anchor" href="#NewSinglyLink" aria-label="Permalink to &quot;&lt;span id=&quot;NewSinglyLink&quot;&gt;NewSinglyLink&lt;/span&gt;&quot;">​</a></h3><p>Return a singly link(SinglyLink) instance</p><p><b>Signature:</b></p><div class="language-go vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">go</span><pre class="shiki dracula-soft vp-code-dark"><code><span class="line"><span style="color:#F286C4;">type</span><span style="color:#F6F6F4;"> </span><span style="color:#97E1F1;font-style:italic;">LinkNode</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;">	Value T</span></span>
<span class="line"><span style="color:#F6F6F4;">	Next  </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">LinkNode[T]</span></span>
<span class="line"><span style="color:#F6F6F4;">}</span></span>
<span class="line"><span style="color:#F286C4;">type</span><span style="color:#F6F6F4;"> </span><span style="color:#97E1F1;font-style:italic;">SinglyLink</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;">	Head   </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">datastructure.LinkNode[T]</span></span>
<span class="line"><span style="color:#F6F6F4;">	length </span><span style="color:#97E1F1;font-style:italic;">int</span></span>
<span class="line"><span style="color:#F6F6F4;">}</span></span>
<span class="line"><span style="color:#F286C4;">func</span><span style="color:#F6F6F4;"> NewSinglyLink[T any]() </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">SinglyLink[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;">LinkNode</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;">	Value T</span></span>
<span class="line"><span style="color:#393A34;">	Next  </span><span style="color:#AB5959;">*</span><span style="color:#393A34;">LinkNode</span><span style="color:#999999;">[</span><span style="color:#393A34;">T</span><span style="color:#999999;">]</span></span>
<span class="line"><span style="color:#999999;">}</span></span>
<span class="line"><span style="color:#1E754F;">type</span><span style="color:#393A34;"> </span><span style="color:#2E8F82;">SinglyLink</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;">	Head   </span><span style="color:#AB5959;">*</span><span style="color:#393A34;">datastructure</span><span style="color:#999999;">.</span><span style="color:#393A34;">LinkNode</span><span style="color:#999999;">[</span><span style="color:#393A34;">T</span><span style="color:#999999;">]</span></span>
<span class="line"><span style="color:#393A34;">	length </span><span style="color:#AB5959;">int</span></span>
<span class="line"><span style="color:#999999;">}</span></span>
<span class="line"><span style="color:#1E754F;">func</span><span style="color:#393A34;"> NewSinglyLink</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:#AB5959;">*</span><span style="color:#393A34;">SinglyLink</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;">    link </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/link</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;">    lk </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> link.NewSinglyLink[</span><span style="color:#97E1F1;font-style:italic;">int</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;">(lk)</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;">link</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/link</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;">lk</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> link</span><span style="color:#999999;">.</span><span style="color:#393A34;">NewSinglyLink</span><span style="color:#999999;">[</span><span style="color:#AB5959;">int</span><span style="color:#999999;">]()</span></span>
<span class="line"><span style="color:#393A34;">    fmt</span><span style="color:#999999;">.</span><span style="color:#998418;">Println</span><span style="color:#999999;">(</span><span style="color:#393A34;">lk</span><span style="color:#999999;">)</span></span>
<span class="line"><span style="color:#999999;">}</span></span></code></pre></div><h3 id="Values" tabindex="-1"><span id="SinglyLink_Values">Values</span> <a class="header-anchor" href="#Values" aria-label="Permalink to &quot;&lt;span id=&quot;SinglyLink_Values&quot;&gt;Values&lt;/span&gt;&quot;">​</a></h3><p>Return a slice of all node value in singly linklist</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;"> (link </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">SinglyLink[T]) </span><span style="color:#62E884;">Values</span><span style="color:#F6F6F4;">() []T</span></span></code></pre><pre class="shiki vitesse-light vp-code-light"><code><span class="line"><span style="color:#1E754F;">func</span><span style="color:#393A34;"> </span><span style="color:#999999;">(</span><span style="color:#393A34;">link </span><span style="color:#AB5959;">*</span><span style="color:#393A34;">SinglyLink</span><span style="color:#999999;">[</span><span style="color:#393A34;">T</span><span style="color:#999999;">])</span><span style="color:#393A34;"> </span><span style="color:#59873A;">Values</span><span style="color:#999999;">()</span><span style="color:#393A34;"> </span><span style="color:#999999;">[]</span><span style="color:#393A34;">T</span></span></code></pre></div><p><b>Example:</b></p><div class="language-go vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">go</span><pre class="shiki dracula-soft vp-code-dark"><code><span class="line"><span style="color:#F286C4;">package</span><span style="color:#F6F6F4;"> main</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F286C4;">import</span><span style="color:#F6F6F4;"> (</span></span>
<span class="line"><span style="color:#F6F6F4;">    </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">fmt</span><span style="color:#DEE492;">&quot;</span></span>
<span class="line"><span style="color:#F6F6F4;">    link </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/link</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;">    lk </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> link.NewSinglyLink[</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;">    lk.</span><span style="color:#97E1F1;">InsertAtTail</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;">    lk.</span><span style="color:#97E1F1;">InsertAtTail</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;">    lk.</span><span style="color:#97E1F1;">InsertAtTail</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;">(lk.</span><span style="color:#97E1F1;">Values</span><span style="color:#F6F6F4;">()) </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;">link</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/link</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;">lk</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> link</span><span style="color:#999999;">.</span><span style="color:#393A34;">NewSinglyLink</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;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAtTail</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;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAtTail</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;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAtTail</span><span style="color:#999999;">(</span><span style="color:#2F798A;">3</span><span style="color:#999999;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#393A34;">    fmt</span><span style="color:#999999;">.</span><span style="color:#998418;">Println</span><span style="color:#999999;">(</span><span style="color:#393A34;">lk</span><span style="color:#999999;">.</span><span style="color:#998418;">Values</span><span style="color:#999999;">())</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">//[]int{1, 2, 3}</span></span>
<span class="line"><span style="color:#999999;">}</span></span></code></pre></div><h3 id="InsertAt" tabindex="-1"><span id="SinglyLink_InsertAt">InsertAt</span> <a class="header-anchor" href="#InsertAt" aria-label="Permalink to &quot;&lt;span id=&quot;SinglyLink_InsertAt&quot;&gt;InsertAt&lt;/span&gt;&quot;">​</a></h3><p>Insert value into singly linklist at index, param \`index\` should between [0, len(SinglyLink)], if index do not meet the conditions, 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;"> (link </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">SinglyLink[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;">link </span><span style="color:#AB5959;">*</span><span style="color:#393A34;">SinglyLink</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;">    link </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/link</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;">    lk </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> link.NewSinglyLink[</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;">    lk.</span><span style="color:#97E1F1;">InsertAt</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:#7B7F8B;">//do nothing</span></span>
<span class="line"><span style="color:#F6F6F4;">    </span></span>
<span class="line"><span style="color:#F6F6F4;">    lk.</span><span style="color:#97E1F1;">InsertAt</span><span style="color:#F6F6F4;">(</span><span style="color:#BF9EEE;">0</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;">    lk.</span><span style="color:#97E1F1;">InsertAt</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;">    lk.</span><span style="color:#97E1F1;">InsertAt</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;">    lk.</span><span style="color:#97E1F1;">InsertAt</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;">    fmt.</span><span style="color:#97E1F1;">Println</span><span style="color:#F6F6F4;">(lk.</span><span style="color:#97E1F1;">Values</span><span style="color:#F6F6F4;">()) </span><span style="color:#7B7F8B;">//[]int{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;">link</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/link</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;">lk</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> link</span><span style="color:#999999;">.</span><span style="color:#393A34;">NewSinglyLink</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;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAt</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:#A0ADA0;">//do nothing</span></span>
<span class="line"><span style="color:#393A34;">    </span></span>
<span class="line"><span style="color:#393A34;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAt</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;">1</span><span style="color:#999999;">)</span></span>
<span class="line"><span style="color:#393A34;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAt</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;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAt</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;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAt</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>
<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;">lk</span><span style="color:#999999;">.</span><span style="color:#998418;">Values</span><span style="color:#999999;">())</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">//[]int{1, 2, 4, 3}</span></span>
<span class="line"><span style="color:#999999;">}</span></span></code></pre></div><h3 id="InsertAtHead" tabindex="-1"><span id="SinglyLink_InsertAtHead">InsertAtHead</span> <a class="header-anchor" href="#InsertAtHead" aria-label="Permalink to &quot;&lt;span id=&quot;SinglyLink_InsertAtHead&quot;&gt;InsertAtHead&lt;/span&gt;&quot;">​</a></h3><p>Insert value into singly linklist at head(first) index</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;"> (link </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">SinglyLink[T]) </span><span style="color:#62E884;">InsertAtHead</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;">link </span><span style="color:#AB5959;">*</span><span style="color:#393A34;">SinglyLink</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;">InsertAtHead</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;">    link </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/link</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;">    lk </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> link.NewSinglyLink[</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;">    lk.</span><span style="color:#97E1F1;">InsertAtHead</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;">    lk.</span><span style="color:#97E1F1;">InsertAtHead</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;">    lk.</span><span style="color:#97E1F1;">InsertAtHead</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;">(lk.</span><span style="color:#97E1F1;">Values</span><span style="color:#F6F6F4;">()) </span><span style="color:#7B7F8B;">//[]int{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;">link</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/link</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;">lk</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> link</span><span style="color:#999999;">.</span><span style="color:#393A34;">NewSinglyLink</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;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAtHead</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;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAtHead</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;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAtHead</span><span style="color:#999999;">(</span><span style="color:#2F798A;">3</span><span style="color:#999999;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#393A34;">    fmt</span><span style="color:#999999;">.</span><span style="color:#998418;">Println</span><span style="color:#999999;">(</span><span style="color:#393A34;">lk</span><span style="color:#999999;">.</span><span style="color:#998418;">Values</span><span style="color:#999999;">())</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">//[]int{3, 2, 1}</span></span>
<span class="line"><span style="color:#999999;">}</span></span></code></pre></div><h3 id="InsertAtTail" tabindex="-1"><span id="SinglyLink_InsertAtTail">InsertAtTail</span> <a class="header-anchor" href="#InsertAtTail" aria-label="Permalink to &quot;&lt;span id=&quot;SinglyLink_InsertAtTail&quot;&gt;InsertAtTail&lt;/span&gt;&quot;">​</a></h3><p>Insert value into singly linklist at tail(last) index</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;"> (link </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">SinglyLink[T]) </span><span style="color:#62E884;">InsertAtTail</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;">link </span><span style="color:#AB5959;">*</span><span style="color:#393A34;">SinglyLink</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;">InsertAtTail</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;">    link </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/link</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;">    lk </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> link.NewSinglyLink[</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;">    lk.</span><span style="color:#97E1F1;">InsertAtTail</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;">    lk.</span><span style="color:#97E1F1;">InsertAtTail</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;">    lk.</span><span style="color:#97E1F1;">InsertAtTail</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;">(lk.</span><span style="color:#97E1F1;">Values</span><span style="color:#F6F6F4;">()) </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;">link</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/link</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;">lk</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> link</span><span style="color:#999999;">.</span><span style="color:#393A34;">NewSinglyLink</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;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAtTail</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;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAtTail</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;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAtTail</span><span style="color:#999999;">(</span><span style="color:#2F798A;">3</span><span style="color:#999999;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#393A34;">    fmt</span><span style="color:#999999;">.</span><span style="color:#998418;">Println</span><span style="color:#999999;">(</span><span style="color:#393A34;">lk</span><span style="color:#999999;">.</span><span style="color:#998418;">Values</span><span style="color:#999999;">())</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">//[]int{1, 2, 3}</span></span>
<span class="line"><span style="color:#999999;">}</span></span></code></pre></div><h3 id="DeleteAt" tabindex="-1"><span id="SinglyLink_DeleteAt">DeleteAt</span> <a class="header-anchor" href="#DeleteAt" aria-label="Permalink to &quot;&lt;span id=&quot;SinglyLink_DeleteAt&quot;&gt;DeleteAt&lt;/span&gt;&quot;">​</a></h3><p>Delete value at specific index, param \`index\` should be [0, len(SinglyLink)-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;"> (link </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">SinglyLink[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;">link </span><span style="color:#AB5959;">*</span><span style="color:#393A34;">SinglyLink</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;">    link </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/link</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;">    lk </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> link.NewSinglyLink[</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;">    lk.</span><span style="color:#97E1F1;">InsertAtTail</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;">    lk.</span><span style="color:#97E1F1;">InsertAtTail</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;">    lk.</span><span style="color:#97E1F1;">InsertAtTail</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;">    lk.</span><span style="color:#97E1F1;">InsertAtTail</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;">    lk.</span><span style="color:#97E1F1;">DeleteAt</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;">(lk.</span><span style="color:#97E1F1;">Values</span><span style="color:#F6F6F4;">()) </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;">link</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/link</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;">lk</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> link</span><span style="color:#999999;">.</span><span style="color:#393A34;">NewSinglyLink</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;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAtTail</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;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAtTail</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;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAtTail</span><span style="color:#999999;">(</span><span style="color:#2F798A;">3</span><span style="color:#999999;">)</span></span>
<span class="line"><span style="color:#393A34;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAtTail</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;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">DeleteAt</span><span style="color:#999999;">(</span><span style="color:#2F798A;">3</span><span style="color:#999999;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#393A34;">    fmt</span><span style="color:#999999;">.</span><span style="color:#998418;">Println</span><span style="color:#999999;">(</span><span style="color:#393A34;">lk</span><span style="color:#999999;">.</span><span style="color:#998418;">Values</span><span style="color:#999999;">())</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">//[]int{1, 2, 3}</span></span>
<span class="line"><span style="color:#999999;">}</span></span></code></pre></div><h3 id="DeleteAtHead" tabindex="-1"><span id="SinglyLink_DeleteAtHead">DeleteAtHead</span> <a class="header-anchor" href="#DeleteAtHead" aria-label="Permalink to &quot;&lt;span id=&quot;SinglyLink_DeleteAtHead&quot;&gt;DeleteAtHead&lt;/span&gt;&quot;">​</a></h3><p>Delete value in singly linklist at first index</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;"> (link </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">SinglyLink[T]) </span><span style="color:#62E884;">DeleteAtHead</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;">link </span><span style="color:#AB5959;">*</span><span style="color:#393A34;">SinglyLink</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;">DeleteAtHead</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;">    link </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/link</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;">    lk </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> link.NewSinglyLink[</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;">    lk.</span><span style="color:#97E1F1;">InsertAtTail</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;">    lk.</span><span style="color:#97E1F1;">InsertAtTail</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;">    lk.</span><span style="color:#97E1F1;">InsertAtTail</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;">    lk.</span><span style="color:#97E1F1;">InsertAtTail</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;">    lk.</span><span style="color:#97E1F1;">DeleteAtHead</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;">(lk.</span><span style="color:#97E1F1;">Values</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;">link</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/link</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;">lk</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> link</span><span style="color:#999999;">.</span><span style="color:#393A34;">NewSinglyLink</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;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAtTail</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;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAtTail</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;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAtTail</span><span style="color:#999999;">(</span><span style="color:#2F798A;">3</span><span style="color:#999999;">)</span></span>
<span class="line"><span style="color:#393A34;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAtTail</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;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">DeleteAtHead</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;">lk</span><span style="color:#999999;">.</span><span style="color:#998418;">Values</span><span style="color:#999999;">())</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">//[]int{2, 3, 4}</span></span>
<span class="line"><span style="color:#999999;">}</span></span></code></pre></div><h3 id="DeleteAtTail" tabindex="-1"><span id="SinglyLink_DeleteAtTail">DeleteAtTail</span> <a class="header-anchor" href="#DeleteAtTail" aria-label="Permalink to &quot;&lt;span id=&quot;SinglyLink_DeleteAtTail&quot;&gt;DeleteAtTail&lt;/span&gt;&quot;">​</a></h3><p>Delete value in singly linklist at last index</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;"> (link </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">SinglyLink[T]) </span><span style="color:#62E884;">DeleteAtTail</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;">link </span><span style="color:#AB5959;">*</span><span style="color:#393A34;">SinglyLink</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;">DeleteAtTail</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;">    link </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/link</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;">    lk </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> link.NewSinglyLink[</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;">    lk.</span><span style="color:#97E1F1;">InsertAtTail</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;">    lk.</span><span style="color:#97E1F1;">InsertAtTail</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;">    lk.</span><span style="color:#97E1F1;">InsertAtTail</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;">    lk.</span><span style="color:#97E1F1;">DeleteAtTail</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;">(lk.</span><span style="color:#97E1F1;">Values</span><span style="color:#F6F6F4;">()) </span><span style="color:#7B7F8B;">//[]int{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;">link</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/link</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;">lk</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> link</span><span style="color:#999999;">.</span><span style="color:#393A34;">NewSinglyLink</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;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAtTail</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;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAtTail</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;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAtTail</span><span style="color:#999999;">(</span><span style="color:#2F798A;">3</span><span style="color:#999999;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#393A34;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">DeleteAtTail</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;">lk</span><span style="color:#999999;">.</span><span style="color:#998418;">Values</span><span style="color:#999999;">())</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">//[]int{1, 2}</span></span>
<span class="line"><span style="color:#999999;">}</span></span></code></pre></div><h3 id="DeleteValue" tabindex="-1"><span id="SinglyLink_DeleteValue">DeleteValue</span> <a class="header-anchor" href="#DeleteValue" aria-label="Permalink to &quot;&lt;span id=&quot;SinglyLink_DeleteValue&quot;&gt;DeleteValue&lt;/span&gt;&quot;">​</a></h3><p>Delete all \`value\` in singly linklist</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;"> (link </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">SinglyLink[T]) </span><span style="color:#62E884;">DeleteValue</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;">link </span><span style="color:#AB5959;">*</span><span style="color:#393A34;">SinglyLink</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;">DeleteValue</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;">    link </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/link</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;">    lk </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> link.NewSinglyLink[</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;">    lk.</span><span style="color:#97E1F1;">InsertAtTail</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;">    lk.</span><span style="color:#97E1F1;">InsertAtTail</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;">    lk.</span><span style="color:#97E1F1;">InsertAtTail</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;">    lk.</span><span style="color:#97E1F1;">InsertAtTail</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;">    lk.</span><span style="color:#97E1F1;">DeleteValue</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;">(lk.</span><span style="color:#97E1F1;">Values</span><span style="color:#F6F6F4;">()) </span><span style="color:#7B7F8B;">//[]int{1, 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;">link</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/link</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;">lk</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> link</span><span style="color:#999999;">.</span><span style="color:#393A34;">NewSinglyLink</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;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAtTail</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;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAtTail</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;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAtTail</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;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAtTail</span><span style="color:#999999;">(</span><span style="color:#2F798A;">3</span><span style="color:#999999;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#393A34;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">DeleteValue</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;">lk</span><span style="color:#999999;">.</span><span style="color:#998418;">Values</span><span style="color:#999999;">())</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">//[]int{1, 3}</span></span>
<span class="line"><span style="color:#999999;">}</span></span></code></pre></div><h3 id="Reverse" tabindex="-1"><span id="SinglyLink_Reverse">Reverse</span> <a class="header-anchor" href="#Reverse" aria-label="Permalink to &quot;&lt;span id=&quot;SinglyLink_Reverse&quot;&gt;Reverse&lt;/span&gt;&quot;">​</a></h3><p>Reverse all nodes order in linkist</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;"> (link </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">SinglyLink[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;">link </span><span style="color:#AB5959;">*</span><span style="color:#393A34;">SinglyLink</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;">    link </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/link</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;">    lk </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> link.NewSinglyLink[</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;">    lk.</span><span style="color:#97E1F1;">InsertAtTail</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;">    lk.</span><span style="color:#97E1F1;">InsertAtTail</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;">    lk.</span><span style="color:#97E1F1;">InsertAtTail</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;">    lk.</span><span style="color:#97E1F1;">Reverse</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;">(lk.</span><span style="color:#97E1F1;">Values</span><span style="color:#F6F6F4;">()) </span><span style="color:#7B7F8B;">//[]int{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;">link</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/link</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;">lk</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> link</span><span style="color:#999999;">.</span><span style="color:#393A34;">NewSinglyLink</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;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAtTail</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;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAtTail</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;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAtTail</span><span style="color:#999999;">(</span><span style="color:#2F798A;">3</span><span style="color:#999999;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#393A34;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">Reverse</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;">lk</span><span style="color:#999999;">.</span><span style="color:#998418;">Values</span><span style="color:#999999;">())</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">//[]int{3, 2, 1}</span></span>
<span class="line"><span style="color:#999999;">}</span></span></code></pre></div><h3 id="GetMiddleNode" tabindex="-1"><span id="SinglyLink_GetMiddleNode">GetMiddleNode</span> <a class="header-anchor" href="#GetMiddleNode" aria-label="Permalink to &quot;&lt;span id=&quot;SinglyLink_GetMiddleNode&quot;&gt;GetMiddleNode&lt;/span&gt;&quot;">​</a></h3><p>Get the node at middle index of linkist</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;"> (link </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">SinglyLink[T]) </span><span style="color:#62E884;">GetMiddleNode</span><span style="color:#F6F6F4;">() </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">datastructure.LinkNode[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;">link </span><span style="color:#AB5959;">*</span><span style="color:#393A34;">SinglyLink</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;">GetMiddleNode</span><span style="color:#999999;">()</span><span style="color:#393A34;"> </span><span style="color:#AB5959;">*</span><span style="color:#393A34;">datastructure</span><span style="color:#999999;">.</span><span style="color:#393A34;">LinkNode</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;">    link </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/link</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;">    lk </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> link.NewSinglyLink[</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;">    lk.</span><span style="color:#97E1F1;">InsertAtTail</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;">    lk.</span><span style="color:#97E1F1;">InsertAtTail</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;">    lk.</span><span style="color:#97E1F1;">InsertAtTail</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;">    midNode </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> lk.</span><span style="color:#97E1F1;">GetMiddleNode</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;">(midNode.Value) </span><span style="color:#7B7F8B;">//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;">link</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/link</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;">lk</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> link</span><span style="color:#999999;">.</span><span style="color:#393A34;">NewSinglyLink</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;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAtTail</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;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAtTail</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;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAtTail</span><span style="color:#999999;">(</span><span style="color:#2F798A;">3</span><span style="color:#999999;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B07D48;">midNode</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> lk</span><span style="color:#999999;">.</span><span style="color:#998418;">GetMiddleNode</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;">midNode</span><span style="color:#999999;">.</span><span style="color:#393A34;">Value</span><span style="color:#999999;">)</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">//2</span></span>
<span class="line"><span style="color:#999999;">}</span></span></code></pre></div><h3 id="Size" tabindex="-1"><span id="SinglyLink_Size">Size</span> <a class="header-anchor" href="#Size" aria-label="Permalink to &quot;&lt;span id=&quot;SinglyLink_Size&quot;&gt;Size&lt;/span&gt;&quot;">​</a></h3><p>Get the number of nodes in linklist</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;"> (link </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">SinglyLink[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;">link </span><span style="color:#AB5959;">*</span><span style="color:#393A34;">SinglyLink</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;">    link </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/link</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;">    lk </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> link.NewSinglyLink[</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;">    lk.</span><span style="color:#97E1F1;">InsertAtTail</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;">    lk.</span><span style="color:#97E1F1;">InsertAtTail</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;">    lk.</span><span style="color:#97E1F1;">InsertAtTail</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;">(lk.</span><span style="color:#97E1F1;">Size</span><span style="color:#F6F6F4;">()) </span><span style="color:#7B7F8B;">//3</span></span>
<span class="line"><span style="color:#F6F6F4;">}</span></span></code></pre><pre class="shiki vitesse-light vp-code-light"><code><span class="line"><span style="color:#1E754F;">package</span><span style="color:#393A34;"> </span><span style="color:#59873A;">main</span></span>
<span class="line"></span>
<span class="line"><span style="color:#1E754F;">import</span><span style="color:#393A34;"> </span><span style="color:#999999;">(</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">fmt</span><span style="color:#B5695999;">&quot;</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#59873A;">link</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/link</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;">lk</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> link</span><span style="color:#999999;">.</span><span style="color:#393A34;">NewSinglyLink</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;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAtTail</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;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAtTail</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;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAtTail</span><span style="color:#999999;">(</span><span style="color:#2F798A;">3</span><span style="color:#999999;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#393A34;">    fmt</span><span style="color:#999999;">.</span><span style="color:#998418;">Println</span><span style="color:#999999;">(</span><span style="color:#393A34;">lk</span><span style="color:#999999;">.</span><span style="color:#998418;">Size</span><span style="color:#999999;">())</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">//3</span></span>
<span class="line"><span style="color:#999999;">}</span></span></code></pre></div><h3 id="IsEmpty" tabindex="-1"><span id="SinglyLink_IsEmpty">IsEmpty</span> <a class="header-anchor" href="#IsEmpty" aria-label="Permalink to &quot;&lt;span id=&quot;SinglyLink_IsEmpty&quot;&gt;IsEmpty&lt;/span&gt;&quot;">​</a></h3><p>Checks if linklist 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;"> (link </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">SinglyLink[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;">link </span><span style="color:#AB5959;">*</span><span style="color:#393A34;">SinglyLink</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;">    link </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/link</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;">    lk </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> link.NewSinglyLink[</span><span style="color:#97E1F1;font-style:italic;">int</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;">(lk.</span><span style="color:#97E1F1;">IsEmpty</span><span style="color:#F6F6F4;">()) </span><span style="color:#7B7F8B;">//true</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F6F6F4;">    lk.</span><span style="color:#97E1F1;">InsertAtTail</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;">    lk.</span><span style="color:#97E1F1;">InsertAtTail</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;">    lk.</span><span style="color:#97E1F1;">InsertAtTail</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;">(lk.</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;">}</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;">link</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/link</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;">lk</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> link</span><span style="color:#999999;">.</span><span style="color:#393A34;">NewSinglyLink</span><span style="color:#999999;">[</span><span style="color:#AB5959;">int</span><span style="color:#999999;">]()</span></span>
<span class="line"><span style="color:#393A34;">    fmt</span><span style="color:#999999;">.</span><span style="color:#998418;">Println</span><span style="color:#999999;">(</span><span style="color:#393A34;">lk</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>
<span class="line"><span style="color:#393A34;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAtTail</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;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAtTail</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;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAtTail</span><span style="color:#999999;">(</span><span style="color:#2F798A;">3</span><span style="color:#999999;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#393A34;">    fmt</span><span style="color:#999999;">.</span><span style="color:#998418;">Println</span><span style="color:#999999;">(</span><span style="color:#393A34;">lk</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:#999999;">}</span></span></code></pre></div><h3 id="Clear" tabindex="-1"><span id="SinglyLink_Clear">Clear</span> <a class="header-anchor" href="#Clear" aria-label="Permalink to &quot;&lt;span id=&quot;SinglyLink_Clear&quot;&gt;Clear&lt;/span&gt;&quot;">​</a></h3><p>Clear all nodes in the linklist, make it empty</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;"> (link </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">SinglyLink[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;">link </span><span style="color:#AB5959;">*</span><span style="color:#393A34;">SinglyLink</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;">    link </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/link</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;">    lk </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> link.NewSinglyLink[</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;">    lk.</span><span style="color:#97E1F1;">InsertAtTail</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;">    lk.</span><span style="color:#97E1F1;">InsertAtTail</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;">    lk.</span><span style="color:#97E1F1;">InsertAtTail</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;">    lk.</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;">(lk.</span><span style="color:#97E1F1;">Values</span><span style="color:#F6F6F4;">()) </span><span style="color:#7B7F8B;">//</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;">link</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/link</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;">lk</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> link</span><span style="color:#999999;">.</span><span style="color:#393A34;">NewSinglyLink</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;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAtTail</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;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAtTail</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;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAtTail</span><span style="color:#999999;">(</span><span style="color:#2F798A;">3</span><span style="color:#999999;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#393A34;">    lk</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;">lk</span><span style="color:#999999;">.</span><span style="color:#998418;">Values</span><span style="color:#999999;">())</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">//</span></span>
<span class="line"><span style="color:#999999;">}</span></span></code></pre></div><h3 id="Print" tabindex="-1"><span id="SinglyLink_Print">Print</span> <a class="header-anchor" href="#Print" aria-label="Permalink to &quot;&lt;span id=&quot;SinglyLink_Print&quot;&gt;Print&lt;/span&gt;&quot;">​</a></h3><p>Print all nodes info of linklist</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;"> (link </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">SinglyLink[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;">link </span><span style="color:#AB5959;">*</span><span style="color:#393A34;">SinglyLink</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;">    link </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/link</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;">    lk </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> link.NewSinglyLink[</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;">    lk.</span><span style="color:#97E1F1;">InsertAtTail</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;">    lk.</span><span style="color:#97E1F1;">InsertAtTail</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;">    lk.</span><span style="color:#97E1F1;">InsertAtTail</span><span style="color:#F6F6F4;">(</span><span style="color:#BF9EEE;">3</span><span style="color:#F6F6F4;">)</span></span>
<span class="line"><span style="color:#F6F6F4;">    </span></span>
<span class="line"><span style="color:#F6F6F4;">    lk.</span><span style="color:#97E1F1;">Print</span><span style="color:#F6F6F4;">() </span><span style="color:#7B7F8B;">//[ &amp;{Value:1 Pre:&lt;nil&gt; Next:0xc0000a4048}, &amp;{Value:2 Pre:&lt;nil&gt; Next:0xc0000a4060}, &amp;{Value:3 Pre:&lt;nil&gt; Next:&lt;nil&gt;} ]</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;">link</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/link</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;">lk</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> link</span><span style="color:#999999;">.</span><span style="color:#393A34;">NewSinglyLink</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;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAtTail</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;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAtTail</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;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAtTail</span><span style="color:#999999;">(</span><span style="color:#2F798A;">3</span><span style="color:#999999;">)</span></span>
<span class="line"><span style="color:#393A34;">    </span></span>
<span class="line"><span style="color:#393A34;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">Print</span><span style="color:#999999;">()</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">//[ &amp;{Value:1 Pre:&lt;nil&gt; Next:0xc0000a4048}, &amp;{Value:2 Pre:&lt;nil&gt; Next:0xc0000a4060}, &amp;{Value:3 Pre:&lt;nil&gt; Next:&lt;nil&gt;} ]</span></span>
<span class="line"><span style="color:#999999;">}</span></span></code></pre></div><h3 id="_2-DoublyLink-1" tabindex="-1">2. DoublyLink <a class="header-anchor" href="#_2-DoublyLink-1" aria-label="Permalink to &quot;2. DoublyLink&quot;">​</a></h3><p>DoublyLink is a linked list, whose node has a value, a next pointer points to next node and pre pointer points to previous node of the link.</p><h3 id="NewDoublyLink" tabindex="-1"><span id="NewDoublyLink">NewDoublyLink</span> <a class="header-anchor" href="#NewDoublyLink" aria-label="Permalink to &quot;&lt;span id=&quot;NewDoublyLink&quot;&gt;NewDoublyLink&lt;/span&gt;&quot;">​</a></h3><p>Return a doubly link instance</p><p><b>Signature:</b></p><div class="language-go vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">go</span><pre class="shiki dracula-soft vp-code-dark"><code><span class="line"><span style="color:#F286C4;">type</span><span style="color:#F6F6F4;"> </span><span style="color:#97E1F1;font-style:italic;">LinkNode</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;">	Value T</span></span>
<span class="line"><span style="color:#F6F6F4;">    Pre   </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">LinkNode[T]</span></span>
<span class="line"><span style="color:#F6F6F4;">	Next  </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">LinkNode[T]</span></span>
<span class="line"><span style="color:#F6F6F4;">}</span></span>
<span class="line"><span style="color:#F286C4;">type</span><span style="color:#F6F6F4;"> </span><span style="color:#97E1F1;font-style:italic;">DoublyLink</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;">	Head   </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">datastructure.LinkNode[T]</span></span>
<span class="line"><span style="color:#F6F6F4;">	length </span><span style="color:#97E1F1;font-style:italic;">int</span></span>
<span class="line"><span style="color:#F6F6F4;">}</span></span>
<span class="line"><span style="color:#F286C4;">func</span><span style="color:#F6F6F4;"> NewDoublyLink[T any]() </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">DoublyLink[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;">LinkNode</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;">	Value T</span></span>
<span class="line"><span style="color:#393A34;">    Pre   </span><span style="color:#AB5959;">*</span><span style="color:#393A34;">LinkNode</span><span style="color:#999999;">[</span><span style="color:#393A34;">T</span><span style="color:#999999;">]</span></span>
<span class="line"><span style="color:#393A34;">	Next  </span><span style="color:#AB5959;">*</span><span style="color:#393A34;">LinkNode</span><span style="color:#999999;">[</span><span style="color:#393A34;">T</span><span style="color:#999999;">]</span></span>
<span class="line"><span style="color:#999999;">}</span></span>
<span class="line"><span style="color:#1E754F;">type</span><span style="color:#393A34;"> </span><span style="color:#2E8F82;">DoublyLink</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;">	Head   </span><span style="color:#AB5959;">*</span><span style="color:#393A34;">datastructure</span><span style="color:#999999;">.</span><span style="color:#393A34;">LinkNode</span><span style="color:#999999;">[</span><span style="color:#393A34;">T</span><span style="color:#999999;">]</span></span>
<span class="line"><span style="color:#393A34;">	length </span><span style="color:#AB5959;">int</span></span>
<span class="line"><span style="color:#999999;">}</span></span>
<span class="line"><span style="color:#1E754F;">func</span><span style="color:#393A34;"> NewDoublyLink</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:#AB5959;">*</span><span style="color:#393A34;">DoublyLink</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;">    link </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/link</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;">    lk </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> link.NewDoublyLink[</span><span style="color:#97E1F1;font-style:italic;">int</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;">(lk)</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;">link</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/link</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;">lk</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> link</span><span style="color:#999999;">.</span><span style="color:#393A34;">NewDoublyLink</span><span style="color:#999999;">[</span><span style="color:#AB5959;">int</span><span style="color:#999999;">]()</span></span>
<span class="line"><span style="color:#393A34;">    fmt</span><span style="color:#999999;">.</span><span style="color:#998418;">Println</span><span style="color:#999999;">(</span><span style="color:#393A34;">lk</span><span style="color:#999999;">)</span></span>
<span class="line"><span style="color:#999999;">}</span></span></code></pre></div><h3 id="Values-1" tabindex="-1"><span id="DoublyLink_Values">Values</span> <a class="header-anchor" href="#Values-1" aria-label="Permalink to &quot;&lt;span id=&quot;DoublyLink_Values&quot;&gt;Values&lt;/span&gt;&quot;">​</a></h3><p>Return a slice of all node value in doubly linklist</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;"> (link </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">DoublyLink[T]) </span><span style="color:#62E884;">Values</span><span style="color:#F6F6F4;">() []T</span></span></code></pre><pre class="shiki vitesse-light vp-code-light"><code><span class="line"><span style="color:#1E754F;">func</span><span style="color:#393A34;"> </span><span style="color:#999999;">(</span><span style="color:#393A34;">link </span><span style="color:#AB5959;">*</span><span style="color:#393A34;">DoublyLink</span><span style="color:#999999;">[</span><span style="color:#393A34;">T</span><span style="color:#999999;">])</span><span style="color:#393A34;"> </span><span style="color:#59873A;">Values</span><span style="color:#999999;">()</span><span style="color:#393A34;"> </span><span style="color:#999999;">[]</span><span style="color:#393A34;">T</span></span></code></pre></div><p><b>Example:</b></p><div class="language-go vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">go</span><pre class="shiki dracula-soft vp-code-dark"><code><span class="line"><span style="color:#F286C4;">package</span><span style="color:#F6F6F4;"> main</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F286C4;">import</span><span style="color:#F6F6F4;"> (</span></span>
<span class="line"><span style="color:#F6F6F4;">    </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">fmt</span><span style="color:#DEE492;">&quot;</span></span>
<span class="line"><span style="color:#F6F6F4;">    link </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/link</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;">    lk </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> link.NewDoublyLink[</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;">    lk.</span><span style="color:#97E1F1;">InsertAtTail</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;">    lk.</span><span style="color:#97E1F1;">InsertAtTail</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;">    lk.</span><span style="color:#97E1F1;">InsertAtTail</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;">(lk.</span><span style="color:#97E1F1;">Values</span><span style="color:#F6F6F4;">()) </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;">link</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/link</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;">lk</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> link</span><span style="color:#999999;">.</span><span style="color:#393A34;">NewDoublyLink</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;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAtTail</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;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAtTail</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;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAtTail</span><span style="color:#999999;">(</span><span style="color:#2F798A;">3</span><span style="color:#999999;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#393A34;">    fmt</span><span style="color:#999999;">.</span><span style="color:#998418;">Println</span><span style="color:#999999;">(</span><span style="color:#393A34;">lk</span><span style="color:#999999;">.</span><span style="color:#998418;">Values</span><span style="color:#999999;">())</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">//[]int{1, 2, 3}</span></span>
<span class="line"><span style="color:#999999;">}</span></span></code></pre></div><h3 id="InsertAt-1" tabindex="-1"><span id="DoublyLink_InsertAt">InsertAt</span> <a class="header-anchor" href="#InsertAt-1" aria-label="Permalink to &quot;&lt;span id=&quot;DoublyLink_InsertAt&quot;&gt;InsertAt&lt;/span&gt;&quot;">​</a></h3><p>Insert value into doubly linklist at index, param \`index\` should between [0, len(DoublyLink)], if index do not meet the conditions, 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;"> (link </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">DoublyLink[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;">link </span><span style="color:#AB5959;">*</span><span style="color:#393A34;">DoublyLink</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;">    link </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/link</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;">    lk </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> link.NewDoublyLink[</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;">    lk.</span><span style="color:#97E1F1;">InsertAt</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:#7B7F8B;">//do nothing</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F6F6F4;">    lk.</span><span style="color:#97E1F1;">InsertAt</span><span style="color:#F6F6F4;">(</span><span style="color:#BF9EEE;">0</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;">    lk.</span><span style="color:#97E1F1;">InsertAt</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;">    lk.</span><span style="color:#97E1F1;">InsertAt</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;">    lk.</span><span style="color:#97E1F1;">InsertAt</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;">    fmt.</span><span style="color:#97E1F1;">Println</span><span style="color:#F6F6F4;">(lk.</span><span style="color:#97E1F1;">Values</span><span style="color:#F6F6F4;">()) </span><span style="color:#7B7F8B;">//[]int{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;">link</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/link</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;">lk</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> link</span><span style="color:#999999;">.</span><span style="color:#393A34;">NewDoublyLink</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;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAt</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:#A0ADA0;">//do nothing</span></span>
<span class="line"></span>
<span class="line"><span style="color:#393A34;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAt</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;">1</span><span style="color:#999999;">)</span></span>
<span class="line"><span style="color:#393A34;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAt</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;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAt</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;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAt</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>
<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;">lk</span><span style="color:#999999;">.</span><span style="color:#998418;">Values</span><span style="color:#999999;">())</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">//[]int{1, 2, 4, 3}</span></span>
<span class="line"><span style="color:#999999;">}</span></span></code></pre></div><h3 id="InsertAtHead-1" tabindex="-1"><span id="DoublyLink_InsertAtHead">InsertAtHead</span> <a class="header-anchor" href="#InsertAtHead-1" aria-label="Permalink to &quot;&lt;span id=&quot;DoublyLink_InsertAtHead&quot;&gt;InsertAtHead&lt;/span&gt;&quot;">​</a></h3><p>Insert value into doubly linklist at head(first) index</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;"> (link </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">DoublyLink[T]) </span><span style="color:#62E884;">InsertAtHead</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;">link </span><span style="color:#AB5959;">*</span><span style="color:#393A34;">DoublyLink</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;">InsertAtHead</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;">    link </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/link</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;">    lk </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> link.NewDoublyLink[</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;">    lk.</span><span style="color:#97E1F1;">InsertAtHead</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;">    lk.</span><span style="color:#97E1F1;">InsertAtHead</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;">    lk.</span><span style="color:#97E1F1;">InsertAtHead</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;">(lk.</span><span style="color:#97E1F1;">Values</span><span style="color:#F6F6F4;">()) </span><span style="color:#7B7F8B;">//[]int{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;">link</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/link</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;">lk</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> link</span><span style="color:#999999;">.</span><span style="color:#393A34;">NewDoublyLink</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;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAtHead</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;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAtHead</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;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAtHead</span><span style="color:#999999;">(</span><span style="color:#2F798A;">3</span><span style="color:#999999;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#393A34;">    fmt</span><span style="color:#999999;">.</span><span style="color:#998418;">Println</span><span style="color:#999999;">(</span><span style="color:#393A34;">lk</span><span style="color:#999999;">.</span><span style="color:#998418;">Values</span><span style="color:#999999;">())</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">//[]int{3, 2, 1}</span></span>
<span class="line"><span style="color:#999999;">}</span></span></code></pre></div><h3 id="InsertAtTail-1" tabindex="-1"><span id="DoublyLink_InsertAtTail">InsertAtTail</span> <a class="header-anchor" href="#InsertAtTail-1" aria-label="Permalink to &quot;&lt;span id=&quot;DoublyLink_InsertAtTail&quot;&gt;InsertAtTail&lt;/span&gt;&quot;">​</a></h3><p>Insert value into doubly linklist at tail(last) index</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;"> (link </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">DoublyLink[T]) </span><span style="color:#62E884;">InsertAtTail</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;">link </span><span style="color:#AB5959;">*</span><span style="color:#393A34;">DoublyLink</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;">InsertAtTail</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;">    link </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/link</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;">    lk </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> link.NewDoublyLink[</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;">    lk.</span><span style="color:#97E1F1;">InsertAtTail</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;">    lk.</span><span style="color:#97E1F1;">InsertAtTail</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;">    lk.</span><span style="color:#97E1F1;">InsertAtTail</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;">(lk.</span><span style="color:#97E1F1;">Values</span><span style="color:#F6F6F4;">()) </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;">link</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/link</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;">lk</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> link</span><span style="color:#999999;">.</span><span style="color:#393A34;">NewDoublyLink</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;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAtTail</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;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAtTail</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;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAtTail</span><span style="color:#999999;">(</span><span style="color:#2F798A;">3</span><span style="color:#999999;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#393A34;">    fmt</span><span style="color:#999999;">.</span><span style="color:#998418;">Println</span><span style="color:#999999;">(</span><span style="color:#393A34;">lk</span><span style="color:#999999;">.</span><span style="color:#998418;">Values</span><span style="color:#999999;">())</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">//[]int{1, 2, 3}</span></span>
<span class="line"><span style="color:#999999;">}</span></span></code></pre></div><h3 id="DeleteAt-1" tabindex="-1"><span id="DoublyLink_DeleteAt">DeleteAt</span> <a class="header-anchor" href="#DeleteAt-1" aria-label="Permalink to &quot;&lt;span id=&quot;DoublyLink_DeleteAt&quot;&gt;DeleteAt&lt;/span&gt;&quot;">​</a></h3><p>Delete value at specific index, param \`index\` should be [0, len(DoublyLink)-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;"> (link </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">DoublyLink[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;">link </span><span style="color:#AB5959;">*</span><span style="color:#393A34;">DoublyLink</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;">    link </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/link</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;">    lk </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> link.NewDoublyLink[</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;">    lk.</span><span style="color:#97E1F1;">InsertAtTail</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;">    lk.</span><span style="color:#97E1F1;">InsertAtTail</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;">    lk.</span><span style="color:#97E1F1;">InsertAtTail</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;">    lk.</span><span style="color:#97E1F1;">InsertAtTail</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;">    lk.</span><span style="color:#97E1F1;">DeleteAt</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;">(lk.</span><span style="color:#97E1F1;">Values</span><span style="color:#F6F6F4;">()) </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;">link</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/link</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;">lk</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> link</span><span style="color:#999999;">.</span><span style="color:#393A34;">NewDoublyLink</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;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAtTail</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;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAtTail</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;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAtTail</span><span style="color:#999999;">(</span><span style="color:#2F798A;">3</span><span style="color:#999999;">)</span></span>
<span class="line"><span style="color:#393A34;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAtTail</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;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">DeleteAt</span><span style="color:#999999;">(</span><span style="color:#2F798A;">3</span><span style="color:#999999;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#393A34;">    fmt</span><span style="color:#999999;">.</span><span style="color:#998418;">Println</span><span style="color:#999999;">(</span><span style="color:#393A34;">lk</span><span style="color:#999999;">.</span><span style="color:#998418;">Values</span><span style="color:#999999;">())</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">//[]int{1, 2, 3}</span></span>
<span class="line"><span style="color:#999999;">}</span></span></code></pre></div><h3 id="DeleteAtHead-1" tabindex="-1"><span id="DoublyLink_DeleteAtHead">DeleteAtHead</span> <a class="header-anchor" href="#DeleteAtHead-1" aria-label="Permalink to &quot;&lt;span id=&quot;DoublyLink_DeleteAtHead&quot;&gt;DeleteAtHead&lt;/span&gt;&quot;">​</a></h3><p>Delete value in doubly linklist at first index</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;"> (link </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">DoublyLink[T]) </span><span style="color:#62E884;">DeleteAtHead</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;">link </span><span style="color:#AB5959;">*</span><span style="color:#393A34;">DoublyLink</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;">DeleteAtHead</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;">    link </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/link</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;">    lk </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> link.NewDoublyLink[</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;">    lk.</span><span style="color:#97E1F1;">InsertAtTail</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;">    lk.</span><span style="color:#97E1F1;">InsertAtTail</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;">    lk.</span><span style="color:#97E1F1;">InsertAtTail</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;">    lk.</span><span style="color:#97E1F1;">InsertAtTail</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;">    lk.</span><span style="color:#97E1F1;">DeleteAtHead</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;">(lk.</span><span style="color:#97E1F1;">Values</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;">link</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/link</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;">lk</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> link</span><span style="color:#999999;">.</span><span style="color:#393A34;">NewDoublyLink</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;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAtTail</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;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAtTail</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;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAtTail</span><span style="color:#999999;">(</span><span style="color:#2F798A;">3</span><span style="color:#999999;">)</span></span>
<span class="line"><span style="color:#393A34;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAtTail</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;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">DeleteAtHead</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;">lk</span><span style="color:#999999;">.</span><span style="color:#998418;">Values</span><span style="color:#999999;">())</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">//[]int{2, 3, 4}</span></span>
<span class="line"><span style="color:#999999;">}</span></span></code></pre></div><h3 id="DeleteAtTail-1" tabindex="-1"><span id="DoublyLink_DeleteAtTail">DeleteAtTail</span> <a class="header-anchor" href="#DeleteAtTail-1" aria-label="Permalink to &quot;&lt;span id=&quot;DoublyLink_DeleteAtTail&quot;&gt;DeleteAtTail&lt;/span&gt;&quot;">​</a></h3><p>Delete value in doubly linklist at last index</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;"> (link </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">DoublyLink[T]) </span><span style="color:#62E884;">DeleteAtTail</span><span style="color:#F6F6F4;">() </span><span style="color:#97E1F1;font-style:italic;">error</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;">link </span><span style="color:#AB5959;">*</span><span style="color:#393A34;">DoublyLink</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;">DeleteAtTail</span><span style="color:#999999;">()</span><span style="color:#393A34;"> </span><span style="color:#AB5959;">error</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;">    link </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/link</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;">    lk </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> link.NewDoublyLink[</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;">    lk.</span><span style="color:#97E1F1;">InsertAtTail</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;">    lk.</span><span style="color:#97E1F1;">InsertAtTail</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;">    lk.</span><span style="color:#97E1F1;">InsertAtTail</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;">    err </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> lk.</span><span style="color:#97E1F1;">DeleteAtTail</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;">(err) </span><span style="color:#7B7F8B;">//nil</span></span>
<span class="line"><span style="color:#F6F6F4;">    fmt.</span><span style="color:#97E1F1;">Println</span><span style="color:#F6F6F4;">(lk.</span><span style="color:#97E1F1;">Values</span><span style="color:#F6F6F4;">()) </span><span style="color:#7B7F8B;">//[]int{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;">link</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/link</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;">lk</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> link</span><span style="color:#999999;">.</span><span style="color:#393A34;">NewDoublyLink</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;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAtTail</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;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAtTail</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;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAtTail</span><span style="color:#999999;">(</span><span style="color:#2F798A;">3</span><span style="color:#999999;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B07D48;">err</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> lk</span><span style="color:#999999;">.</span><span style="color:#998418;">DeleteAtTail</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;">err</span><span style="color:#999999;">)</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">//nil</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;">lk</span><span style="color:#999999;">.</span><span style="color:#998418;">Values</span><span style="color:#999999;">())</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">//[]int{1, 2}</span></span>
<span class="line"><span style="color:#999999;">}</span></span></code></pre></div><h3 id="Reverse-1" tabindex="-1"><span id="DoublyLink_Reverse">Reverse</span> <a class="header-anchor" href="#Reverse-1" aria-label="Permalink to &quot;&lt;span id=&quot;DoublyLink_Reverse&quot;&gt;Reverse&lt;/span&gt;&quot;">​</a></h3><p>Reverse all nodes order in linkist</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;"> (link </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">DoublyLink[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;">link </span><span style="color:#AB5959;">*</span><span style="color:#393A34;">DoublyLink</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;">    link </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/link</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;">    lk </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> link.NewDoublyLink[</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;">    lk.</span><span style="color:#97E1F1;">InsertAtTail</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;">    lk.</span><span style="color:#97E1F1;">InsertAtTail</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;">    lk.</span><span style="color:#97E1F1;">InsertAtTail</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;">    lk.</span><span style="color:#97E1F1;">Reverse</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;">(lk.</span><span style="color:#97E1F1;">Values</span><span style="color:#F6F6F4;">()) </span><span style="color:#7B7F8B;">//[]int{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;">link</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/link</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;">lk</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> link</span><span style="color:#999999;">.</span><span style="color:#393A34;">NewDoublyLink</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;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAtTail</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;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAtTail</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;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAtTail</span><span style="color:#999999;">(</span><span style="color:#2F798A;">3</span><span style="color:#999999;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#393A34;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">Reverse</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;">lk</span><span style="color:#999999;">.</span><span style="color:#998418;">Values</span><span style="color:#999999;">())</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">//[]int{3, 2, 1}</span></span>
<span class="line"><span style="color:#999999;">}</span></span></code></pre></div><h3 id="GetMiddleNode-1" tabindex="-1"><span id="DoublyLink_GetMiddleNode">GetMiddleNode</span> <a class="header-anchor" href="#GetMiddleNode-1" aria-label="Permalink to &quot;&lt;span id=&quot;DoublyLink_GetMiddleNode&quot;&gt;GetMiddleNode&lt;/span&gt;&quot;">​</a></h3><p>Get the node at middle index of linkist</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;"> (link </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">DoublyLink[T]) </span><span style="color:#62E884;">GetMiddleNode</span><span style="color:#F6F6F4;">() </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">datastructure.LinkNode[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;">link </span><span style="color:#AB5959;">*</span><span style="color:#393A34;">DoublyLink</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;">GetMiddleNode</span><span style="color:#999999;">()</span><span style="color:#393A34;"> </span><span style="color:#AB5959;">*</span><span style="color:#393A34;">datastructure</span><span style="color:#999999;">.</span><span style="color:#393A34;">LinkNode</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;">    link </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/link</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;">    lk </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> link.NewDoublyLink[</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;">    lk.</span><span style="color:#97E1F1;">InsertAtTail</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;">    lk.</span><span style="color:#97E1F1;">InsertAtTail</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;">    lk.</span><span style="color:#97E1F1;">InsertAtTail</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;">    midNode </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> lk.</span><span style="color:#97E1F1;">GetMiddleNode</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;">(midNode.Value) </span><span style="color:#7B7F8B;">//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;">link</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/link</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;">lk</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> link</span><span style="color:#999999;">.</span><span style="color:#393A34;">NewDoublyLink</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;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAtTail</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;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAtTail</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;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAtTail</span><span style="color:#999999;">(</span><span style="color:#2F798A;">3</span><span style="color:#999999;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B07D48;">midNode</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> lk</span><span style="color:#999999;">.</span><span style="color:#998418;">GetMiddleNode</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;">midNode</span><span style="color:#999999;">.</span><span style="color:#393A34;">Value</span><span style="color:#999999;">)</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">//2</span></span>
<span class="line"><span style="color:#999999;">}</span></span></code></pre></div><h3 id="Size-1" tabindex="-1"><span id="DoublyLink_Size">Size</span> <a class="header-anchor" href="#Size-1" aria-label="Permalink to &quot;&lt;span id=&quot;DoublyLink_Size&quot;&gt;Size&lt;/span&gt;&quot;">​</a></h3><p>Get the number of nodes in linklist</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;"> (link </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">DoublyLink[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;">link </span><span style="color:#AB5959;">*</span><span style="color:#393A34;">DoublyLink</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;">    link </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/link</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;">    lk </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> link.NewDoublyLink[</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;">    lk.</span><span style="color:#97E1F1;">InsertAtTail</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;">    lk.</span><span style="color:#97E1F1;">InsertAtTail</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;">    lk.</span><span style="color:#97E1F1;">InsertAtTail</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;">(lk.</span><span style="color:#97E1F1;">Size</span><span style="color:#F6F6F4;">()) </span><span style="color:#7B7F8B;">//3</span></span>
<span class="line"><span style="color:#F6F6F4;">}</span></span></code></pre><pre class="shiki vitesse-light vp-code-light"><code><span class="line"><span style="color:#1E754F;">package</span><span style="color:#393A34;"> </span><span style="color:#59873A;">main</span></span>
<span class="line"></span>
<span class="line"><span style="color:#1E754F;">import</span><span style="color:#393A34;"> </span><span style="color:#999999;">(</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">fmt</span><span style="color:#B5695999;">&quot;</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#59873A;">link</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/link</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;">lk</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> link</span><span style="color:#999999;">.</span><span style="color:#393A34;">NewDoublyLink</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;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAtTail</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;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAtTail</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;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAtTail</span><span style="color:#999999;">(</span><span style="color:#2F798A;">3</span><span style="color:#999999;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#393A34;">    fmt</span><span style="color:#999999;">.</span><span style="color:#998418;">Println</span><span style="color:#999999;">(</span><span style="color:#393A34;">lk</span><span style="color:#999999;">.</span><span style="color:#998418;">Size</span><span style="color:#999999;">())</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">//3</span></span>
<span class="line"><span style="color:#999999;">}</span></span></code></pre></div><h3 id="IsEmpty-1" tabindex="-1"><span id="DoublyLink_IsEmpty">IsEmpty</span> <a class="header-anchor" href="#IsEmpty-1" aria-label="Permalink to &quot;&lt;span id=&quot;DoublyLink_IsEmpty&quot;&gt;IsEmpty&lt;/span&gt;&quot;">​</a></h3><p>Checks if linklist 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;"> (link </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">DoublyLink[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;">link </span><span style="color:#AB5959;">*</span><span style="color:#393A34;">DoublyLink</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;">    link </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/link</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;">    lk </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> link.NewDoublyLink[</span><span style="color:#97E1F1;font-style:italic;">int</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;">(lk.</span><span style="color:#97E1F1;">IsEmpty</span><span style="color:#F6F6F4;">()) </span><span style="color:#7B7F8B;">//true</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F6F6F4;">    lk.</span><span style="color:#97E1F1;">InsertAtTail</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;">    lk.</span><span style="color:#97E1F1;">InsertAtTail</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;">    lk.</span><span style="color:#97E1F1;">InsertAtTail</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;">(lk.</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;">}</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;">link</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/link</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;">lk</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> link</span><span style="color:#999999;">.</span><span style="color:#393A34;">NewDoublyLink</span><span style="color:#999999;">[</span><span style="color:#AB5959;">int</span><span style="color:#999999;">]()</span></span>
<span class="line"><span style="color:#393A34;">    fmt</span><span style="color:#999999;">.</span><span style="color:#998418;">Println</span><span style="color:#999999;">(</span><span style="color:#393A34;">lk</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>
<span class="line"><span style="color:#393A34;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAtTail</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;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAtTail</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;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAtTail</span><span style="color:#999999;">(</span><span style="color:#2F798A;">3</span><span style="color:#999999;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#393A34;">    fmt</span><span style="color:#999999;">.</span><span style="color:#998418;">Println</span><span style="color:#999999;">(</span><span style="color:#393A34;">lk</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:#999999;">}</span></span></code></pre></div><h3 id="Clear-1" tabindex="-1"><span id="DoublyLink_Clear">Clear</span> <a class="header-anchor" href="#Clear-1" aria-label="Permalink to &quot;&lt;span id=&quot;DoublyLink_Clear&quot;&gt;Clear&lt;/span&gt;&quot;">​</a></h3><p>Clear all nodes in the linklist, make it empty</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;"> (link </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">DoublyLink[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;">link </span><span style="color:#AB5959;">*</span><span style="color:#393A34;">DoublyLink</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;">    link </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/link</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;">    lk </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> link.NewDoublyLink[</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;">    lk.</span><span style="color:#97E1F1;">InsertAtTail</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;">    lk.</span><span style="color:#97E1F1;">InsertAtTail</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;">    lk.</span><span style="color:#97E1F1;">InsertAtTail</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;">    lk.</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;">(lk.</span><span style="color:#97E1F1;">Values</span><span style="color:#F6F6F4;">()) </span><span style="color:#7B7F8B;">//</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;">link</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/link</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;">lk</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> link</span><span style="color:#999999;">.</span><span style="color:#393A34;">NewDoublyLink</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;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAtTail</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;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAtTail</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;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAtTail</span><span style="color:#999999;">(</span><span style="color:#2F798A;">3</span><span style="color:#999999;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#393A34;">    lk</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;">lk</span><span style="color:#999999;">.</span><span style="color:#998418;">Values</span><span style="color:#999999;">())</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">//</span></span>
<span class="line"><span style="color:#999999;">}</span></span></code></pre></div><h3 id="Print-1" tabindex="-1"><span id="DoublyLink_Print">Print</span> <a class="header-anchor" href="#Print-1" aria-label="Permalink to &quot;&lt;span id=&quot;DoublyLink_Print&quot;&gt;Print&lt;/span&gt;&quot;">​</a></h3><p>Print all nodes info of linklist</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;"> (link </span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">DoublyLink[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;">link </span><span style="color:#AB5959;">*</span><span style="color:#393A34;">DoublyLink</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;">    link </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/datastructure/link</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;">    lk </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> link.NewDoublyLink[</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;">    lk.</span><span style="color:#97E1F1;">InsertAtTail</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;">    lk.</span><span style="color:#97E1F1;">InsertAtTail</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;">    lk.</span><span style="color:#97E1F1;">InsertAtTail</span><span style="color:#F6F6F4;">(</span><span style="color:#BF9EEE;">3</span><span style="color:#F6F6F4;">)</span></span>
<span class="line"><span style="color:#F6F6F4;">    </span></span>
<span class="line"><span style="color:#F6F6F4;">    lk.</span><span style="color:#97E1F1;">Print</span><span style="color:#F6F6F4;">() </span><span style="color:#7B7F8B;">//</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;">link</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/datastructure/link</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;">lk</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> link</span><span style="color:#999999;">.</span><span style="color:#393A34;">NewDoublyLink</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;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAtTail</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;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAtTail</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;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">InsertAtTail</span><span style="color:#999999;">(</span><span style="color:#2F798A;">3</span><span style="color:#999999;">)</span></span>
<span class="line"><span style="color:#393A34;">    </span></span>
<span class="line"><span style="color:#393A34;">    lk</span><span style="color:#999999;">.</span><span style="color:#998418;">Print</span><span style="color:#999999;">()</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">//</span></span>
<span class="line"><span style="color:#999999;">}</span></span></code></pre></div>`,179),g=[t,c,r,y,i,F,A,u,d,k,E];function h(m,v,b,f,D,B){return p(),o("div",null,g)}const T=l(e,[["render",h]]);export{C as __pageData,T as default};
