1
0
mirror of https://github.com/charlienet/go-mixed.git synced 2025-07-18 08:32:40 +08:00

linked list

This commit is contained in:
2022-06-07 10:58:21 +08:00
parent 31c9b4d3e6
commit 96d24dea42
3 changed files with 222 additions and 10 deletions

View File

@ -0,0 +1,36 @@
package collections
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestNewLinkdList(t *testing.T) {
l := NewLinkedList(1, 2, 3, 4, 5)
l.Append(55)
t.Log(l)
t.Log(NewLinkedList("a", "b", "c", "d"))
}
func TestLinkedListSize(t *testing.T) {
ll := NewLinkedList[int]()
ll.Append(5)
ll.Append(6)
ll.Append(7)
assert.Equal(t, 3, ll.Size())
ll.Prepend(8, 9, 10)
assert.Equal(t, 6, ll.Size())
ll.RemoveAt(1)
assert.Equal(t, 5, ll.Size())
t.Log(ll)
ll.RemoveAt(ll.Size() - 1)
t.Log(ll)
}