Help us shape the future of Go! Take the 2026 Go Developer Survey

datastructure

package
v2.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 17, 2022 License: MIT Imports: 3 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DoublyLink[T any] struct {
	Head *datastructure.LinkNode[T]
	// contains filtered or unexported fields
}

DoublyLink is a linked list. Whose node has a generic Value, Pre pointer points to a previous node of the link, Next pointer points to a next node of the link.

func NewDoublyLink[T any]() *DoublyLink[T]

NewDoublyLink return *DoublyLink instance

func (*DoublyLink[T]) Clear

func (link *DoublyLink[T]) Clear()

Clear checks if link is empty or not

func (*DoublyLink[T]) DeleteAt

func (link *DoublyLink[T]) DeleteAt(index int) error

DeleteAt delete value in doubly linklist at index

func (*DoublyLink[T]) DeleteAtHead

func (link *DoublyLink[T]) DeleteAtHead() error

DeleteAtHead delete value in doubly linklist at head index

func (*DoublyLink[T]) DeleteAtTail

func (link *DoublyLink[T]) DeleteAtTail() error

DeleteAtTail delete value in doubly linklist at tail index

func (*DoublyLink[T]) GetMiddleNode

func (link *DoublyLink[T]) GetMiddleNode() *datastructure.LinkNode[T]

GetMiddleNode return node at middle index of linked list

func (*DoublyLink[T]) InsertAt

func (link *DoublyLink[T]) InsertAt(index int, value T) error

InsertAt insert value into doubly linklist at index

func (*DoublyLink[T]) InsertAtHead

func (link *DoublyLink[T]) InsertAtHead(value T)

InsertAtHead insert value into doubly linklist at head index

func (*DoublyLink[T]) InsertAtTail

func (link *DoublyLink[T]) InsertAtTail(value T)

InsertAtTail insert value into doubly linklist at tail index

func (*DoublyLink[T]) IsEmpty

func (link *DoublyLink[T]) IsEmpty() bool

IsEmpty checks if link is empty or not

func (*DoublyLink[T]) Print

func (link *DoublyLink[T]) Print()

Print all nodes info of a linked list

func (*DoublyLink[T]) Reverse

func (link *DoublyLink[T]) Reverse()

Reverse the linked list

func (*DoublyLink[T]) Size

func (link *DoublyLink[T]) Size() int

Size return the count of doubly linked list

func (*DoublyLink[T]) Values

func (link *DoublyLink[T]) Values() []T

Values return slice of all doubly linklist node value

type SinglyLink[T any] struct {
	Head *datastructure.LinkNode[T]
	// contains filtered or unexported fields
}

SinglyLink is a linked list. Whose node has a Value generics and Next pointer points to a next node of the link.

func NewSinglyLink[T any]() *SinglyLink[T]

NewSinglyLink return *SinglyLink instance

func (*SinglyLink[T]) Clear

func (link *SinglyLink[T]) Clear()

Clear checks if link is empty or not

func (*SinglyLink[T]) DeleteAt

func (link *SinglyLink[T]) DeleteAt(index int) error

DeleteAt delete value in singly linklist at index

func (*SinglyLink[T]) DeleteAtHead

func (link *SinglyLink[T]) DeleteAtHead() error

DeleteAtHead delete value in singly linklist at head index

func (*SinglyLink[T]) DeleteAtTail

func (link *SinglyLink[T]) DeleteAtTail() error

DeleteAtTail delete value in singly linklist at tail index

func (*SinglyLink[T]) GetMiddleNode

func (link *SinglyLink[T]) GetMiddleNode() *datastructure.LinkNode[T]

GetMiddleNode return node at middle index of linked list

func (*SinglyLink[T]) InsertAt

func (link *SinglyLink[T]) InsertAt(index int, value T) error

InsertAt insert value into singly linklist at index

func (*SinglyLink[T]) InsertAtHead

func (link *SinglyLink[T]) InsertAtHead(value T)

InsertAtHead insert value into singly linklist at head index

func (*SinglyLink[T]) InsertAtTail

func (link *SinglyLink[T]) InsertAtTail(value T)

InsertAtTail insert value into singly linklist at tail index

func (*SinglyLink[T]) IsEmpty

func (link *SinglyLink[T]) IsEmpty() bool

IsEmpty checks if link is empty or not

func (*SinglyLink[T]) Print

func (link *SinglyLink[T]) Print()

Print all nodes info of a linked list

func (*SinglyLink[T]) Reverse

func (link *SinglyLink[T]) Reverse()

Reverse the linked list

func (*SinglyLink[T]) Size

func (link *SinglyLink[T]) Size() int

Size return the count of singly linked list

func (*SinglyLink[T]) Values

func (link *SinglyLink[T]) Values() []T

Values return slice of all singly linklist node value

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL