forked from root/public
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
355 B
20 lines
355 B
![]()
4 years ago
|
package correct
|
||
![]()
4 years ago
|
|
||
![]()
4 years ago
|
// removes all elements that are equal to the data_ref
|
||
![]()
4 years ago
|
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
|
||
|
}
|
||
|
}
|