You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

19 lines
356 B

package solutions
//removes all elements that are equal to the data_ref
func ListRemoveIf(l *List, data_ref interface{}) {
temp := l.Head
prev := l.Head
for temp != nil && temp.Data == data_ref {
l.Head = temp.Next
temp = l.Head
}
for temp != nil {
if temp.Data != data_ref {
prev = temp
}
prev.Next = temp.Next
temp = prev.Next
}
}