added NewLinkedList

This commit is contained in:
Acid
2026-05-02 14:52:24 -04:00
parent 77a6e0fa54
commit f53776ede0
+5
View File
@@ -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}