mirror of https://github.com/01-edu/public.git
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.
20 lines
356 B
20 lines
356 B
5 years ago
|
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
|
||
|
}
|
||
|
}
|