added NewLinkedList
This commit is contained in:
@@ -16,6 +16,11 @@ type LinkedList[T any] struct {
|
|||||||
length uint8
|
length uint8
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewLinkedList() -> Creates a linked list NewLinkedList[Type]()
|
||||||
|
func NewLinkedList[T any]() *LinkedList[T] {
|
||||||
|
return &LinkedList[T]{}
|
||||||
|
}
|
||||||
|
|
||||||
// InsertAtHead() -> inserts data and sets it as head
|
// InsertAtHead() -> inserts data and sets it as head
|
||||||
func (ll *LinkedList[T]) InsertAtHead(data T) {
|
func (ll *LinkedList[T]) InsertAtHead(data T) {
|
||||||
newNode := &Node[T]{data: data}
|
newNode := &Node[T]{data: data}
|
||||||
|
|||||||
Reference in New Issue
Block a user