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.
33 lines
471 B
33 lines
471 B
package main |
|
|
|
type NodeL struct { |
|
Data interface{} |
|
Next *NodeL |
|
} |
|
|
|
type List struct { |
|
Head *NodeL |
|
Tail *NodeL |
|
} |
|
|
|
//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 |
|
} |
|
} |
|
|
|
func main() { |
|
}
|
|
|