From 8bdbaa9455bd0cf0507cc4b3a70c192518a21c65 Mon Sep 17 00:00:00 2001 From: surdeus Date: Sun, 12 Nov 2023 12:33:46 +0300 Subject: [PATCH] Rebranding. --- cmd/ll/main.go | 2 +- cmd/sparse/main.go | 16 ++++++------- go.mod | 2 +- lists/main.go | 5 ++--- lists/single.go | 56 ++++++++++++++++++++++------------------------ maps/main.go | 6 ++--- stacks/main.go | 2 +- 7 files changed, 42 insertions(+), 47 deletions(-) diff --git a/cmd/ll/main.go b/cmd/ll/main.go index ec6854f..dea05fe 100644 --- a/cmd/ll/main.go +++ b/cmd/ll/main.go @@ -2,7 +2,7 @@ package main import ( "fmt" - "github.com/reklesio/gods/lists" + "github.com/omnipunk/gods/lists" "strings" ) diff --git a/cmd/sparse/main.go b/cmd/sparse/main.go index 836aa0f..f242742 100644 --- a/cmd/sparse/main.go +++ b/cmd/sparse/main.go @@ -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()) diff --git a/go.mod b/go.mod index 866f599..1e270da 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/reklesio/gods +module github.com/omnipunk/gods go 1.21 diff --git a/lists/main.go b/lists/main.go index e160419..ceb48b2 100644 --- a/lists/main.go +++ b/lists/main.go @@ -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]) } - diff --git a/lists/single.go b/lists/single.go index 8599b98..4984900 100644 --- a/lists/single.go +++ b/lists/single.go @@ -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,20 +58,19 @@ 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 } - + return p } @@ -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 } @@ -109,12 +108,12 @@ func (ll *sLinkedList[V]) InsA(index int, values ...V) { ll.Add(values...) return } - + el := ll.getEl(index) for _, v := range values { el.next = &sElement[V]{ value: v, - next: el.next, + next: el.next, } el = el.next } @@ -125,10 +124,10 @@ func (ll *sLinkedList[V]) Swap(i1, i2 int) { if i1 == i2 { return } - + el1 := ll.getEl(i1) el2 := ll.getEl(i2) - + el1.value, el2.value = el2.value, el1.value } @@ -140,21 +139,21 @@ func (ll *sLinkedList[V]) Del(i int) { ll.ln-- 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 } - + ll.ln-- } 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,11 +171,11 @@ 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 - + ll.ln++ if ll.ln == 1 { ll.last = ll.before.next @@ -195,16 +194,16 @@ func (ll *sLinkedList[V]) gappend(v V) { ll.Push(v) return } - + last := &sElement[V]{ - next: nil, + next: nil, value: v, } - + lastBuf := ll.last lastBuf.next = last ll.last = last - + ll.ln++ } @@ -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, }) } - diff --git a/maps/main.go b/maps/main.go index 3c51393..7b4bed1 100644 --- a/maps/main.go +++ b/maps/main.go @@ -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 } - - diff --git a/stacks/main.go b/stacks/main.go index 766b995..80e1442 100644 --- a/stacks/main.go +++ b/stacks/main.go @@ -1,7 +1,7 @@ package stacks import ( - "github.com/reklesio/gods" + "github.com/omnipunk/gods" ) type Stack[V any] interface {