Documentation
¶
Overview ¶
Package object 用于将布尔值封装为并发安全的对象,提供一些基本的操作方法
Package object 用于将float32类型的数据封装为线程安全的对象 ¶
Package object 用于将float64类型的数据封装为线程安全的对象 ¶
Package object 用于将int32类型的数据封装为线程安全的对象 ¶
Package object 用于将int64类型的数据封装为线程安全的对象 ¶
Package object 用于将Map结构体封装为一个支持并发安全的泛型的键值对存储器 ¶
Package object 用于创建一个线程安全的字符串对象且提供对象的方法简易调用封装 ¶
Package object 将字符串切片封装为对象,提供线程安全的操作方法 ¶
Package object 将结构体切片封装为对象,提供线程安全的操作方法 ¶
Package object 用于将uint32类型的数据封装为线程安全的对象 ¶
Package object 用于将uint64类型的数据封装为线程安全的对象
Index ¶
- type Bool
- type Float32
- type Float64
- type Int32
- type Int64
- type Map
- func (m *Map[K, V]) Add(key K, value V) bool
- func (m *Map[K, V]) Clean()
- func (m *Map[K, V]) Clone(threadSafe bool) (*Map[K, V], error)
- func (m *Map[K, V]) Contains(key K) bool
- func (m *Map[K, V]) Delete(key K) bool
- func (m *Map[K, V]) Entries() map[K]V
- func (m *Map[K, V]) Equals(m2 *Map[K, V]) (bool, error)
- func (m *Map[K, V]) ForEach(callback func(key K, value V))
- func (m *Map[K, V]) Get(key K) (V, bool)
- func (m *Map[K, V]) IsEmpty() bool
- func (m *Map[K, V]) Keys() []K
- func (m *Map[K, V]) Merge(m2 *Map[K, V], keepOldValue bool)
- func (m *Map[K, V]) Set(key K, value V)
- func (m *Map[K, V]) Size() int
- func (m *Map[K, V]) Update(key K, value V) bool
- func (m *Map[K, V]) Values() []V
- type NonThreadSafeFloat32
- type NonThreadSafeFloat64
- type NonThreadSafeInt32
- type NonThreadSafeInt64
- type NonThreadSafeUInt32
- type NonThreadSafeUInt64
- type String
- func (s *String) Concat(value string) *String
- func (s *String) Contains(value string) bool
- func (s *String) Count(substr string) int
- func (s *String) Display()
- func (s *String) DisplayType()
- func (s *String) Equal(value string) bool
- func (s *String) EqualFold(value string) bool
- func (s *String) Fields() []string
- func (s *String) Get() string
- func (s *String) HasPrefix(prefix string) bool
- func (s *String) HasSuffix(suffix string) bool
- func (s *String) Index(substr string) int
- func (s *String) IsEmpty() bool
- func (s *String) LastIndex(substr string) int
- func (s *String) Length() int
- func (s *String) Repeat(n int) string
- func (s *String) Replace(old, new string, n int) string
- func (s *String) Set(value string)
- func (s *String) Split(sep string) []string
- func (s *String) ToLower() string
- func (s *String) ToUpper() string
- func (s *String) Trim(cutset string) string
- func (s *String) TrimSpace() string
- type StringSlice
- func (s *StringSlice) Add(item string)
- func (s *StringSlice) AppendWithoutDuplicates(newItems []string)
- func (s *StringSlice) Clean()
- func (s *StringSlice) Clone(threadSafe bool) *StringSlice
- func (s *StringSlice) Contains(keyword string) bool
- func (s *StringSlice) ExactMatch(keyword string) bool
- func (s *StringSlice) Get() []string
- func (s *StringSlice) Remove(value string, allowChangeOrder bool)
- func (s *StringSlice) RemoveAtIndex(index int, allowChangeOrder bool)
- func (s *StringSlice) RemoveAtIndices(indices []int, allowChangeOrder bool)
- func (s *StringSlice) RemoveIfContains(keyword string)
- func (s *StringSlice) RemoveIfNotContains(keyword string)
- func (s *StringSlice) Search(keyword string) map[int]string
- func (s *StringSlice) Set(values []string)
- func (s *StringSlice) Size() int
- type Struct
- type StructSlice
- func (s *StructSlice[T]) Add(item T)
- func (s *StructSlice[T]) Clean()
- func (s *StructSlice[T]) Clone(threadSafe bool) *StructSlice[T]
- func (s *StructSlice[T]) Get() []T
- func (s *StructSlice[T]) RemoveAtIndex(index int, allowChangeOrder bool)
- func (s *StructSlice[T]) RemoveAtIndices(indices []int, allowChangeOrder bool)
- func (s *StructSlice[T]) Set(values []T)
- func (s *StructSlice[T]) Size() int
- type ThreadSafeFloat32
- type ThreadSafeFloat64
- type ThreadSafeInt32
- type ThreadSafeInt64
- type ThreadSafeUInt32
- type ThreadSafeUInt64
- type Time
- func (t *Time) Add(d time.Duration) time.Time
- func (t *Time) AddDate(years int, months int, days int) time.Time
- func (t *Time) After(u time.Time) bool
- func (t *Time) AppendFormat(b []byte, layout string) []byte
- func (t *Time) AsTime() time.Time
- func (t *Time) Before(u time.Time) bool
- func (t *Time) Clock() (hour, min, sec int)
- func (t *Time) Date() (year int, month time.Month, day int)
- func (t *Time) Day() int
- func (t *Time) Equal(u time.Time) bool
- func (t *Time) Format(layout string) string
- func (t *Time) Get() time.Time
- func (t *Time) GobDecode(data []byte) error
- func (t *Time) GobEncode() ([]byte, error)
- func (t *Time) Hour() int
- func (t *Time) ISOWeek() (year, week int)
- func (t *Time) In(loc *time.Location) time.Time
- func (t *Time) IsZero() bool
- func (t *Time) Local() time.Time
- func (t *Time) Location() *time.Location
- func (t *Time) MarshalBinary() ([]byte, error)
- func (t *Time) MarshalJSON() ([]byte, error)
- func (t *Time) MarshalText() ([]byte, error)
- func (t *Time) Minute() int
- func (t *Time) Month() time.Month
- func (t *Time) Nanosecond() int
- func (t *Time) Round(d time.Duration) time.Time
- func (t *Time) Second() int
- func (t *Time) Set(value time.Time)
- func (t *Time) Since() time.Duration
- func (t *Time) String() string
- func (t *Time) Sub(u time.Time) time.Duration
- func (t *Time) Truncate(d time.Duration) time.Time
- func (t *Time) UTC() time.Time
- func (t *Time) Unix() int64
- func (t *Time) UnixMicro() int64
- func (t *Time) UnixMilli() int64
- func (t *Time) UnixNano() int64
- func (t *Time) UnmarshalBinary(data []byte) error
- func (t *Time) UnmarshalJSON(data []byte) error
- func (t *Time) UnmarshalText(data []byte) error
- func (t *Time) Until() time.Duration
- func (t *Time) Weekday() time.Weekday
- func (t *Time) Year() int
- func (t *Time) YearDay() int
- func (t *Time) Zone() (zone string, offset int)
- type UInt32
- type UInt64
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bool ¶
type Bool struct { Value bool // Value用于存储布尔值 // contains filtered or unexported fields }
Bool 类型包含一个布尔值和一个读写互斥锁
type Float32 ¶
type Float32 interface { Set(value float32) // 设置浮点数的值 Get() float32 // 获取浮点数的值 Add(delta float32) float32 // 增加浮点数的值 String() string // 将浮点数转换为字符串 }
Float32 接口定义了浮点数的基本操作
func NewNonThreadSafeFloat32 ¶
NewNonThreadSafeFloat32 函数创建一个新的非线程安全的Float32实例
func NewThreadSafeFloat32 ¶
NewThreadSafeFloat32 函数创建一个新的线程安全的Float32实例
type Float64 ¶
type Float64 interface { Set(value float64) // 设置浮点数的值 Get() float64 // 获取浮点数的值 Add(delta float64) float64 // 增加浮点数的值 String() string // 将浮点数转换为字符串 }
Float64 接口定义了浮点数的基本操作
func NewNonThreadSafeFloat64 ¶
NewNonThreadSafeFloat64 函数创建一个新的非线程安全的Float64实例
func NewThreadSafeFloat64 ¶
NewThreadSafeFloat64 函数创建一个新的线程安全的Float64实例
type Int32 ¶
type Int32 interface { Set(value int32) // 设置整数值 Get() int32 // 获取当前整数值 Add(delta int32) int32 // 增加值,并返回新值 String() string // 将整数转换为字符串 }
Int32 接口定义了整数的一组操作,包括设置、获取、增加值以及转换为字符串
func NewNonThreadSafeInt32 ¶
NewNonThreadSafeInt32 函数创建并返回一个新的非线程安全的Int32实例
func NewThreadSafeInt32 ¶
NewThreadSafeInt32 函数创建并返回一个新的线程安全的Int32实例
type Int64 ¶
type Int64 interface { Set(value int64) // 设置整数值 Get() int64 // 获取当前整数值 Add(delta int64) int64 // 增加值,并返回新值 String() string // 将整数转换为字符串 }
Int64 接口定义了整数的一组操作,包括设置、获取、增加值以及转换为字符串
func NewNonThreadSafeInt64 ¶
NewNonThreadSafeInt64 函数创建并返回一个新的非线程安全的Int64实例
func NewThreadSafeInt64 ¶
NewThreadSafeInt64 函数创建并返回一个新的线程安全的Int64实例
type Map ¶
type Map[K comparable, V any] struct { Value map[K]V // 存储实际的键值对 // contains filtered or unexported fields }
Map 是一个泛型映射,提供键值对的存储,以及并发控制
func NewMap ¶
func NewMap[K comparable, V any](threadSafe bool) *Map[K, V]
NewMap 创建一个新的Map实例,根据threadSafe参数决定是否线程安全
func (*Map[K, V]) ForEach ¶
func (m *Map[K, V]) ForEach(callback func(key K, value V))
ForEach 方法遍历Map,对每个键值对执行callback函数
type NonThreadSafeFloat32 ¶
type NonThreadSafeFloat32 struct {
// contains filtered or unexported fields
}
NonThreadSafeFloat32 结构体提供非线程安全的浮点数操作
func (*NonThreadSafeFloat32) Add ¶
func (ntsf *NonThreadSafeFloat32) Add(delta float32) float32
Add 方法直接增加浮点数的值
func (*NonThreadSafeFloat32) Set ¶
func (ntsf *NonThreadSafeFloat32) Set(value float32)
Set 方法直接设置浮点数的值
func (*NonThreadSafeFloat32) String ¶
func (ntsf *NonThreadSafeFloat32) String() string
String 方法将浮点数转换为字符串
type NonThreadSafeFloat64 ¶
type NonThreadSafeFloat64 struct {
// contains filtered or unexported fields
}
NonThreadSafeFloat64 结构体提供非线程安全的浮点数操作
func (*NonThreadSafeFloat64) Add ¶
func (ntsf *NonThreadSafeFloat64) Add(delta float64) float64
Add 方法直接增加浮点数的值
func (*NonThreadSafeFloat64) Set ¶
func (ntsf *NonThreadSafeFloat64) Set(value float64)
Set 方法直接设置浮点数的值
func (*NonThreadSafeFloat64) String ¶
func (ntsf *NonThreadSafeFloat64) String() string
String 方法将浮点数转换为字符串
type NonThreadSafeInt32 ¶
type NonThreadSafeInt32 struct {
// contains filtered or unexported fields
}
NonThreadSafeInt32 结构体提供一个非线程安全的整数类型
func (*NonThreadSafeInt32) Add ¶
func (nts *NonThreadSafeInt32) Add(delta int32) int32
Add 方法直接增加整数值,并返回新值,非线程安全
func (*NonThreadSafeInt32) Set ¶
func (nts *NonThreadSafeInt32) Set(value int32)
Set 方法直接设置整数值,非线程安全
func (*NonThreadSafeInt32) String ¶
func (nts *NonThreadSafeInt32) String() string
String 方法返回当前整数值的字符串表示,非线程安全
type NonThreadSafeInt64 ¶
type NonThreadSafeInt64 struct {
// contains filtered or unexported fields
}
NonThreadSafeInt64 结构体提供一个非线程安全的整数类型
func (*NonThreadSafeInt64) Add ¶
func (nts *NonThreadSafeInt64) Add(delta int64) int64
Add 方法直接增加整数值,并返回新值,非线程安全
func (*NonThreadSafeInt64) Set ¶
func (nts *NonThreadSafeInt64) Set(value int64)
Set 方法直接设置整数值,非线程安全
func (*NonThreadSafeInt64) String ¶
func (nts *NonThreadSafeInt64) String() string
String 方法返回当前整数值的字符串表示,非线程安全
type NonThreadSafeUInt32 ¶
type NonThreadSafeUInt32 struct {
// contains filtered or unexported fields
}
NonThreadSafeUInt32 结构体包含一个无符号32位整型数值,非线程安全
func (*NonThreadSafeUInt32) Add ¶
func (nts *NonThreadSafeUInt32) Add(delta uint32) uint32
Add 方法直接增加数值,并返回新值,非线程安全
func (*NonThreadSafeUInt32) Set ¶
func (nts *NonThreadSafeUInt32) Set(value uint32)
Set 方法直接设置数值,非线程安全
func (*NonThreadSafeUInt32) String ¶
func (nts *NonThreadSafeUInt32) String() string
String 方法将数值转换为其十进制的字符串表示形式,非线程安全
type NonThreadSafeUInt64 ¶
type NonThreadSafeUInt64 struct {
// contains filtered or unexported fields
}
NonThreadSafeUInt64 结构体包含一个无符号64位整型数值,非线程安全
func (*NonThreadSafeUInt64) Add ¶
func (nts *NonThreadSafeUInt64) Add(delta uint64) uint64
Add 方法直接增加数值,并返回新值,非线程安全
func (*NonThreadSafeUInt64) Set ¶
func (nts *NonThreadSafeUInt64) Set(value uint64)
Set 方法直接设置数值,非线程安全
func (*NonThreadSafeUInt64) String ¶
func (nts *NonThreadSafeUInt64) String() string
String 方法将数值转换为其十进制的字符串表示形式,非线程安全
type String ¶
type String struct { Value string // 存储字符串的变量 // contains filtered or unexported fields }
String 结构体,用于存储单个字符串及其锁
type StringSlice ¶
type StringSlice struct { Values []string // 存储实际的字符串切片数据 // contains filtered or unexported fields }
StringSlice 结构体,用于存储字符串切片,并通过locker来控制线程安全
func NewStringSlice ¶
func NewStringSlice(values []string, threadSafe bool) *StringSlice
NewStringSlice 函数创建StringSlice实例,可以选择是否线程安全
func (*StringSlice) AppendWithoutDuplicates ¶
func (s *StringSlice) AppendWithoutDuplicates(newItems []string)
AppendWithoutDuplicates 方法将新元素添加到切片中,同时确保没有重复
func (*StringSlice) Clone ¶
func (s *StringSlice) Clone(threadSafe bool) *StringSlice
Clone 方法创建并返回一个当前副本
func (*StringSlice) Contains ¶
func (s *StringSlice) Contains(keyword string) bool
Contains 方法判断切片中是否包含关键字
func (*StringSlice) ExactMatch ¶
func (s *StringSlice) ExactMatch(keyword string) bool
ExactMatch 方法判断切片中是否有元素与关键字完全匹配
func (*StringSlice) Remove ¶
func (s *StringSlice) Remove(value string, allowChangeOrder bool)
Remove 方法根据值移除元素
func (*StringSlice) RemoveAtIndex ¶
func (s *StringSlice) RemoveAtIndex(index int, allowChangeOrder bool)
RemoveAtIndex 方法根据索引移除元素
func (*StringSlice) RemoveAtIndices ¶
func (s *StringSlice) RemoveAtIndices(indices []int, allowChangeOrder bool)
RemoveAtIndices 方法根据一组索引移除多个元素
func (*StringSlice) RemoveIfContains ¶
func (s *StringSlice) RemoveIfContains(keyword string)
RemoveIfContains 方法移除切片中包含关键字的元素
func (*StringSlice) RemoveIfNotContains ¶
func (s *StringSlice) RemoveIfNotContains(keyword string)
RemoveIfNotContains 方法移除切片中不包含关键字的元素
type Struct ¶
type Struct[T any] struct { Value T // contains filtered or unexported fields }
Struct 是一个泛型结构体,提供并发控制
type StructSlice ¶
type StructSlice[T any] struct { Values []T // 存储实际的字符串切片数据 // contains filtered or unexported fields }
StructSlice 结构体,用于存储字符串切片,并通过locker来控制线程安全
func NewStructSlice ¶
func NewStructSlice[T any](values []T, threadSafe bool) *StructSlice[T]
NewStructSlice 函数创建StructSlice实例,可以选择是否线程安全
func (*StructSlice[T]) Clone ¶
func (s *StructSlice[T]) Clone(threadSafe bool) *StructSlice[T]
Clone 方法克隆切片
func (*StructSlice[T]) RemoveAtIndex ¶
func (s *StructSlice[T]) RemoveAtIndex(index int, allowChangeOrder bool)
RemoveAtIndex 方法移除指定索引的元素
func (*StructSlice[T]) RemoveAtIndices ¶
func (s *StructSlice[T]) RemoveAtIndices(indices []int, allowChangeOrder bool)
RemoveAtIndices 方法根据一组索引移除多个元素
type ThreadSafeFloat32 ¶
type ThreadSafeFloat32 struct {
// contains filtered or unexported fields
}
ThreadSafeFloat32 结构体提供了线程安全的浮点数操作
func (*ThreadSafeFloat32) Add ¶
func (tsf *ThreadSafeFloat32) Add(delta float32) float32
Add 方法使用原子操作安全地增加浮点数的值
func (*ThreadSafeFloat32) Set ¶
func (tsf *ThreadSafeFloat32) Set(value float32)
Set 方法使用原子操作安全地设置浮点数的值
func (*ThreadSafeFloat32) String ¶
func (tsf *ThreadSafeFloat32) String() string
String 方法将浮点数转换为字符串
type ThreadSafeFloat64 ¶
type ThreadSafeFloat64 struct {
// contains filtered or unexported fields
}
ThreadSafeFloat64 结构体提供了线程安全的浮点数操作
func (*ThreadSafeFloat64) Add ¶
func (tsf *ThreadSafeFloat64) Add(delta float64) float64
Add 方法使用原子操作安全地增加浮点数的值
func (*ThreadSafeFloat64) Set ¶
func (tsf *ThreadSafeFloat64) Set(value float64)
Set 方法使用原子操作安全地设置浮点数的值
func (*ThreadSafeFloat64) String ¶
func (tsf *ThreadSafeFloat64) String() string
String 方法将浮点数转换为字符串
type ThreadSafeInt32 ¶
type ThreadSafeInt32 struct {
// contains filtered or unexported fields
}
ThreadSafeInt32 结构体提供一个线程安全的整数类型
func (*ThreadSafeInt32) Add ¶
func (tsi *ThreadSafeInt32) Add(delta int32) int32
Add 方法使用原子操作来安全地增加整数值,并返回新值
type ThreadSafeInt64 ¶
type ThreadSafeInt64 struct {
// contains filtered or unexported fields
}
ThreadSafeInt64 结构体提供一个线程安全的整数类型
func (*ThreadSafeInt64) Add ¶
func (tsi *ThreadSafeInt64) Add(delta int64) int64
Add 方法使用原子操作来安全地增加整数值,并返回新值
type ThreadSafeUInt32 ¶
type ThreadSafeUInt32 struct {
// contains filtered or unexported fields
}
ThreadSafeUInt32 结构体包含一个无符号32位整型数值,确保线程安全
func (*ThreadSafeUInt32) Add ¶
func (tsi *ThreadSafeUInt32) Add(delta uint32) uint32
Add 方法使用原子操作增加数值,并返回新值
func (*ThreadSafeUInt32) String ¶
func (tsi *ThreadSafeUInt32) String() string
String 方法将数值转换为其十进制的字符串表示形式
type ThreadSafeUInt64 ¶
type ThreadSafeUInt64 struct {
// contains filtered or unexported fields
}
ThreadSafeUInt64 结构体包含一个无符号64位整型数值,确保线程安全
func (*ThreadSafeUInt64) Add ¶
func (tsi *ThreadSafeUInt64) Add(delta uint64) uint64
Add 方法使用原子操作增加数值,并返回新值
func (*ThreadSafeUInt64) String ¶
func (tsi *ThreadSafeUInt64) String() string
String 方法将数值转换为其十进制的字符串表示形式
type Time ¶
Time 结构体用于存储时间值和关联的锁
func (*Time) AppendFormat ¶
AppendFormat 方法将Time按照指定的格式追加到字节切片b中
func (*Time) MarshalBinary ¶
MarshalBinary 方法将Time编码为二进制形式
func (*Time) MarshalJSON ¶
MarshalJSON 方法将Time编码为JSON格式
func (*Time) UnmarshalBinary ¶
UnmarshalBinary 方法从二进制格式解码Time
func (*Time) UnmarshalJSON ¶
UnmarshalJSON 方法从JSON格式解码Time
func (*Time) UnmarshalText ¶
UnmarshalText 方法从文本格式解码Time
type UInt32 ¶
type UInt32 interface { Set(value uint32) // 设置数值 Get() uint32 // 获取数值 Add(delta uint32) uint32 // 对数值进行原子增加操作 String() string // 获取数值的字符串表示形式 }
UInt32 接口声明了一组操作无符号32位整型的方法
func NewNonThreadSafeUInt32 ¶
NewNonThreadSafeUInt32 函数创建一个新的非线程安全的无符号32位整型数值
func NewThreadSafeUInt32 ¶
NewThreadSafeUInt32 函数创建一个新的线程安全的无符号32位整型数值
type UInt64 ¶
type UInt64 interface { Set(value uint64) // 设置数值 Get() uint64 // 获取数值 Add(delta uint64) uint64 // 对数值进行原子增加操作 String() string // 获取数值的字符串表示形式 }
UInt64 接口声明了一组操作无符号64位整型的方法
func NewNonThreadSafeUInt64 ¶
NewNonThreadSafeUInt64 函数创建一个新的非线程安全的无符号64位整型数值
func NewThreadSafeUInt64 ¶
NewThreadSafeUInt64 函数创建一个新的线程安全的无符号64位整型数值