Commit 4b8063fb by zhengqiuyun86

数组差集算法

parent e8ce7b1a
...@@ -23,7 +23,7 @@ type Config struct { ...@@ -23,7 +23,7 @@ type Config struct {
func BaseConfig(conf Config) { func BaseConfig(conf Config) {
if util.IsEmpty(&conf.ServerName) { if util.IsEmpty(&conf.ServerName) {
exception.AssertThrowable("ServerName error") exception.ThrowsErrS("SYSTEM_ERR", "ServerName error")
} else { } else {
ServerName = conf.ServerName ServerName = conf.ServerName
} }
......
...@@ -15,6 +15,7 @@ require ( ...@@ -15,6 +15,7 @@ require (
github.com/KyleBanks/depth v1.2.1 // indirect github.com/KyleBanks/depth v1.2.1 // indirect
github.com/PuerkitoBio/purell v1.1.1 // indirect github.com/PuerkitoBio/purell v1.1.1 // indirect
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
github.com/gin-contrib/cors v1.4.0 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect github.com/gin-contrib/sse v0.1.0 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.19.6 // indirect github.com/go-openapi/jsonreference v0.19.6 // indirect
...@@ -48,10 +49,8 @@ require ( ...@@ -48,10 +49,8 @@ require (
) )
require ( require (
github.com/gin-contrib/cors v1.4.0
github.com/onsi/ginkgo v1.16.5 // indirect github.com/onsi/ginkgo v1.16.5 // indirect
github.com/onsi/gomega v1.20.0 // indirect github.com/onsi/gomega v1.20.0 // indirect
github.com/swaggo/files v0.0.0-20220728132757-551d4a08d97a github.com/swaggo/files v0.0.0-20220728132757-551d4a08d97a
github.com/swaggo/gin-swagger v1.5.2 github.com/swaggo/gin-swagger v1.5.2
gopkg.in/fatih/set.v0 v0.2.1
) )
//package main
//
//import (
// "git.168cad.top/zhengqiuyun/rym-util/conf"
// "git.168cad.top/zhengqiuyun/rym-util/es"
// "git.168cad.top/zhengqiuyun/rym-util/log"
// "git.168cad.top/zhengqiuyun/rym-util/mysqlrym"
// "git.168cad.top/zhengqiuyun/rym-util/redis"
// "git.168cad.top/zhengqiuyun/rym-util/router"
//)
//
//func main() {
// log.Debug("测试")
// log.Info("测试")
// log.Warn("测试")
// log.Error("测试")
// conf.BaseConfig(conf.Config{
// ServerName: "rym-framework",
// Env: "dev",
// HttpPort: 1024,
// LogColorful: true,
// })
// mysqlrym.TestLog()
// es.TestLog()
// redis.TestLog()
// c := router.InitGinEngine(true)
// router.Run(c)
//}
package main package main
import ( import (
"fmt" "git.168cad.top/zhengqiuyun/rym-util/conf"
"gopkg.in/fatih/set.v0" "git.168cad.top/zhengqiuyun/rym-util/es"
"git.168cad.top/zhengqiuyun/rym-util/log"
"git.168cad.top/zhengqiuyun/rym-util/mysqlrym"
"git.168cad.top/zhengqiuyun/rym-util/redis"
"git.168cad.top/zhengqiuyun/rym-util/router"
) )
/*set并集 交集 差集计算示例*/
func main() { func main() {
a := set.New(set.ThreadSafe) log.Debug("测试")
a.Add(1) log.Info("测试")
a.Add(2) log.Warn("测试")
a.Add(3) log.Error("测试")
b := set.New(set.ThreadSafe) conf.BaseConfig(conf.Config{
b.Add(2) ServerName: "rym-framework",
b.Add(3) Env: "dev",
b.Add(4) HttpPort: 1024,
//并集 LogColorful: true,
unionSet := set.Union(a, b) })
fmt.Printf("并集:%v\n", unionSet) mysqlrym.TestLog()
//交集 es.TestLog()
intersectionSet := set.Intersection(a, b) redis.TestLog()
fmt.Printf("交集:%v\n", intersectionSet) c := router.InitGinEngine(true)
//差集 router.Run(c)
diffS1S2 := set.Difference(a, b)
fmt.Printf("差集(属a不属b):%v\n", diffS1S2)
diffS2S1 := set.Difference(b, a)
fmt.Printf("差集(属b不属a):%v\n", diffS2S1)
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment