Giter VIP home page Giter VIP logo

basemax / onewaylinkedlistgo Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 21 KB

This is a simple implementation of a one-way linked-list in Go. The one way linkedlist is a data structure that is made up of nodes. Each node contains a value and a pointer to the next node. The head of the list is the first node in the list. The tail of the list is the last node in the list. The tail of the list points to nil.

License: GNU General Public License v3.0

Go 100.00%
go golang linkedlist linkedlist-delete linkedlist-implementation linkedlist-insert linkedlist-reverse linkedlists linkedlists-using-class oneway-data-binding

onewaylinkedlistgo's Introduction

One-Way Linked-List Go

This is a simple implementation of a one-way linked-list in Go. The one way linkedlist is a data structure that is made up of nodes. Each node contains a value and a pointer to the next node. The head of the list is the first node in the list. The tail of the list is the last node in the list. The tail of the list points to nil.

Structure

Types:

type Node struct {
	Value interface{}
	Next  *Node
}

type List struct {
	Head *Node
}

Methods:

// Create, O(1)
func (list *List) Create(value interface{})

// InsertBegin, O(1)
func (list *List) InsertBegin(value interface{})

// InsertEnd, O(n)
func (list *List) InsertEnd(value interface{})

// InsertAfter, O(n)
func (list *List) InsertAfter(value interface{}, after interface{})

// InsertBefore, O(n)
func (list *List) InsertBefore(value interface{}, before interface{})

// DeleteBegin, O(1)
func (list *List) DeleteBegin()

// DeleteEnd, O(n)
func (list *List) DeleteEnd()

// DeleteValue, O(n)
func (list *List) DeleteValue(value interface{})

// DeleteAfterValue, O(n)
func (list *List) DeleteAfterValue(value interface{})

// DeleteBeforeValue, O(n)
func (list *List) DeleteBeforeValue(value interface{})

// DeleteIndex, O(n)
func (list *List) DeleteIndex(index int)

// DeleteAfterIndex, O(n)
func (list *List) DeleteAfterIndex(index int)

// DeleteBeforeIndex, O(n)
func (list *List) DeleteBeforeIndex(index int)

// Search, O(n)
func (list *List) Search(value interface{}) bool

// Print, O(n)
func (list *List) Print()

// ToString, O(n)
func (list *List) ToString() string

© Copyright 2022, Max Base

onewaylinkedlistgo's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.