1 Star 0 Fork 2

Fengzhi/gkit

forked from menuiis/gkit 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
types.go 23.83 KB
一键复制 编辑 原始数据 按行查看 历史
SongZhibin97 提交于 2022-07-25 17:09 . feat: ternary
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901
// Copyright 2021 ByteDance Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Code generated by go run types_gen.go; DO NOT EDIT.
package hashset
type ByteSet map[byte]struct{}
// NewByte returns an empty byte set
func NewByte() ByteSet {
return make(map[byte]struct{})
}
// NewByteWithSize returns an empty byte set initialized with specific size
func NewByteWithSize(size int) ByteSet {
return make(map[byte]struct{}, size)
}
// Add adds the specified element to this set
// Always returns true due to the build-in map doesn't indicate caller whether the given element already exists
// Reserves the return type for future extension
func (s ByteSet) Add(value byte) bool {
s[value] = struct{}{}
return true
}
// Contains returns true if this set contains the specified element
func (s ByteSet) Contains(value byte) bool {
if _, ok := s[value]; ok {
return true
}
return false
}
// Remove removes the specified element from this set
// Always returns true due to the build-in map doesn't indicate caller whether the given element already exists
// Reserves the return type for future extension
func (s ByteSet) Remove(value byte) bool {
delete(s, value)
return true
}
// Range calls f sequentially for each value present in the hashset.
// If f returns false, range stops the iteration.
func (s ByteSet) Range(f func(value byte) bool) {
for k := range s {
if !f(k) {
break
}
}
}
// Len returns the number of elements of this set
func (s ByteSet) Len() int {
return len(s)
}
type Complex64Set map[complex64]struct{}
// NewComplex64 returns an empty complex64 set
func NewComplex64() Complex64Set {
return make(map[complex64]struct{})
}
// NewComplex64WithSize returns an empty complex64 set initialized with specific size
func NewComplex64WithSize(size int) Complex64Set {
return make(map[complex64]struct{}, size)
}
// Add adds the specified element to this set
// Always returns true due to the build-in map doesn't indicate caller whether the given element already exists
// Reserves the return type for future extension
func (s Complex64Set) Add(value complex64) bool {
s[value] = struct{}{}
return true
}
// Contains returns true if this set contains the specified element
func (s Complex64Set) Contains(value complex64) bool {
if _, ok := s[value]; ok {
return true
}
return false
}
// Remove removes the specified element from this set
// Always returns true due to the build-in map doesn't indicate caller whether the given element already exists
// Reserves the return type for future extension
func (s Complex64Set) Remove(value complex64) bool {
delete(s, value)
return true
}
// Range calls f sequentially for each value present in the hashset.
// If f returns false, range stops the iteration.
func (s Complex64Set) Range(f func(value complex64) bool) {
for k := range s {
if !f(k) {
break
}
}
}
// Len returns the number of elements of this set
func (s Complex64Set) Len() int {
return len(s)
}
type Complex128Set map[complex128]struct{}
// NewComplex128 returns an empty complex128 set
func NewComplex128() Complex128Set {
return make(map[complex128]struct{})
}
// NewComplex128WithSize returns an empty complex128 set initialized with specific size
func NewComplex128WithSize(size int) Complex128Set {
return make(map[complex128]struct{}, size)
}
// Add adds the specified element to this set
// Always returns true due to the build-in map doesn't indicate caller whether the given element already exists
// Reserves the return type for future extension
func (s Complex128Set) Add(value complex128) bool {
s[value] = struct{}{}
return true
}
// Contains returns true if this set contains the specified element
func (s Complex128Set) Contains(value complex128) bool {
if _, ok := s[value]; ok {
return true
}
return false
}
// Remove removes the specified element from this set
// Always returns true due to the build-in map doesn't indicate caller whether the given element already exists
// Reserves the return type for future extension
func (s Complex128Set) Remove(value complex128) bool {
delete(s, value)
return true
}
// Range calls f sequentially for each value present in the hashset.
// If f returns false, range stops the iteration.
func (s Complex128Set) Range(f func(value complex128) bool) {
for k := range s {
if !f(k) {
break
}
}
}
// Len returns the number of elements of this set
func (s Complex128Set) Len() int {
return len(s)
}
type Float32Set map[float32]struct{}
// NewFloat32 returns an empty float32 set
func NewFloat32() Float32Set {
return make(map[float32]struct{})
}
// NewFloat32WithSize returns an empty float32 set initialized with specific size
func NewFloat32WithSize(size int) Float32Set {
return make(map[float32]struct{}, size)
}
// Add adds the specified element to this set
// Always returns true due to the build-in map doesn't indicate caller whether the given element already exists
// Reserves the return type for future extension
func (s Float32Set) Add(value float32) bool {
s[value] = struct{}{}
return true
}
// Contains returns true if this set contains the specified element
func (s Float32Set) Contains(value float32) bool {
if _, ok := s[value]; ok {
return true
}
return false
}
// Remove removes the specified element from this set
// Always returns true due to the build-in map doesn't indicate caller whether the given element already exists
// Reserves the return type for future extension
func (s Float32Set) Remove(value float32) bool {
delete(s, value)
return true
}
// Range calls f sequentially for each value present in the hashset.
// If f returns false, range stops the iteration.
func (s Float32Set) Range(f func(value float32) bool) {
for k := range s {
if !f(k) {
break
}
}
}
// Len returns the number of elements of this set
func (s Float32Set) Len() int {
return len(s)
}
type Float64Set map[float64]struct{}
// NewFloat64 returns an empty float64 set
func NewFloat64() Float64Set {
return make(map[float64]struct{})
}
// NewFloat64WithSize returns an empty float64 set initialized with specific size
func NewFloat64WithSize(size int) Float64Set {
return make(map[float64]struct{}, size)
}
// Add adds the specified element to this set
// Always returns true due to the build-in map doesn't indicate caller whether the given element already exists
// Reserves the return type for future extension
func (s Float64Set) Add(value float64) bool {
s[value] = struct{}{}
return true
}
// Contains returns true if this set contains the specified element
func (s Float64Set) Contains(value float64) bool {
if _, ok := s[value]; ok {
return true
}
return false
}
// Remove removes the specified element from this set
// Always returns true due to the build-in map doesn't indicate caller whether the given element already exists
// Reserves the return type for future extension
func (s Float64Set) Remove(value float64) bool {
delete(s, value)
return true
}
// Range calls f sequentially for each value present in the hashset.
// If f returns false, range stops the iteration.
func (s Float64Set) Range(f func(value float64) bool) {
for k := range s {
if !f(k) {
break
}
}
}
// Len returns the number of elements of this set
func (s Float64Set) Len() int {
return len(s)
}
type IntSet map[int]struct{}
// NewInt returns an empty int set
func NewInt() IntSet {
return make(map[int]struct{})
}
// NewIntWithSize returns an empty int set initialized with specific size
func NewIntWithSize(size int) IntSet {
return make(map[int]struct{}, size)
}
// Add adds the specified element to this set
// Always returns true due to the build-in map doesn't indicate caller whether the given element already exists
// Reserves the return type for future extension
func (s IntSet) Add(value int) bool {
s[value] = struct{}{}
return true
}
// Contains returns true if this set contains the specified element
func (s IntSet) Contains(value int) bool {
if _, ok := s[value]; ok {
return true
}
return false
}
// Remove removes the specified element from this set
// Always returns true due to the build-in map doesn't indicate caller whether the given element already exists
// Reserves the return type for future extension
func (s IntSet) Remove(value int) bool {
delete(s, value)
return true
}
// Range calls f sequentially for each value present in the hashset.
// If f returns false, range stops the iteration.
func (s IntSet) Range(f func(value int) bool) {
for k := range s {
if !f(k) {
break
}
}
}
// Len returns the number of elements of this set
func (s IntSet) Len() int {
return len(s)
}
type Int8Set map[int8]struct{}
// NewInt8 returns an empty int8 set
func NewInt8() Int8Set {
return make(map[int8]struct{})
}
// NewInt8WithSize returns an empty int8 set initialized with specific size
func NewInt8WithSize(size int) Int8Set {
return make(map[int8]struct{}, size)
}
// Add adds the specified element to this set
// Always returns true due to the build-in map doesn't indicate caller whether the given element already exists
// Reserves the return type for future extension
func (s Int8Set) Add(value int8) bool {
s[value] = struct{}{}
return true
}
// Contains returns true if this set contains the specified element
func (s Int8Set) Contains(value int8) bool {
if _, ok := s[value]; ok {
return true
}
return false
}
// Remove removes the specified element from this set
// Always returns true due to the build-in map doesn't indicate caller whether the given element already exists
// Reserves the return type for future extension
func (s Int8Set) Remove(value int8) bool {
delete(s, value)
return true
}
// Range calls f sequentially for each value present in the hashset.
// If f returns false, range stops the iteration.
func (s Int8Set) Range(f func(value int8) bool) {
for k := range s {
if !f(k) {
break
}
}
}
// Len returns the number of elements of this set
func (s Int8Set) Len() int {
return len(s)
}
type Int16Set map[int16]struct{}
// NewInt16 returns an empty int16 set
func NewInt16() Int16Set {
return make(map[int16]struct{})
}
// NewInt16WithSize returns an empty int16 set initialized with specific size
func NewInt16WithSize(size int) Int16Set {
return make(map[int16]struct{}, size)
}
// Add adds the specified element to this set
// Always returns true due to the build-in map doesn't indicate caller whether the given element already exists
// Reserves the return type for future extension
func (s Int16Set) Add(value int16) bool {
s[value] = struct{}{}
return true
}
// Contains returns true if this set contains the specified element
func (s Int16Set) Contains(value int16) bool {
if _, ok := s[value]; ok {
return true
}
return false
}
// Remove removes the specified element from this set
// Always returns true due to the build-in map doesn't indicate caller whether the given element already exists
// Reserves the return type for future extension
func (s Int16Set) Remove(value int16) bool {
delete(s, value)
return true
}
// Range calls f sequentially for each value present in the hashset.
// If f returns false, range stops the iteration.
func (s Int16Set) Range(f func(value int16) bool) {
for k := range s {
if !f(k) {
break
}
}
}
// Len returns the number of elements of this set
func (s Int16Set) Len() int {
return len(s)
}
type Int32Set map[int32]struct{}
// NewInt32 returns an empty int32 set
func NewInt32() Int32Set {
return make(map[int32]struct{})
}
// NewInt32WithSize returns an empty int32 set initialized with specific size
func NewInt32WithSize(size int) Int32Set {
return make(map[int32]struct{}, size)
}
// Add adds the specified element to this set
// Always returns true due to the build-in map doesn't indicate caller whether the given element already exists
// Reserves the return type for future extension
func (s Int32Set) Add(value int32) bool {
s[value] = struct{}{}
return true
}
// Contains returns true if this set contains the specified element
func (s Int32Set) Contains(value int32) bool {
if _, ok := s[value]; ok {
return true
}
return false
}
// Remove removes the specified element from this set
// Always returns true due to the build-in map doesn't indicate caller whether the given element already exists
// Reserves the return type for future extension
func (s Int32Set) Remove(value int32) bool {
delete(s, value)
return true
}
// Range calls f sequentially for each value present in the hashset.
// If f returns false, range stops the iteration.
func (s Int32Set) Range(f func(value int32) bool) {
for k := range s {
if !f(k) {
break
}
}
}
// Len returns the number of elements of this set
func (s Int32Set) Len() int {
return len(s)
}
type RuneSet map[rune]struct{}
// NewRune returns an empty rune set
func NewRune() RuneSet {
return make(map[rune]struct{})
}
// NewRuneWithSize returns an empty rune set initialized with specific size
func NewRuneWithSize(size int) RuneSet {
return make(map[rune]struct{}, size)
}
// Add adds the specified element to this set
// Always returns true due to the build-in map doesn't indicate caller whether the given element already exists
// Reserves the return type for future extension
func (s RuneSet) Add(value rune) bool {
s[value] = struct{}{}
return true
}
// Contains returns true if this set contains the specified element
func (s RuneSet) Contains(value rune) bool {
if _, ok := s[value]; ok {
return true
}
return false
}
// Remove removes the specified element from this set
// Always returns true due to the build-in map doesn't indicate caller whether the given element already exists
// Reserves the return type for future extension
func (s RuneSet) Remove(value rune) bool {
delete(s, value)
return true
}
// Range calls f sequentially for each value present in the hashset.
// If f returns false, range stops the iteration.
func (s RuneSet) Range(f func(value rune) bool) {
for k := range s {
if !f(k) {
break
}
}
}
// Len returns the number of elements of this set
func (s RuneSet) Len() int {
return len(s)
}
type StringSet map[string]struct{}
// NewString returns an empty string set
func NewString() StringSet {
return make(map[string]struct{})
}
// NewStringWithSize returns an empty string set initialized with specific size
func NewStringWithSize(size int) StringSet {
return make(map[string]struct{}, size)
}
// Add adds the specified element to this set
// Always returns true due to the build-in map doesn't indicate caller whether the given element already exists
// Reserves the return type for future extension
func (s StringSet) Add(value string) bool {
s[value] = struct{}{}
return true
}
// Contains returns true if this set contains the specified element
func (s StringSet) Contains(value string) bool {
if _, ok := s[value]; ok {
return true
}
return false
}
// Remove removes the specified element from this set
// Always returns true due to the build-in map doesn't indicate caller whether the given element already exists
// Reserves the return type for future extension
func (s StringSet) Remove(value string) bool {
delete(s, value)
return true
}
// Range calls f sequentially for each value present in the hashset.
// If f returns false, range stops the iteration.
func (s StringSet) Range(f func(value string) bool) {
for k := range s {
if !f(k) {
break
}
}
}
// Len returns the number of elements of this set
func (s StringSet) Len() int {
return len(s)
}
type UintSet map[uint]struct{}
// NewUint returns an empty uint set
func NewUint() UintSet {
return make(map[uint]struct{})
}
// NewUintWithSize returns an empty uint set initialized with specific size
func NewUintWithSize(size int) UintSet {
return make(map[uint]struct{}, size)
}
// Add adds the specified element to this set
// Always returns true due to the build-in map doesn't indicate caller whether the given element already exists
// Reserves the return type for future extension
func (s UintSet) Add(value uint) bool {
s[value] = struct{}{}
return true
}
// Contains returns true if this set contains the specified element
func (s UintSet) Contains(value uint) bool {
if _, ok := s[value]; ok {
return true
}
return false
}
// Remove removes the specified element from this set
// Always returns true due to the build-in map doesn't indicate caller whether the given element already exists
// Reserves the return type for future extension
func (s UintSet) Remove(value uint) bool {
delete(s, value)
return true
}
// Range calls f sequentially for each value present in the hashset.
// If f returns false, range stops the iteration.
func (s UintSet) Range(f func(value uint) bool) {
for k := range s {
if !f(k) {
break
}
}
}
// Len returns the number of elements of this set
func (s UintSet) Len() int {
return len(s)
}
type Uint8Set map[uint8]struct{}
// NewUint8 returns an empty uint8 set
func NewUint8() Uint8Set {
return make(map[uint8]struct{})
}
// NewUint8WithSize returns an empty uint8 set initialized with specific size
func NewUint8WithSize(size int) Uint8Set {
return make(map[uint8]struct{}, size)
}
// Add adds the specified element to this set
// Always returns true due to the build-in map doesn't indicate caller whether the given element already exists
// Reserves the return type for future extension
func (s Uint8Set) Add(value uint8) bool {
s[value] = struct{}{}
return true
}
// Contains returns true if this set contains the specified element
func (s Uint8Set) Contains(value uint8) bool {
if _, ok := s[value]; ok {
return true
}
return false
}
// Remove removes the specified element from this set
// Always returns true due to the build-in map doesn't indicate caller whether the given element already exists
// Reserves the return type for future extension
func (s Uint8Set) Remove(value uint8) bool {
delete(s, value)
return true
}
// Range calls f sequentially for each value present in the hashset.
// If f returns false, range stops the iteration.
func (s Uint8Set) Range(f func(value uint8) bool) {
for k := range s {
if !f(k) {
break
}
}
}
// Len returns the number of elements of this set
func (s Uint8Set) Len() int {
return len(s)
}
type Uint16Set map[uint16]struct{}
// NewUint16 returns an empty uint16 set
func NewUint16() Uint16Set {
return make(map[uint16]struct{})
}
// NewUint16WithSize returns an empty uint16 set initialized with specific size
func NewUint16WithSize(size int) Uint16Set {
return make(map[uint16]struct{}, size)
}
// Add adds the specified element to this set
// Always returns true due to the build-in map doesn't indicate caller whether the given element already exists
// Reserves the return type for future extension
func (s Uint16Set) Add(value uint16) bool {
s[value] = struct{}{}
return true
}
// Contains returns true if this set contains the specified element
func (s Uint16Set) Contains(value uint16) bool {
if _, ok := s[value]; ok {
return true
}
return false
}
// Remove removes the specified element from this set
// Always returns true due to the build-in map doesn't indicate caller whether the given element already exists
// Reserves the return type for future extension
func (s Uint16Set) Remove(value uint16) bool {
delete(s, value)
return true
}
// Range calls f sequentially for each value present in the hashset.
// If f returns false, range stops the iteration.
func (s Uint16Set) Range(f func(value uint16) bool) {
for k := range s {
if !f(k) {
break
}
}
}
// Len returns the number of elements of this set
func (s Uint16Set) Len() int {
return len(s)
}
type Uint32Set map[uint32]struct{}
// NewUint32 returns an empty uint32 set
func NewUint32() Uint32Set {
return make(map[uint32]struct{})
}
// NewUint32WithSize returns an empty uint32 set initialized with specific size
func NewUint32WithSize(size int) Uint32Set {
return make(map[uint32]struct{}, size)
}
// Add adds the specified element to this set
// Always returns true due to the build-in map doesn't indicate caller whether the given element already exists
// Reserves the return type for future extension
func (s Uint32Set) Add(value uint32) bool {
s[value] = struct{}{}
return true
}
// Contains returns true if this set contains the specified element
func (s Uint32Set) Contains(value uint32) bool {
if _, ok := s[value]; ok {
return true
}
return false
}
// Remove removes the specified element from this set
// Always returns true due to the build-in map doesn't indicate caller whether the given element already exists
// Reserves the return type for future extension
func (s Uint32Set) Remove(value uint32) bool {
delete(s, value)
return true
}
// Range calls f sequentially for each value present in the hashset.
// If f returns false, range stops the iteration.
func (s Uint32Set) Range(f func(value uint32) bool) {
for k := range s {
if !f(k) {
break
}
}
}
// Len returns the number of elements of this set
func (s Uint32Set) Len() int {
return len(s)
}
type Uint64Set map[uint64]struct{}
// NewUint64 returns an empty uint64 set
func NewUint64() Uint64Set {
return make(map[uint64]struct{})
}
// NewUint64WithSize returns an empty uint64 set initialized with specific size
func NewUint64WithSize(size int) Uint64Set {
return make(map[uint64]struct{}, size)
}
// Add adds the specified element to this set
// Always returns true due to the build-in map doesn't indicate caller whether the given element already exists
// Reserves the return type for future extension
func (s Uint64Set) Add(value uint64) bool {
s[value] = struct{}{}
return true
}
// Contains returns true if this set contains the specified element
func (s Uint64Set) Contains(value uint64) bool {
if _, ok := s[value]; ok {
return true
}
return false
}
// Remove removes the specified element from this set
// Always returns true due to the build-in map doesn't indicate caller whether the given element already exists
// Reserves the return type for future extension
func (s Uint64Set) Remove(value uint64) bool {
delete(s, value)
return true
}
// Range calls f sequentially for each value present in the hashset.
// If f returns false, range stops the iteration.
func (s Uint64Set) Range(f func(value uint64) bool) {
for k := range s {
if !f(k) {
break
}
}
}
// Len returns the number of elements of this set
func (s Uint64Set) Len() int {
return len(s)
}
type UintptrSet map[uintptr]struct{}
// NewUintptr returns an empty uintptr set
func NewUintptr() UintptrSet {
return make(map[uintptr]struct{})
}
// NewUintptrWithSize returns an empty uintptr set initialized with specific size
func NewUintptrWithSize(size int) UintptrSet {
return make(map[uintptr]struct{}, size)
}
// Add adds the specified element to this set
// Always returns true due to the build-in map doesn't indicate caller whether the given element already exists
// Reserves the return type for future extension
func (s UintptrSet) Add(value uintptr) bool {
s[value] = struct{}{}
return true
}
// Contains returns true if this set contains the specified element
func (s UintptrSet) Contains(value uintptr) bool {
if _, ok := s[value]; ok {
return true
}
return false
}
// Remove removes the specified element from this set
// Always returns true due to the build-in map doesn't indicate caller whether the given element already exists
// Reserves the return type for future extension
func (s UintptrSet) Remove(value uintptr) bool {
delete(s, value)
return true
}
// Range calls f sequentially for each value present in the hashset.
// If f returns false, range stops the iteration.
func (s UintptrSet) Range(f func(value uintptr) bool) {
for k := range s {
if !f(k) {
break
}
}
}
// Len returns the number of elements of this set
func (s UintptrSet) Len() int {
return len(s)
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/fengzhi_1/gkit.git
git@gitee.com:fengzhi_1/gkit.git
fengzhi_1
gkit
gkit
b6285053065d

搜索帮助