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.
89 lines
1.9 KiB
89 lines
1.9 KiB
5 years ago
|
package main
|
||
5 years ago
|
|
||
|
import (
|
||
|
"strconv"
|
||
5 years ago
|
|
||
|
"github.com/01-edu/z01"
|
||
5 years ago
|
|
||
|
solution "./solutions"
|
||
|
student "./student"
|
||
|
)
|
||
|
|
||
|
type Node6 = student.NodeL
|
||
|
type List6 = solution.List
|
||
|
type NodeS6 = solution.NodeL
|
||
|
type ListS6 = student.List
|
||
|
|
||
|
func listToStringStu13(l *ListS6) string {
|
||
|
var res string
|
||
|
it := l.Head
|
||
|
for it != nil {
|
||
|
switch it.Data.(type) {
|
||
|
case int:
|
||
|
res += strconv.Itoa(it.Data.(int)) + "-> "
|
||
|
case string:
|
||
|
res += it.Data.(string) + "-> "
|
||
|
}
|
||
|
it = it.Next
|
||
|
}
|
||
|
res += "<nil>"
|
||
|
return res
|
||
|
}
|
||
|
|
||
5 years ago
|
func comparFuncList6(l *List6, l1 *ListS6) {
|
||
5 years ago
|
for l.Head != nil || l1.Head != nil {
|
||
|
if (l.Head == nil && l1.Head != nil) || (l.Head != nil && l1.Head == nil) {
|
||
5 years ago
|
z01.Fatalf("\nstudent list:%s\nlist:%s\n\nListReverse() == %v instead of %v\n\n",
|
||
5 years ago
|
listToStringStu13(l1), solution.ListToString(l.Head), l1.Head, l.Head)
|
||
5 years ago
|
}
|
||
|
if l.Head.Data != l1.Head.Data {
|
||
|
z01.Fatalf("\nstudent list:%s\nlist:%s\n\nListReverse() == %v instead of %v\n\n",
|
||
5 years ago
|
listToStringStu13(l1), solution.ListToString(l.Head), l1.Head.Data, l.Head.Data)
|
||
|
}
|
||
|
l.Head = l.Head.Next
|
||
|
l1.Head = l1.Head.Next
|
||
|
}
|
||
|
}
|
||
5 years ago
|
|
||
5 years ago
|
func listPushBackTest6(l *ListS6, l1 *List6, data interface{}) {
|
||
|
n := &Node6{Data: data}
|
||
|
n1 := &NodeS6{Data: data}
|
||
|
if l.Head == nil {
|
||
|
l.Head = n
|
||
|
} else {
|
||
|
iterator := l.Head
|
||
|
for iterator.Next != nil {
|
||
|
iterator = iterator.Next
|
||
|
}
|
||
|
iterator.Next = n
|
||
|
}
|
||
|
if l1.Head == nil {
|
||
|
l1.Head = n1
|
||
|
} else {
|
||
|
iterator1 := l1.Head
|
||
|
for iterator1.Next != nil {
|
||
|
iterator1 = iterator1.Next
|
||
|
}
|
||
|
iterator1.Next = n1
|
||
|
}
|
||
|
}
|
||
|
|
||
5 years ago
|
func main() {
|
||
|
link1 := &List6{}
|
||
5 years ago
|
link2 := &ListS6{}
|
||
5 years ago
|
table := []solution.NodeTest{{
|
||
|
Data: []interface{}{"I", 1, "something", 2},
|
||
|
}}
|
||
5 years ago
|
table = solution.ElementsToTest(table)
|
||
|
for _, arg := range table {
|
||
5 years ago
|
for _, item := range arg.Data {
|
||
|
listPushBackTest6(link2, link1, item)
|
||
5 years ago
|
}
|
||
|
student.ListReverse(link2)
|
||
5 years ago
|
solution.ListReverse(link1)
|
||
|
comparFuncList6(link1, link2)
|
||
|
link1 = &List6{}
|
||
5 years ago
|
link2 = &ListS6{}
|
||
|
}
|
||
|
}
|