From 1ba27792617b81d3fef4ec2276aed3a7d0cdefcd Mon Sep 17 00:00:00 2001 From: surdeus Date: Sun, 19 May 2024 23:19:55 +0500 Subject: [PATCH] the last grand rename --- btest.sh | 3 +++ cmd/ll/main.go | 2 +- cmd/sparse/main.go | 2 +- go.mod | 4 ++-- {iterx => iters}/chan.go | 2 +- {iterx => iters}/iter.go | 2 +- {iterx => iters}/misc.go | 2 +- lists/main.go | 4 ++-- lists/single.go | 2 +- maps/main.go | 2 +- ranges/range.go | 39 ++++++++++++++++++++------------------- stacks/main.go | 2 +- 12 files changed, 35 insertions(+), 31 deletions(-) create mode 100755 btest.sh rename {iterx => iters}/chan.go (97%) rename {iterx => iters}/iter.go (96%) rename {iterx => iters}/misc.go (89%) diff --git a/btest.sh b/btest.sh new file mode 100755 index 0000000..8b8a631 --- /dev/null +++ b/btest.sh @@ -0,0 +1,3 @@ +#!/bin/sh +# +go build -o ./exe/ ./cmd/* diff --git a/cmd/ll/main.go b/cmd/ll/main.go index 2dcd075..d5a1520 100644 --- a/cmd/ll/main.go +++ b/cmd/ll/main.go @@ -2,7 +2,7 @@ package main import ( "fmt" - "vultras.su/core/gods/lists" + "surdeus.su/core/gods/lists" "strings" ) diff --git a/cmd/sparse/main.go b/cmd/sparse/main.go index cfcf349..78d2d4c 100644 --- a/cmd/sparse/main.go +++ b/cmd/sparse/main.go @@ -1,7 +1,7 @@ package main import ( - "vultras.su/core/gods/maps" + "surdeus.su/core/gods/maps" "fmt" ) diff --git a/go.mod b/go.mod index 92fcd79..fc94b44 100644 --- a/go.mod +++ b/go.mod @@ -1,5 +1,5 @@ -module vultras.su/core/gods +module surdeus.su/core/gods go 1.21 -require golang.org/x/exp v0.0.0-20230213192124-5e25df0256eb // indirect +require golang.org/x/exp v0.0.0-20230213192124-5e25df0256eb diff --git a/iterx/chan.go b/iters/chan.go similarity index 97% rename from iterx/chan.go rename to iters/chan.go index 679d31f..0b4bbbc 100644 --- a/iterx/chan.go +++ b/iters/chan.go @@ -1,4 +1,4 @@ -package iterx +package iters // The type describes pair of key and value. type Pair[K any, V any] struct { diff --git a/iterx/iter.go b/iters/iter.go similarity index 96% rename from iterx/iter.go rename to iters/iter.go index 53ddbc7..41e36d5 100644 --- a/iterx/iter.go +++ b/iters/iter.go @@ -1,4 +1,4 @@ -package iterx +package iters // Implementing the interface lets us iterate through the // the data by lightweight channels. diff --git a/iterx/misc.go b/iters/misc.go similarity index 89% rename from iterx/misc.go rename to iters/misc.go index a797eb1..59e5ad0 100644 --- a/iterx/misc.go +++ b/iters/misc.go @@ -1,4 +1,4 @@ -package iterx +package iters func ChanToSlice[V any](c chan V) []V { ret := []V{} diff --git a/lists/main.go b/lists/main.go index 7d38524..e4c5495 100644 --- a/lists/main.go +++ b/lists/main.go @@ -1,8 +1,8 @@ package lists import ( - "vultras.su/core/gods" - "vultras.su/core/gods/stacks" + "surdeus.su/core/gods" + "surdeus.su/core/gods/stacks" ) // The interface all the lists must implement. diff --git a/lists/single.go b/lists/single.go index 64c1ad1..bd35944 100644 --- a/lists/single.go +++ b/lists/single.go @@ -1,7 +1,7 @@ package lists import ( - "vultras.su/core/gods" + "surdeus.su/core/gods" "sort" "fmt" ) diff --git a/maps/main.go b/maps/main.go index 3ca8d3f..c5abf01 100644 --- a/maps/main.go +++ b/maps/main.go @@ -2,7 +2,7 @@ package maps import ( "fmt" - "vultras.su/core/gods" + "surdeus.su/core/gods" ) // Generic map interface for all the maps. diff --git a/ranges/range.go b/ranges/range.go index 7b71049..35cc44f 100644 --- a/ranges/range.go +++ b/ranges/range.go @@ -1,7 +1,7 @@ -package rangex +package ranges import ( - "github.com/mojosa-software/godat/src/iterx" + "surdeus.su/core/gods/iters" cnts "golang.org/x/exp/constraints" ) @@ -18,29 +18,30 @@ func New[V cnts.Ordered](start, step, end V) *Range[V] { } } -func (r *Range[V]) Chan() iterx.PairChan[int, V] { +func (r *Range[V]) Chan() iters.PairChan[int, V] { + + less := func(a, b V) bool { + return a < b + } + more := func(a, b V) bool { + return a > b + } + + var compare func(a, b V) bool start, step, end := r.start, r.step, r.end - c := make(iterx.PairChan[int, V]) + if start < end { + compare = less + } else { + compare = more + } + + c := make(iters.PairChan[int, V]) go func(){ - var compare func(a, b V) bool - less := func(a, b V) bool { - return a < b - } - - more := func(a, b V) bool { - return a > b - } - - if start < end { - compare = less - } else { - compare = more - } j := 0 for i := start ; compare(i, end) ; i += step { - c <- iterx.Pair[int, V]{ + c <- iters.Pair[int, V]{ K:j, V:i, } diff --git a/stacks/main.go b/stacks/main.go index 7a92699..64a6c28 100644 --- a/stacks/main.go +++ b/stacks/main.go @@ -1,7 +1,7 @@ package stacks import ( - "vultras.su/core/gods" + "surdeus.su/core/gods" ) type Stack[V any] interface {