diff --git a/datastructure/node.go b/datastructure/node.go new file mode 100644 index 0000000..bf89e31 --- /dev/null +++ b/datastructure/node.go @@ -0,0 +1,13 @@ +package datastructure + +// LinkNode is a linkedlist node, which have a value and Pre points to previous node, Next points to a next node of the link. +type LinkNode[T any] struct { + Value T + Pre *LinkNode[T] + Next *LinkNode[T] +} + +func NewLinkNode[T any](value T) *LinkNode[T] { + return &LinkNode[T]{value, nil, nil} +} +