package Ġcom . ds . implementation . linked list . sing ly Ċ Ċ import Ġcom . ds . implementation . linked list . common . Node ĊĊ Ċ fun Ġmain () Ġ{ ĊĠĠĠ Ġval Ġnode 1 Ġ= ĠListNode ( 1 ) ĊĠĠĠ Ġval Ġnode 2 Ġ= ĠListNode ( 2 ) ĊĠĠĠ Ġval Ġnode 3 Ġ= ĠListNode ( 3 ) ĊĠĠĠ Ġval Ġnode 4 Ġ= ĠListNode ( 4 ) ĊĠĠĠ Ġval Ġnode 5 Ġ= ĠListNode ( 5 ) ĊĠĠĠ Ġnode 4 . next Ġ= Ġnode 5 ĊĠĠĠ Ġnode 3 . next Ġ= Ġnode 4 ĊĠĠĠ Ġnode 2 . next Ġ= Ġnode 3 ĊĠĠĠ Ġnode 1 . next Ġ= Ġnode 2 ĊĊĠĠĠ Ġval Ġimpl Ġ= ĠLinkedList Impl ( node 1 ) ĊĠĠĠ Ġimpl . print () ĊĠĠĠ Ġprintln (" Search ĠResult Ġ"+ impl . search By Value ( 3 )) ĊĠĠĠ Ġprintln (" Search ĠResult Ġ"+ impl . search By Value ( 3 3 )) ĊĠĠĠ Ġprintln (" Search ĠResult Ġ"+ impl . search By Node ( Node ( 5 ))) ĊĠĠĠ Ġprintln (" Search ĠResult Ġ"+ impl . search By Node ( Node ( 1 1 ))) ĊĠĠĠ Ġimpl . print (" ======== Before ĠInsert ion ============ =") ĊĠĠĠ Ġimpl . insert ( 0 ) ĊĠĠĠ Ġimpl . print (" ======== Insertion Ġ 0 ============ =") ĊĠĠĠ Ġimpl . insert After Node ( 1 1 , ĠListNode ( 1 )) ĊĠĠĠ Ġimpl . print (" ======== Insertion Ġ 1 1 ĠAt fer Ġposition Ġ 1 ============ =") ĊĠĠĠ Ġimpl . insert At Position ( 2 2 , Ġ 3 ) ĊĠĠĠ Ġimpl . print (" ======== Insertion Ġ 2 2 ĠAt Ġposition Ġ 3 ============ =") ĊĠĠĠ Ġimpl . insert At Position ( 2 2 2 , Ġ 0 ) ĊĠĠĠ Ġimpl . print (" ======== Insertion Ġ 2 2 2 ĠAt Ġposition Ġ 0 ============ =") ĊĠĠĠ Ġimpl . insert At Position ( 5 5 5 , Ġ 8 ) ĊĠĠĠ Ġimpl . print (" ======== Insertion Ġ 5 5 5 ĠAt Ġposition Ġ 8 ============ =") ĊĠĠĠ Ġimpl . insert At Position ( 9 9 9 9 , Ġ 1 0 ) ĊĠĠĠ Ġimpl . print (" ======== Insertion Ġ 9 9 9 9 ĠAt Ġposition Ġ 1 0 ============ =") ĊĠĠĠ Ġimpl . delete At Position ( 0 ) ĊĠĠĠ Ġimpl . delete () ĊĠĠĠ Ġimpl . delete At Position ( 8 ) ĊĠĠĠ Ġimpl . print (" ======== Delete Ġfirst Ġtwo Ġvalues Ġand Ġlast ============ =") ĊĠĠĠ Ġimpl . delete After Node ( ListNode ( 1 1 )) ĊĠĠĠ Ġimpl . print (" ======== Delete Ġnode Ġafter Ġ 1 1 ============ =") ĊĠĠĠ Ġimpl . delete At Position ( 1 ) ĊĠĠĠ Ġimpl . print (" ======== Delete Ġnode Ġat Ġposition Ġ 1 ============ =") ĊĠĠĠ Ġimpl . delete At Position ( 4 ) ĊĠĠĠ Ġimpl . print (" ======== Delete Ġnode Ġat Ġposition Ġ 4 ============ =") ĊĠĠĠ Ġimpl . node AtIndex ( 2 )?. let Ġ{ Ġprintln (" Node Ġat Ġindex Ġ 2 Ġ-> Ġ| ${ it . value }| ") Ġ} ĊĠĠĠ Ġimpl . node AtIndex ( 2 2 )?. let Ġ{ Ġprintln (" Node Ġat Ġindex Ġ 2 Ġ-> Ġ| ${ it . value }| ") Ġ} ?: println (" No Ġnode Ġfound Ġat ĠIndex Ġ 2 2 ") ĊĠĠĠ Ġimpl . reverse () ĊĠĠĠ Ġimpl . print (" Linked Ġlist Ġreversed ") ĊĠĠĠ Ġimpl . pal indrome () Ċ Ċ }