From da189762414b80e6b6c4e09469a7c5a59eebd756 Mon Sep 17 00:00:00 2001
From: myyrakle <sssang97@naver.com>
Date: Wed, 4 Oct 2023 01:31:19 +0900
Subject: [PATCH] [#16] add: LinkedList::Front

---
 linked_list.go | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/linked_list.go b/linked_list.go
index a61aa41..cba07d0 100644
--- a/linked_list.go
+++ b/linked_list.go
@@ -139,6 +139,16 @@ func (list *LinkedList[T]) PopFront() Option[T] {
 	return Some[T](value)
 }
 
+// Provides a reference to the front element, or None if the list is empty.
+// This operation should compute in O(1) time.
+func (list *LinkedList[T]) Front() Option[*T] {
+	if list.head == nil {
+		return None[*T]()
+	}
+
+	return Some[*T](&list.head.value)
+}
+
 // into_iter
 func (list *LinkedList[T]) IntoIter() Iterator[T] {
 	return &LinkedListIter[T]{