Rebranding.

This commit is contained in:
Andrey Parhomenko 2023-11-12 12:33:46 +03:00
parent 1c5fcf1da1
commit 8bdbaa9455
7 changed files with 42 additions and 47 deletions

View file

@ -2,7 +2,7 @@ package main
import ( import (
"fmt" "fmt"
"github.com/reklesio/gods/lists" "github.com/omnipunk/gods/lists"
"strings" "strings"
) )

View file

@ -1,17 +1,17 @@
package main package main
import ( import (
"github.com/reklesio/gods/maps" "github.com/omnipunk/gods/maps"
"fmt" "fmt"
) )
func main() { func main() {
arr := maps.NewSparse[float32, string]("default", map[float32] string { arr := maps.NewSparse[float32, string]("default", map[float32]string{
5: "something at 5", 5: "something at 5",
12: "new shit 12", 12: "new shit 12",
50: "die 50", 50: "die 50",
}) })
for i:=0 ; i<=50 ; i++ { for i := 0; i <= 50; i++ {
fmt.Println(arr.Get(float32(i))) fmt.Println(arr.Get(float32(i)))
} }
fmt.Println(arr.Size()) fmt.Println(arr.Size())
@ -19,7 +19,7 @@ func main() {
arr.Del(5) arr.Del(5)
arr.Del(12) arr.Del(12)
arr.Del(50) arr.Del(50)
for i:=0 ; i<=50 ; i++ { for i := 0; i <= 50; i++ {
fmt.Println(arr.Get(float32(i))) fmt.Println(arr.Get(float32(i)))
} }
fmt.Println(arr.Size()) fmt.Println(arr.Size())

2
go.mod
View file

@ -1,4 +1,4 @@
module github.com/reklesio/gods module github.com/omnipunk/gods
go 1.21 go 1.21

View file

@ -1,8 +1,8 @@
package lists package lists
import ( import (
"github.com/reklesio/gods" "github.com/omnipunk/gods"
"github.com/reklesio/gods/stacks" "github.com/omnipunk/gods/stacks"
) )
// The interface all the lists must implement. // The interface all the lists must implement.
@ -38,4 +38,3 @@ type List[V any] interface {
// and sorts the list corresponding to it. // and sorts the list corresponding to it.
Sort(gods.LessFunc[V]) Sort(gods.LessFunc[V])
} }

View file

@ -1,7 +1,7 @@
package lists package lists
import ( import (
"github.com/reklesio/gods" "github.com/omnipunk/gods"
"sort" "sort"
"fmt" "fmt"
) )
@ -24,15 +24,15 @@ type sLinkedList[V any] struct {
// The type represents element of the linked list. // The type represents element of the linked list.
type sElement[V any] struct { type sElement[V any] struct {
next *sElement[V] next *sElement[V]
value V value V
} }
func newSingly[V any](values ...V) *sLinkedList[V] { func newSingly[V any](values ...V) *sLinkedList[V] {
ret := &sLinkedList[V]{ ret := &sLinkedList[V]{
before: &sElement[V]{}, before: &sElement[V]{},
last: nil, last: nil,
ln: 0, ln: 0,
} }
ret.Add(values...) ret.Add(values...)
@ -58,17 +58,16 @@ func (ll *sLinkedList[V]) Clear() {
} }
func (ll *sLinkedList[V]) Len() int { func (ll *sLinkedList[V]) Len() int {
return ll.ln return ll.ln
} }
// Get the index-indexed element itself. // Get the index-indexed element itself.
func (ll *sLinkedList[V]) getEl(index int) *sElement[V] { func (ll *sLinkedList[V]) getEl(index int) *sElement[V] {
if ll.ln <= index || index < 0 { if ll.ln <= index || index < 0 {
panic(gods.IndexRangeErr) panic(gods.IndexRangeErr)
} }
p := ll.before p := ll.before
for i := 0 ; i <= index ; i++ { for i := 0; i <= index; i++ {
p = p.next p = p.next
} }
@ -93,11 +92,11 @@ func (ll *sLinkedList[V]) InsB(index int, values ...V) {
return return
} }
el := ll.getEl(index-1) el := ll.getEl(index - 1)
for _, v := range values { for _, v := range values {
el.next = &sElement[V]{ el.next = &sElement[V]{
value: v, value: v,
next: el.next, next: el.next,
} }
el = el.next el = el.next
} }
@ -114,7 +113,7 @@ func (ll *sLinkedList[V]) InsA(index int, values ...V) {
for _, v := range values { for _, v := range values {
el.next = &sElement[V]{ el.next = &sElement[V]{
value: v, value: v,
next: el.next, next: el.next,
} }
el = el.next el = el.next
} }
@ -141,11 +140,11 @@ func (ll *sLinkedList[V]) Del(i int) {
return return
} }
el1 := ll.getEl(i-1) el1 := ll.getEl(i - 1)
if i == ll.ln - 1 { if i == ll.ln-1 {
el1.next = nil el1.next = nil
} else { } else {
el2 := ll.getEl(i+1) el2 := ll.getEl(i + 1)
el1.next = el2 el1.next = el2
} }
@ -154,7 +153,7 @@ func (ll *sLinkedList[V]) Del(i int) {
func (ll *sLinkedList[V]) Put(values ...V) { func (ll *sLinkedList[V]) Put(values ...V) {
ln := len(values) ln := len(values)
for i:=ln-1 ; i >= 0 ; i-- { for i := ln - 1; i >= 0; i-- {
ll.Push(values[i]) ll.Push(values[i])
} }
} }
@ -172,7 +171,7 @@ func (ll *sLinkedList[V]) Pop() V {
func (ll *sLinkedList[V]) Push(v V) { func (ll *sLinkedList[V]) Push(v V) {
prevNext := ll.before.next prevNext := ll.before.next
nextNext := &sElement[V]{ nextNext := &sElement[V]{
next: prevNext, next: prevNext,
value: v, value: v,
} }
ll.before.next = nextNext ll.before.next = nextNext
@ -197,7 +196,7 @@ func (ll *sLinkedList[V]) gappend(v V) {
} }
last := &sElement[V]{ last := &sElement[V]{
next: nil, next: nil,
value: v, value: v,
} }
@ -232,7 +231,7 @@ func (ll *sLinkedList[V]) Last() *sElement[V] {
// Returns a channel with values ordered as in list. // Returns a channel with values ordered as in list.
func (ll *sLinkedList[V]) Chan() chan V { func (ll *sLinkedList[V]) Chan() chan V {
chn := make(chan V) chn := make(chan V)
go func(){ go func() {
el := ll.before el := ll.before
for el.next != nil { for el.next != nil {
el = el.next el = el.next
@ -264,7 +263,6 @@ func (ll *sLinkedList[V]) String() string {
func (ll *sLinkedList[V]) Sort(fn gods.LessFunc[V]) { func (ll *sLinkedList[V]) Sort(fn gods.LessFunc[V]) {
sort.Sort(gods.CustomSort[V]{ sort.Sort(gods.CustomSort[V]{
CustomSorter: ll, CustomSorter: ll,
LessFunc: fn, LessFunc: fn,
}) })
} }

View file

@ -2,7 +2,7 @@ package maps
import ( import (
"fmt" "fmt"
"github.com/reklesio/gods" "github.com/omnipunk/gods"
) )
// Generic map interface for all the maps. // 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 { 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. // 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 return ret
} }

View file

@ -1,7 +1,7 @@
package stacks package stacks
import ( import (
"github.com/reklesio/gods" "github.com/omnipunk/gods"
) )
type Stack[V any] interface { type Stack[V any] interface {