Documentation ¶
Index ¶
- func Byte2Ints[T constraints.Integer](n T, b byte) []T
- func Int2Byte[T constraints.Integer](i T) (T, byte)
- type BitMap
- func (t *BitMap[T]) Add(elems ...T) BitMap[T]
- func (t *BitMap[T]) AddBitMap(elem BitMap[T]) BitMap[T]
- func (t BitMap[T]) All(elems ...T) bool
- func (t BitMap[T]) Any(elems ...T) bool
- func (t BitMap[T]) Bytes() []byte
- func (t BitMap[T]) Count() int
- func (t BitMap[T]) Del(elems ...T) BitMap[T]
- func (t BitMap[T]) DelBitMap(elem BitMap[T]) BitMap[T]
- func (t BitMap[T]) Has(tag T) bool
- func (t BitMap[T]) Join(sep string) string
- func (t *BitMap[T]) Load(bs []byte)
- func (t BitMap[T]) Slice() []T
- func (t BitMap[T]) String() string
- type Tag
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BitMap ¶
type BitMap[T constraints.Integer] []byte
BitMap 位图.
Example ¶
package main import ( "fmt" "github.com/xuender/oils/tags" ) func main() { tag := tags.NewBitMap(1, 2, 33) fmt.Println(tag.Has(1)) fmt.Println(tag.Has(3)) fmt.Println(tag.Has(33)) fmt.Println(tag) }
Output: true false true 1, 2, 33
func Intersection ¶
func Intersection[T constraints.Integer](elems ...BitMap[T]) BitMap[T]
Intersection 交集. nolint
type Tag ¶
type Tag uint64
Tag 标签.
标签内最多保存64个状态,数据库索引字段避免使用Tag,位运算无法使用索引加速.
Example ¶
package main import ( "fmt" "github.com/xuender/oils/tags" ) func main() { var tag tags.Tag tag.Add(0, 1, 2) fmt.Println(tag.Has(1)) fmt.Println(tag.Has(3)) tag.Add(3) fmt.Println(tag.Len()) fmt.Println(tag.Slice()) tag.Del(2) fmt.Println(tag.Len()) fmt.Println(tag.All(3, 4)) fmt.Println(tag.All(1, 3)) fmt.Println(tag.Any(4, 5)) fmt.Println(tag.Any(3, 4)) }
Output: true false 4 [0 1 2 3] 3 false true false true
Click to show internal directories.
Click to hide internal directories.