Documentation ¶
Overview ¶
Package tag 标签方法.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Add ¶
func Add[E constraints.Integer](tag E, elems ...E) E
Add 增加.
Example ¶
ExampleAdd 增加例子.
package main import ( "fmt" "github.com/xuender/kit/tags" ) func main() { tag := tags.Add(1<<3, 1<<4) fmt.Println(tag) }
Output: 24
func Del ¶
func Del[E constraints.Integer](tag E, elems ...E) E
Del 删除.
Example ¶
ExampleDel 删除例子.
package main import ( "fmt" "github.com/xuender/kit/tags" ) func main() { tag := tags.Add(1<<3, 1<<4) tag = tags.Del(tag, 1<<3, 1<<5) fmt.Println(tag) }
Output: 16
func Has ¶
func Has[E constraints.Integer](tag E, elems ...E) bool
Has 包含任何一个标签.
Example ¶
ExampleHas 包含例子.
package main import ( "fmt" "github.com/xuender/kit/tags" ) func main() { tag := tags.Add(1<<3, 1<<4) query1 := tags.Add(1 << 3) query2 := tags.Add(1<<3, 1<<4) query3 := tags.Add(1 << 2) fmt.Println(tags.Has(tag, query1)) fmt.Println(tags.Has(tag, query1, query2)) fmt.Println(tags.Has(tag, query3)) fmt.Println(tags.Has(tag, query3, query2)) }
Output: true true false true
func Hit ¶
func Hit[E constraints.Integer](tag E, elems ...E) bool
Hit 命中所有标签.
Example ¶
ExampleHit 命中例子.
package main import ( "fmt" "github.com/xuender/kit/tags" ) func main() { tag := tags.Add(1<<3, 1<<4) query1 := tags.Add(1 << 3) query2 := tags.Add(1<<3, 1<<4) query3 := tags.Add(1 << 2) fmt.Println(tags.Hit(tag, query1)) fmt.Println(tags.Hit(tag, query1, query2)) fmt.Println(tags.Hit(tag, query3)) fmt.Println(tags.Hit(tag, query3, query2)) }
Output: true true false false
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.