Skip to content

Commit e1302bd

Browse files
committed
Added some comments to exported functions to make it lint compliant.
Signed-off-by: Jobin John <[email protected]>
1 parent 33066f4 commit e1302bd

File tree

1 file changed

+7
-19
lines changed

1 file changed

+7
-19
lines changed

data-structures/linked-list/singlelinkedlist/single-linkedlist.go

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,15 @@ func newNode(val interface{}) *node {
2323
return &node{val, nil}
2424
}
2525

26+
// AddAtBeg adds a new node with given value at the beginning of the list.
2627
func (ll *singlelinkedlist) AddAtBeg(val interface{}) {
2728
n := newNode(val)
2829
n.Next = ll.Head
2930
ll.Head = n
3031
ll.length++
3132
}
3233

34+
// AddAtEnd adds a new node with given value at the end of the list.
3335
func (ll *singlelinkedlist) AddAtEnd(val int) {
3436
n := newNode(val)
3537

@@ -46,6 +48,7 @@ func (ll *singlelinkedlist) AddAtEnd(val int) {
4648
ll.length++
4749
}
4850

51+
// DelAtBeg deletes the node at the head(beginning) of the list and returns its value. Returns -1 if the list is empty.
4952
func (ll *singlelinkedlist) DelAtBeg() interface{} {
5053
if ll.Head == nil {
5154
return -1
@@ -58,6 +61,7 @@ func (ll *singlelinkedlist) DelAtBeg() interface{} {
5861
return cur.Val
5962
}
6063

64+
// DelAtEnd deletes the node at the tail(end) of the list and returns its value. Returns -1 if the list is empty.
6165
func (ll *singlelinkedlist) DelAtEnd() interface{} {
6266
if ll.Head == nil {
6367
return -1
@@ -79,10 +83,12 @@ func (ll *singlelinkedlist) DelAtEnd() interface{} {
7983

8084
}
8185

86+
// Count returns the current size of the list.
8287
func (ll *singlelinkedlist) Count() int {
8388
return ll.length
8489
}
8590

91+
// Reverse reverses the list.
8692
func (ll *singlelinkedlist) Reverse() {
8793
var prev, Next *node
8894
cur := ll.Head
@@ -97,29 +103,11 @@ func (ll *singlelinkedlist) Reverse() {
97103
ll.Head = prev
98104
}
99105

106+
// Display prints out the elements of the list.
100107
func (ll *singlelinkedlist) Display() {
101108
for cur := ll.Head; cur != nil; cur = cur.Next {
102109
fmt.Print(cur.Val, " ")
103110
}
104111

105112
fmt.Print("\n")
106113
}
107-
108-
// func main() {
109-
// ll := singlelinkedlist{}
110-
111-
// ll.addAtBeg(10)
112-
// ll.addAtEnd(20)
113-
// ll.display()
114-
// ll.addAtBeg(30)
115-
// ll.display()
116-
// ll.reverse()
117-
// ll.display()
118-
119-
// fmt.Print(ll.delAtBeg(), "\n")
120-
// ll.display()
121-
122-
// fmt.Print(ll.delAtEnd(), "\n")
123-
// ll.display()
124-
125-
// }

0 commit comments

Comments
 (0)