Rebranding.
This commit is contained in:
parent
1c5fcf1da1
commit
8bdbaa9455
7 changed files with 42 additions and 47 deletions
|
@ -2,7 +2,7 @@ package main
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/reklesio/gods/lists"
|
||||
"github.com/omnipunk/gods/lists"
|
||||
"strings"
|
||||
)
|
||||
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/reklesio/gods/maps"
|
||||
"github.com/omnipunk/gods/maps"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
arr := maps.NewSparse[float32, string]("default", map[float32] string {
|
||||
5: "something at 5",
|
||||
12: "new shit 12",
|
||||
50: "die 50",
|
||||
})
|
||||
for i:=0 ; i<=50 ; i++ {
|
||||
arr := maps.NewSparse[float32, string]("default", map[float32]string{
|
||||
5: "something at 5",
|
||||
12: "new shit 12",
|
||||
50: "die 50",
|
||||
})
|
||||
for i := 0; i <= 50; i++ {
|
||||
fmt.Println(arr.Get(float32(i)))
|
||||
}
|
||||
fmt.Println(arr.Size())
|
||||
|
@ -19,7 +19,7 @@ func main() {
|
|||
arr.Del(5)
|
||||
arr.Del(12)
|
||||
arr.Del(50)
|
||||
for i:=0 ; i<=50 ; i++ {
|
||||
for i := 0; i <= 50; i++ {
|
||||
fmt.Println(arr.Get(float32(i)))
|
||||
}
|
||||
fmt.Println(arr.Size())
|
||||
|
|
2
go.mod
2
go.mod
|
@ -1,4 +1,4 @@
|
|||
module github.com/reklesio/gods
|
||||
module github.com/omnipunk/gods
|
||||
|
||||
go 1.21
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package lists
|
||||
|
||||
import (
|
||||
"github.com/reklesio/gods"
|
||||
"github.com/reklesio/gods/stacks"
|
||||
"github.com/omnipunk/gods"
|
||||
"github.com/omnipunk/gods/stacks"
|
||||
)
|
||||
|
||||
// The interface all the lists must implement.
|
||||
|
@ -38,4 +38,3 @@ type List[V any] interface {
|
|||
// and sorts the list corresponding to it.
|
||||
Sort(gods.LessFunc[V])
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package lists
|
||||
|
||||
import (
|
||||
"github.com/reklesio/gods"
|
||||
"github.com/omnipunk/gods"
|
||||
"sort"
|
||||
"fmt"
|
||||
)
|
||||
|
@ -24,15 +24,15 @@ type sLinkedList[V any] struct {
|
|||
|
||||
// The type represents element of the linked list.
|
||||
type sElement[V any] struct {
|
||||
next *sElement[V]
|
||||
next *sElement[V]
|
||||
value V
|
||||
}
|
||||
|
||||
func newSingly[V any](values ...V) *sLinkedList[V] {
|
||||
ret := &sLinkedList[V]{
|
||||
before: &sElement[V]{},
|
||||
last: nil,
|
||||
ln: 0,
|
||||
last: nil,
|
||||
ln: 0,
|
||||
}
|
||||
|
||||
ret.Add(values...)
|
||||
|
@ -58,17 +58,16 @@ func (ll *sLinkedList[V]) Clear() {
|
|||
}
|
||||
|
||||
func (ll *sLinkedList[V]) Len() int {
|
||||
return ll.ln
|
||||
return ll.ln
|
||||
}
|
||||
|
||||
|
||||
// Get the index-indexed element itself.
|
||||
func (ll *sLinkedList[V]) getEl(index int) *sElement[V] {
|
||||
if ll.ln <= index || index < 0 {
|
||||
panic(gods.IndexRangeErr)
|
||||
}
|
||||
p := ll.before
|
||||
for i := 0 ; i <= index ; i++ {
|
||||
for i := 0; i <= index; i++ {
|
||||
p = p.next
|
||||
}
|
||||
|
||||
|
@ -93,11 +92,11 @@ func (ll *sLinkedList[V]) InsB(index int, values ...V) {
|
|||
return
|
||||
}
|
||||
|
||||
el := ll.getEl(index-1)
|
||||
el := ll.getEl(index - 1)
|
||||
for _, v := range values {
|
||||
el.next = &sElement[V]{
|
||||
value: v,
|
||||
next: el.next,
|
||||
next: el.next,
|
||||
}
|
||||
el = el.next
|
||||
}
|
||||
|
@ -114,7 +113,7 @@ func (ll *sLinkedList[V]) InsA(index int, values ...V) {
|
|||
for _, v := range values {
|
||||
el.next = &sElement[V]{
|
||||
value: v,
|
||||
next: el.next,
|
||||
next: el.next,
|
||||
}
|
||||
el = el.next
|
||||
}
|
||||
|
@ -141,11 +140,11 @@ func (ll *sLinkedList[V]) Del(i int) {
|
|||
return
|
||||
}
|
||||
|
||||
el1 := ll.getEl(i-1)
|
||||
if i == ll.ln - 1 {
|
||||
el1 := ll.getEl(i - 1)
|
||||
if i == ll.ln-1 {
|
||||
el1.next = nil
|
||||
} else {
|
||||
el2 := ll.getEl(i+1)
|
||||
el2 := ll.getEl(i + 1)
|
||||
el1.next = el2
|
||||
}
|
||||
|
||||
|
@ -154,7 +153,7 @@ func (ll *sLinkedList[V]) Del(i int) {
|
|||
|
||||
func (ll *sLinkedList[V]) Put(values ...V) {
|
||||
ln := len(values)
|
||||
for i:=ln-1 ; i >= 0 ; i-- {
|
||||
for i := ln - 1; i >= 0; i-- {
|
||||
ll.Push(values[i])
|
||||
}
|
||||
}
|
||||
|
@ -172,7 +171,7 @@ func (ll *sLinkedList[V]) Pop() V {
|
|||
func (ll *sLinkedList[V]) Push(v V) {
|
||||
prevNext := ll.before.next
|
||||
nextNext := &sElement[V]{
|
||||
next: prevNext,
|
||||
next: prevNext,
|
||||
value: v,
|
||||
}
|
||||
ll.before.next = nextNext
|
||||
|
@ -197,7 +196,7 @@ func (ll *sLinkedList[V]) gappend(v V) {
|
|||
}
|
||||
|
||||
last := &sElement[V]{
|
||||
next: nil,
|
||||
next: nil,
|
||||
value: v,
|
||||
}
|
||||
|
||||
|
@ -232,7 +231,7 @@ func (ll *sLinkedList[V]) Last() *sElement[V] {
|
|||
// Returns a channel with values ordered as in list.
|
||||
func (ll *sLinkedList[V]) Chan() chan V {
|
||||
chn := make(chan V)
|
||||
go func(){
|
||||
go func() {
|
||||
el := ll.before
|
||||
for el.next != nil {
|
||||
el = el.next
|
||||
|
@ -264,7 +263,6 @@ func (ll *sLinkedList[V]) String() string {
|
|||
func (ll *sLinkedList[V]) Sort(fn gods.LessFunc[V]) {
|
||||
sort.Sort(gods.CustomSort[V]{
|
||||
CustomSorter: ll,
|
||||
LessFunc: fn,
|
||||
LessFunc: fn,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ package maps
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/reklesio/gods"
|
||||
"github.com/omnipunk/gods"
|
||||
)
|
||||
|
||||
// Generic map interface for all the maps.
|
||||
|
@ -48,7 +48,7 @@ type Map[K comparable, V any] interface {
|
|||
}*/
|
||||
}
|
||||
type lMap[K comparable, V any] struct {
|
||||
store map[K] V
|
||||
store map[K]V
|
||||
}
|
||||
|
||||
// Returns new basic map with the builtin Go type down there.
|
||||
|
@ -140,5 +140,3 @@ func (m *lMap[K, V]) KeyChan() chan K {
|
|||
}()
|
||||
return ret
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package stacks
|
||||
|
||||
import (
|
||||
"github.com/reklesio/gods"
|
||||
"github.com/omnipunk/gods"
|
||||
)
|
||||
|
||||
type Stack[V any] interface {
|
||||
|
|
Loading…
Reference in a new issue