array and linked-list: at operator
This commit is contained in:
@@ -137,3 +137,16 @@ func (ls *LinkedList) HasValue(value any) (found bool) {
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (ls *LinkedList) Index(value any) (index int64) {
|
||||
index = -1
|
||||
i := int64(0)
|
||||
for node := ls.FirstNode(); node != nil; node = node.Next() {
|
||||
if kern.Equal(node.Data(), value) {
|
||||
index = i
|
||||
break
|
||||
}
|
||||
i++
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user