types

package module
v0.0.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 17, 2022 License: MIT Imports: 6 Imported by: 6

README

Go types

This package provides alias/types for maps and slices.
Thread-safe types also supported.

Support atomic

Maps :
Alias Type
Map map[string]any
Slices :
Alias Type
Ints []int
Uints []uint
Int64s []int64
Uint64s []uint64
Floats []float64
Strings []string
Bytes []byte
Bools []bool
Slice []any
Time & Date :
Alias Wrapper Type
Date NewDate() Date
DateTime NewDateTime() DateTime

Support sync

You can use the wrapper types.SyncXXX() :

m := types.SyncMap()
Alias Wrapper Type
TSafeMap SyncMap() map[string]any
TSafeStrings SyncStrings() []string
TSafeInts SyncInts() []int
TSafeUints SyncUints() []uint
TSafeInt64s SyncInt64s() []int64
TSafeUint64s SyncUint64s() []uint64

Documentation

Index

Constants

View Source
const (
	DateYearMonthFormat = "2006-01"
	DateFormat          = "2006-01-02"
	DateTimeFormat      = "2006-01-02 15:04:05"
)

Variables

This section is empty.

Functions

func Bool

func Bool(v *bool) bool

Bool return the value of `v`.

func BoolPtr

func BoolPtr(v bool) *bool

BoolPtr return a pointer of `v`.

func Float64

func Float64(v *float64) float64

Float64 return the value of `v`.

func Float64NoZero

func Float64NoZero(v float64) bool

Float64NoZero is a filter for LenIf, SumIf, MeanIf.

func Float64Ptr

func Float64Ptr(v float64) *float64

Float64Ptr return a pointer of `v`.

func Int

func Int(v *int) int

Int returns the value of `v`.

func Int64

func Int64(v *int64) int64

Int64 return the value of `v`.

func Int64NoZero

func Int64NoZero(v int64) bool

Int64NoZero is a filter for LenIf, SumIf, MeanIf.

func Int64Ptr

func Int64Ptr(v int64) *int64

Int64Ptr return a pointer of `v`.

func IntPtr

func IntPtr(v int) *int

IntPtr return a pointer of `v`.

func String

func String(v *string) string

String returns the value of `v`.

func StringPtr

func StringPtr(v string) *string

StringPtr return the value of `v`.

func Time

func Time(v *time.Time) time.Time

Time return the value of `v`.

func TimePtr

func TimePtr(v time.Time) *time.Time

TimePtr return a pointer of `v`.

func UInt64NoZero

func UInt64NoZero(v uint64) bool

UInt64NoZero is a filter for LenIf, SumIf, MeanIf.

func Uint

func Uint(v *uint) uint

Uint returns the value of `v`.

func Uint64

func Uint64(v *uint64) uint64

Uint64 return the value of `v`.

func Uint64Ptr

func Uint64Ptr(v uint64) *uint64

Uint64Ptr return a pointer of `v`.

func UintPtr

func UintPtr(v uint) *uint

UintPtr return a pointer of `v`.

Types

type Bools

type Bools []bool

Bools is a slice of bool.

func (*Bools) Add

func (s *Bools) Add(values ...bool)

Add new elements to the slice.

func (Bools) Contains

func (s Bools) Contains(values ...bool) bool

Contains say if "s" contains "values".

func (Bools) ContainsOneOf

func (s Bools) ContainsOneOf(values ...bool) bool

ContainsOneOf says if "s" contains one of the "values".

func (Bools) Copy

func (s Bools) Copy() Bools

Copy create a new copy of the slice.

func (Bools) Diff

func (s Bools) Diff(s2 Bools) Bools

Diff returns the difference between "s" and "s2".

func (Bools) Empty

func (s Bools) Empty() bool

Empty says if the slice is empty.

func (Bools) Equal

func (s Bools) Equal(s2 Bools) bool

Equal says if "s" and "s2" are equal.

func (Bools) First

func (s Bools) First() (bool, bool)

First return the value of the first element.

func (Bools) Get

func (s Bools) Get(i int) (bool, bool)

Get the element "i" and say if it has been found.

func (Bools) Intersect

func (s Bools) Intersect(s2 Bools) Bools

Intersect return the intersection between "s" and "s2".

func (Bools) Last

func (s Bools) Last() (bool, bool)

Last return the value of the last element.

func (Bools) Len

func (s Bools) Len() int

Len returns the size of the slice.

func (*Bools) Reset

func (s *Bools) Reset()

Reset the slice.

func (Bools) S

func (s Bools) S() (out []any)

S convert s into []any

func (Bools) Take

func (s Bools) Take(n int) (out Bools)

Take n element and return a new slice.

type Bytes

type Bytes []byte

Bytes is a slice of byte.

func (*Bytes) Add

func (s *Bytes) Add(values ...byte)

Add new elements to the slice.

func (Bytes) Contains

func (s Bytes) Contains(values ...byte) bool

Contains say if "s" contains "values".

func (Bytes) ContainsOneOf

func (s Bytes) ContainsOneOf(values ...byte) bool

ContainsOneOf says if "s" contains one of the "values".

func (Bytes) Copy

func (s Bytes) Copy() Bytes

Copy create a new copy of the slice.

func (Bytes) Diff

func (s Bytes) Diff(s2 Bytes) Bytes

Diff returns the difference between "s" and "s2".

func (Bytes) Empty

func (s Bytes) Empty() bool

Empty says if the slice is empty.

func (Bytes) Equal

func (s Bytes) Equal(s2 Bytes) bool

Equal says if "s" and "s2" are equal.

func (Bytes) Find

func (s Bytes) Find(matcher func(v byte) bool) (byte, bool)

Find the first element matching the pattern.

func (Bytes) FindAll

func (s Bytes) FindAll(matcher func(v byte) bool) Bytes

FindAll elements matching the pattern.

func (Bytes) First

func (s Bytes) First() (byte, bool)

First return the value of the first element.

func (Bytes) Get

func (s Bytes) Get(i int) (byte, bool)

Get the element "i" and say if it has been found.

func (Bytes) Intersect

func (s Bytes) Intersect(s2 Bytes) Bytes

Intersect return the intersection between "s" and "s2".

func (Bytes) Last

func (s Bytes) Last() (byte, bool)

Last return the value of the last element.

func (Bytes) Len

func (s Bytes) Len() int

Len returns the size of the slice.

func (*Bytes) Reset

func (s *Bytes) Reset()

Reset the slice.

func (Bytes) S

func (s Bytes) S() (out []any)

S convert s into []any

func (Bytes) Take

func (s Bytes) Take(n int) (out Bytes)

Take n element and return a new slice.

type Date

type Date struct {
	time.Time
}

Date is a wrapper around time.Time.

func NewDate

func NewDate(t time.Time) Date

NewDate returns a new date from a time.Time.

func ParseDate

func ParseDate(t string) Date

ParseDate returns the Date of the given string.

func (Date) MarshalJSON

func (d Date) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (Date) String

func (d Date) String() string

String returns the string representation of the date.

func (*Date) UnmarshalJSON added in v0.0.5

func (d *Date) UnmarshalJSON(b []byte) (err error)

func (Date) Value

func (d Date) Value() (driver.Value, error)

Value implements the database.Valuer interface.

type DateTime

type DateTime struct {
	time.Time
}

DateTime is a wrapper around time.Time.

func NewDateTime

func NewDateTime(t time.Time) DateTime

NewDateTime create a new DateTime from a time.Time.

func ParseDateTime

func ParseDateTime(t string) DateTime

ParseDateTime returns the DateTime of the given string.

func (DateTime) MarshalJSON

func (d DateTime) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (DateTime) String

func (d DateTime) String() string

String returns the string representation of the datetime.

func (DateTime) Value

func (d DateTime) Value() (driver.Value, error)

Value implements the database.Valuer interface.

type DateYearMonth

type DateYearMonth struct {
	time.Time
}

DateYearMonth is a wrapper around time.Time.

func NewDateYearMonth

func NewDateYearMonth(t time.Time) DateYearMonth

NewDateYearMonth returns a new date from a time.Time.

func ParseDateYearMonth

func ParseDateYearMonth(t string) DateYearMonth

ParseDateYearMonth returns the DateYearMonth of the given string.

func (DateYearMonth) MarshalJSON

func (d DateYearMonth) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (DateYearMonth) String

func (d DateYearMonth) String() string

String returns the string representation of the date.

func (DateYearMonth) Value

func (d DateYearMonth) Value() (driver.Value, error)

Value implements the database.Valuer interface.

type Floats

type Floats []float64

Floats is a slice of float64.

func (*Floats) Add

func (s *Floats) Add(values ...float64)

Add new elements to the slice.

func (Floats) Contains

func (s Floats) Contains(values ...float64) bool

Contains say if "s" contains "values".

func (Floats) ContainsOneOf

func (s Floats) ContainsOneOf(values ...float64) bool

ContainsOneOf says if "s" contains one of the "values".

func (Floats) Copy

func (s Floats) Copy() Floats

Copy create a new copy of the slice.

func (Floats) Diff

func (s Floats) Diff(s2 Floats) Floats

Diff returns the difference between "s" and "s2".

func (Floats) Empty

func (s Floats) Empty() bool

Empty says if the slice is empty.

func (Floats) Equal

func (s Floats) Equal(s2 Floats) bool

Equal says if "s" and "s2" are equal.

func (Floats) Find

func (s Floats) Find(matcher func(v float64) bool) (float64, bool)

Find the first element matching the pattern.

func (Floats) FindAll

func (s Floats) FindAll(matcher func(v float64) bool) Floats

FindAll elements matching the pattern.

func (Floats) First

func (s Floats) First() (float64, bool)

First return the value of the first element.

func (Floats) Get

func (s Floats) Get(i int) (float64, bool)

Get the element "i" and say if it has been found.

func (Floats) Intersect

func (s Floats) Intersect(s2 Floats) Floats

Intersect return the intersection between "s" and "s2".

func (Floats) Last

func (s Floats) Last() (float64, bool)

Last return the value of the last element.

func (Floats) Len

func (s Floats) Len() int

Len returns the size of the slice.

func (Floats) LenIf

func (s Floats) LenIf(f func(v float64) bool) (n int)

LenIf return the size of the slice if the filter is valid.

func (Floats) Mean

func (s Floats) Mean() (mean float64)

Mean of the slice.

func (Floats) MeanIf

func (s Floats) MeanIf(f func(v float64) bool) (mean float64)

MeanIf the filter is valid of the slice.

func (*Floats) Reset

func (s *Floats) Reset()

Reset the slice.

func (Floats) S

func (s Floats) S() (out []any)

S convert s to []any

func (Floats) Sum

func (s Floats) Sum() (sum float64)

Sum of the slice.

func (Floats) SumIf

func (s Floats) SumIf(f func(v float64) bool) (sum float64)

SumIf the filter is valid of the slice.

func (Floats) Take

func (s Floats) Take(n int) (out Floats)

Take n element and return a new slice.

type Int64s

type Int64s []int64

Int64s is a slice of int64.

func (*Int64s) Add

func (s *Int64s) Add(values ...int64)

Add new elements to the slice.

func (Int64s) Contains

func (s Int64s) Contains(values ...int64) bool

Contains say if "s" contains "values".

func (Int64s) ContainsOneOf

func (s Int64s) ContainsOneOf(values ...int64) bool

ContainsOneOf says if "s" contains one of the "values".

func (Int64s) Copy

func (s Int64s) Copy() Int64s

Copy create a new copy of the slice.

func (Int64s) Diff

func (s Int64s) Diff(s2 Int64s) Int64s

Diff returns the difference between "s" and "s2".

func (Int64s) Empty

func (s Int64s) Empty() bool

Empty says if the slice is empty.

func (Int64s) Equal

func (s Int64s) Equal(s2 Int64s) bool

Equal says if "s" and "s2" are equal.

func (Int64s) Find

func (s Int64s) Find(matcher func(v int64) bool) (int64, bool)

Find the first element matching the pattern.

func (Int64s) FindAll

func (s Int64s) FindAll(matcher func(v int64) bool) Int64s

FindAll elements matching the pattern.

func (Int64s) First

func (s Int64s) First() (int64, bool)

First return the value of the first element.

func (Int64s) Get

func (s Int64s) Get(i int) (int64, bool)

Get the element "i" and say if it has been found.

func (Int64s) Intersect

func (s Int64s) Intersect(s2 Int64s) Int64s

Intersect return the intersection between "s" and "s2".

func (Int64s) Last

func (s Int64s) Last() (int64, bool)

Last return the value of the last element.

func (Int64s) Len

func (s Int64s) Len() int

Len return the size of the slice.

func (Int64s) LenIf

func (s Int64s) LenIf(f func(v int64) bool) (n int)

LenIf return the size of the slice if the filter is valid.

func (Int64s) Mean

func (s Int64s) Mean() (mean float64)

Mean of the slice.

func (Int64s) MeanIf

func (s Int64s) MeanIf(f func(v int64) bool) (mean float64)

MeanIf the filter is valid of the slice.

func (*Int64s) Reset

func (s *Int64s) Reset()

Reset the slice.

func (Int64s) S

func (s Int64s) S() (out []any)

S convert s into []any

func (Int64s) Sum

func (s Int64s) Sum() (sum int64)

Sum of the slice.

func (Int64s) SumIf

func (s Int64s) SumIf(f func(v int64) bool) (sum int64)

SumIf the filter is valid of the slice.

func (Int64s) Take

func (s Int64s) Take(n int) (out Int64s)

Take n element and return a new slice.

type Ints

type Ints []int

Ints is a slice of int.

func (*Ints) Add

func (s *Ints) Add(values ...int)

Add new elements to the slice.

func (Ints) Contains

func (s Ints) Contains(values ...int) bool

Contains say if "s" contains "values".

func (Ints) ContainsOneOf

func (s Ints) ContainsOneOf(values ...int) bool

ContainsOneOf says if "s" contains one of the "values".

func (Ints) Copy

func (s Ints) Copy() Ints

Copy create a new copy of the slice.

func (Ints) Diff

func (s Ints) Diff(s2 Ints) Ints

Diff returns the difference between "s" and "s2".

func (Ints) Empty

func (s Ints) Empty() bool

Empty says if the slice is empty.

func (Ints) Equal

func (s Ints) Equal(s2 Ints) bool

Equal says if "s" and "s2" are equal.

func (Ints) Find

func (s Ints) Find(matcher func(v int) bool) (int, bool)

Find the first element matching the pattern.

func (Ints) FindAll

func (s Ints) FindAll(matcher func(v int) bool) Ints

FindAll elements matching the pattern.

func (Ints) First

func (s Ints) First() (int, bool)

First return the value of the first element.

func (Ints) Get

func (s Ints) Get(i int) (int, bool)

Get the element "i" and say if it has been found.

func (Ints) Intersect

func (s Ints) Intersect(s2 Ints) Ints

Intersect return the intersection between "s" and "s2".

func (Ints) Last

func (s Ints) Last() (int, bool)

Last return the value of the last element.

func (Ints) Len

func (s Ints) Len() int

Len return the size of the slice.

func (Ints) LenIf

func (s Ints) LenIf(f func(v int) bool) (n int)

LenIf return the size of the slice if the filter is valid.

func (Ints) Mean

func (s Ints) Mean() (mean float64)

Mean of the slice.

func (Ints) MeanIf

func (s Ints) MeanIf(f func(v int) bool) (mean float64)

MeanIf the filter is valid of the slice.

func (*Ints) Reset

func (s *Ints) Reset()

Reset the slice.

func (Ints) S

func (s Ints) S() (out []any)

S convert s into []any

func (Ints) Sum

func (s Ints) Sum() (sum int)

Sum of the slice.

func (Ints) SumIf

func (s Ints) SumIf(f func(v int) bool) (sum int)

SumIf the filter is valid of the slice.

func (Ints) Take

func (s Ints) Take(n int) (out Ints)

Take n element and return a new slice.

type Map

type Map map[string]any

Map is a hashmap.

func (Map) Add

func (m Map) Add(k string, v any)

Add a value to the map if the key doesn't exists.

func (Map) Copy

func (m Map) Copy() Map

Copy the keys and values into a new map.

func (Map) Find

func (m Map) Find(matcher Matcher) (string, any, bool)

Find the first element matching the pattern.

func (Map) FindAll

func (m Map) FindAll(matcher Matcher) Map

FindAll elements matching the pattern.

func (Map) Get

func (m Map) Get(k string) (v any, ok bool)

Get an element from the map.

func (Map) Int

func (m Map) Int(k string) int

func (Map) Int64

func (m Map) Int64(k string) int64

func (Map) Int64Ptr

func (m Map) Int64Ptr(k string) *int64

func (Map) IntPtr

func (m Map) IntPtr(k string) *int

func (Map) KeyExists

func (m Map) KeyExists(keys ...string) bool

KeyExists says if the list of keys exists.

func (Map) Keys

func (m Map) Keys() []string

Keys return the list of keys.

func (Map) Len

func (m Map) Len() int

Len returns the size of the map.

func (Map) Merge added in v0.0.3

func (m Map) Merge(sub map[string]any)

Merge another map.

func (*Map) Reset

func (m *Map) Reset()

Reset the values of the map.

func (Map) Set

func (m Map) Set(k string, v any)

Set a new value in the map.

func (Map) String

func (m Map) String(k string) string

String get an element from the map as string.

func (Map) StringPtr

func (m Map) StringPtr(k string) *string

func (Map) Time

func (m Map) Time(k string) time.Time

func (Map) TimePtr

func (m Map) TimePtr(k string) *time.Time

func (Map) Uint64

func (m Map) Uint64(k string) uint64

func (Map) Uint64Ptr

func (m Map) Uint64Ptr(k string) *uint64

func (Map) Values

func (m Map) Values() []any

Values return the list of values.

type Matcher

type Matcher func(k string, v any) bool

type Point

type Point struct {
	Lat float64 `json:"lat"`
	Lng float64 `json:"lng"`
}

Point is the representation of a couple of latitude and longitude.

func (Point) Encode

func (p Point) Encode() []float64

Encode the point to a slice of coordinates.

type Points

type Points []Point

Points is a slice of Point.

func (Points) Encode

func (p Points) Encode() (out [][]float64)

Encode the series of points.

func (Points) Polyline

func (p Points) Polyline() Polyline

Polyline encode the series of points into string polyline.

type Polyline

type Polyline string

Polyline is the representation of a Google standard polyline.

func (Polyline) Decode

func (p Polyline) Decode() (out Points)

Decode the polyline to Points.

func (Polyline) String

func (p Polyline) String() string

String convert the polyline to string.

func (Polyline) Value

func (p Polyline) Value() (driver.Value, error)

Value implements the database.Valuer interface.

type Slice

type Slice []any

Slice is a slice of any.

func (*Slice) Add

func (s *Slice) Add(values ...any)

Add new elements to the slice.

func (Slice) Contains

func (s Slice) Contains(values ...any) bool

Contains say if "s" contains "values".

func (Slice) ContainsOneOf

func (s Slice) ContainsOneOf(values ...any) bool

ContainsOneOf says if "s" contains one of the "values".

func (Slice) Copy

func (s Slice) Copy() Slice

Copy create a new copy of the slice.

func (Slice) Diff

func (s Slice) Diff(s2 Slice) Slice

Diff returns the difference between "s" and "s2".

func (Slice) Empty

func (s Slice) Empty() bool

Empty says if the slice is empty.

func (Slice) Equal

func (s Slice) Equal(s2 Slice) bool

Equal says if "s" and "s2" are equal.

func (Slice) Find

func (s Slice) Find(matcher func(v any) bool) (any, bool)

Find the first element matching the pattern.

func (Slice) FindAll

func (s Slice) FindAll(matcher func(v any) bool) Slice

FindAll elements matching the pattern.

func (Slice) First

func (s Slice) First() (any, bool)

First return the value of the first element.

func (Slice) Get

func (s Slice) Get(i int) (any, bool)

Get the element "i" and say if it has been found.

func (Slice) Intersect

func (s Slice) Intersect(s2 Slice) Slice

Intersect return the intersection between "s" and "s2".

func (Slice) Last

func (s Slice) Last() (any, bool)

Last return the value of the last element.

func (Slice) Len

func (s Slice) Len() int

Len returns the size of the slice.

func (*Slice) Reset

func (s *Slice) Reset()

Reset the slice.

func (Slice) S

func (s Slice) S() (out []any)

S convert s into []any

func (Slice) Take

func (s Slice) Take(n int) (out Slice)

Take n element and return a new slice.

type Strings

type Strings []string

Strings is a slice of string.

func (*Strings) Add

func (s *Strings) Add(values ...string)

Add new elements to the slice.

func (Strings) Contains

func (s Strings) Contains(values ...string) bool

Contains say if "s" contains "values".

func (Strings) ContainsOneOf

func (s Strings) ContainsOneOf(values ...string) bool

ContainsOneOf says if "s" contains one of the "values".

func (Strings) Copy

func (s Strings) Copy() Strings

Copy create a new copy of the slice.

func (Strings) Diff

func (s Strings) Diff(s2 Strings) Strings

Diff returns the difference between "s" and "s2".

func (Strings) Empty

func (s Strings) Empty() bool

Empty says if the slice is empty.

func (Strings) Equal

func (s Strings) Equal(s2 Strings) bool

Equal says if "s" and "s2" are equal.

func (Strings) Find

func (s Strings) Find(matcher func(v string) bool) (string, bool)

Find the first element matching the pattern.

func (Strings) FindAll

func (s Strings) FindAll(matcher func(v string) bool) Strings

FindAll elements matching the pattern.

func (Strings) First

func (s Strings) First() (string, bool)

First return the value of the first element.

func (Strings) Get

func (s Strings) Get(i int) (string, bool)

Get the element "i" and say if it has been found.

func (Strings) Intersect

func (s Strings) Intersect(s2 Strings) Strings

Intersect return the intersection between "s" and "s2".

func (Strings) Last

func (s Strings) Last() (string, bool)

Last return the value of the last element.

func (Strings) Len

func (s Strings) Len() int

Len returns the size of the slice.

func (*Strings) Reset

func (s *Strings) Reset()

Reset the slice.

func (Strings) S

func (s Strings) S() (out []any)

S convert s into []any

func (Strings) Take

func (s Strings) Take(n int) (out Strings)

Take n element and return a new slice.

type TSafeInt64s

type TSafeInt64s interface {
	// Reset the slice.
	Reset()

	// Contains say if "s" contains "values".
	Contains(...int64) bool

	// ContainsOneOf says if "s" contains one of the "values".
	ContainsOneOf(...int64) bool

	// Copy create a new copy of the slice.
	Copy() TSafeInt64s

	// Diff returns the difference between "s" and "s2".
	Diff(Int64s) Int64s

	// Empty says if the slice is empty.
	Empty() bool

	// Equal says if "s" and "s2" are equal.
	Equal(Int64s) bool

	// Find the first element matching the pattern.
	Find(func(v int64) bool) (int64, bool)

	// FindAll elements matching the pattern.
	FindAll(func(v int64) bool) Int64s

	// First return the value of the first element.
	First() (int64, bool)

	// Get the element "i" and say if it has been found.
	Get(int) (int64, bool)

	// Intersect return the intersection between "s" and "s2".
	Intersect(Int64s) Int64s

	// Last return the value of the last element.
	Last() (int64, bool)

	// Len returns the size of the slice.
	Len() int

	// Take n element and return a new slice.
	Take(int) Int64s

	// S convert s into []any
	S() []any

	// S convert s into Int64s
	Int64s() Int64s
}

func SyncInt64s

func SyncInt64s() TSafeInt64s

type TSafeInts

type TSafeInts interface {
	// Reset the slice.
	Reset()

	// Contains say if "s" contains "values".
	Contains(...int) bool

	// ContainsOneOf says if "s" contains one of the "values".
	ContainsOneOf(...int) bool

	// Copy create a new copy of the slice.
	Copy() TSafeInts

	// Diff returns the difference between "s" and "s2".
	Diff(Ints) Ints

	// Empty says if the slice is empty.
	Empty() bool

	// Equal says if "s" and "s2" are equal.
	Equal(Ints) bool

	// Find the first element matching the pattern.
	Find(func(v int) bool) (int, bool)

	// FindAll elements matching the pattern.
	FindAll(func(v int) bool) Ints

	// First return the value of the first element.
	First() (int, bool)

	// Get the element "i" and say if it has been found.
	Get(int) (int, bool)

	// Intersect return the intersection between "s" and "s2".
	Intersect(Ints) Ints

	// Last return the value of the last element.
	Last() (int, bool)

	// Len returns the size of the slice.
	Len() int

	// Take n element and return a new slice.
	Take(int) Ints

	// S convert s into []any
	S() []any

	// Ints convert s into Ints
	Ints() Ints
}

func SyncInts

func SyncInts() TSafeInts

type TSafeMap

type TSafeMap interface {
	// Add a new entry if the given key is not filled.
	Add(string, any)

	// Find the first element matching the pattern.
	Find(Matcher) (string, any, bool)

	// FindAll elements matching the pattern.
	FindAll(Matcher) Map

	// Get an element from the key.
	Get(string) (any, bool)

	// Map convert TSafeMap to Map.
	Map() Map

	// Set a new entry or change an entry for the given key "k".
	Set(string, any)

	// Reset the values.
	Reset()
}

TSafeMap abstract the implementation of SyncMap.

func SyncMap

func SyncMap() TSafeMap

SyncMap return a new ThreadSafeMap.

type TSafeStrings

type TSafeStrings interface {
	// Reset the slice.
	Reset()

	// Contains say if "s" contains "values".
	Contains(...string) bool

	// ContainsOneOf says if "s" contains one of the "values".
	ContainsOneOf(...string) bool

	// Copy create a new copy of the slice.
	Copy() TSafeStrings

	// Diff returns the difference between "s" and "s2".
	Diff(Strings) Strings

	// Empty says if the slice is empty.
	Empty() bool

	// Equal says if "s" and "s2" are equal.
	Equal(Strings) bool

	// Find the first element matching the pattern.
	Find(func(v string) bool) (string, bool)

	// FindAll elements matching the pattern.
	FindAll(func(v string) bool) Strings

	// First return the value of the first element.
	First() (string, bool)

	// Get the element "i" and say if it has been found.
	Get(int) (string, bool)

	// Intersect return the intersection between "s" and "s2".
	Intersect(Strings) Strings

	// Last return the value of the last element.
	Last() (string, bool)

	// Len returns the size of the slice.
	Len() int

	// Take n element and return a new slice.
	Take(int) Strings

	// S convert s into []any
	S() []any

	// S convert s into Strings
	Strings() Strings
}

func SyncStrings

func SyncStrings() TSafeStrings

type TSafeUint64s

type TSafeUint64s interface {
	// Reset the slice.
	Reset()

	// Contains say if "s" contains "values".
	Contains(...uint64) bool

	// ContainsOneOf says if "s" contains one of the "values".
	ContainsOneOf(...uint64) bool

	// Copy create a new copy of the slice.
	Copy() TSafeUint64s

	// Diff returns the difference between "s" and "s2".
	Diff(Uint64s) Uint64s

	// Empty says if the slice is empty.
	Empty() bool

	// Equal says if "s" and "s2" are equal.
	Equal(Uint64s) bool

	// Find the first element matching the pattern.
	Find(func(v uint64) bool) (uint64, bool)

	// FindAll elements matching the pattern.
	FindAll(func(v uint64) bool) Uint64s

	// First return the value of the first element.
	First() (uint64, bool)

	// Get the element "i" and say if it has been found.
	Get(int) (uint64, bool)

	// Intersect return the intersection between "s" and "s2".
	Intersect(Uint64s) Uint64s

	// Last return the value of the last element.
	Last() (uint64, bool)

	// Len returns the size of the slice.
	Len() int

	// Take n element and return a new slice.
	Take(int) Uint64s

	// S convert s into []any
	S() []any

	// S convert s into Uint64s
	Uint64s() Uint64s
}

func SyncUint64s

func SyncUint64s() TSafeUint64s

type TSafeUints

type TSafeUints interface {
	// Reset the slice.
	Reset()

	// Contains say if "s" contains "values".
	Contains(...uint) bool

	// ContainsOneOf says if "s" contains one of the "values".
	ContainsOneOf(...uint) bool

	// Copy create a new copy of the slice.
	Copy() TSafeUints

	// Diff returns the difference between "s" and "s2".
	Diff(Uints) Uints

	// Empty says if the slice is empty.
	Empty() bool

	// Equal says if "s" and "s2" are equal.
	Equal(Uints) bool

	// Find the first element matching the pattern.
	Find(func(v uint) bool) (uint, bool)

	// FindAll elements matching the pattern.
	FindAll(func(v uint) bool) Uints

	// First return the value of the first element.
	First() (uint, bool)

	// Get the element "i" and say if it has been found.
	Get(int) (uint, bool)

	// Intersect return the intersection between "s" and "s2".
	Intersect(Uints) Uints

	// Last return the value of the last element.
	Last() (uint, bool)

	// Len returns the size of the slice.
	Len() int

	// Take n element and return a new slice.
	Take(int) Uints

	// S convert s into []any
	S() []any

	// S convert s into Uints
	Uints() Uints
}

func SyncUints

func SyncUints() TSafeUints

type Uint64s

type Uint64s []uint64

Uint64s is a slice of uint64.

func (*Uint64s) Add

func (s *Uint64s) Add(values ...uint64)

Add new elements to the slice.

func (Uint64s) Contains

func (s Uint64s) Contains(values ...uint64) bool

Contains says if "s" contains "values".

func (Uint64s) ContainsOneOf

func (s Uint64s) ContainsOneOf(values ...uint64) bool

ContainsOneOf says if "s" contains one of the "values".

func (Uint64s) Copy

func (s Uint64s) Copy() Uint64s

Copy create a new copy of the slice.

func (Uint64s) Diff

func (s Uint64s) Diff(s2 Uint64s) Uint64s

Diff return the difference between "s" and "s2".

func (Uint64s) Empty

func (s Uint64s) Empty() bool

Empty says if the slice is empty.

func (Uint64s) Equal

func (s Uint64s) Equal(s2 Uint64s) bool

Equal says if "s" and "s2" are equal.

func (Uint64s) Excludes added in v0.0.6

func (s Uint64s) Excludes(s2 Uint64s) Uint64s

Excludes elements from s2.

func (Uint64s) Filter added in v0.0.6

func (s Uint64s) Filter(matcher func(v uint64) bool) Uint64s

Filter elements matching the pattern.

func (Uint64s) Find

func (s Uint64s) Find(matcher func(v uint64) bool) (uint64, bool)

Find the first element matching the pattern.

func (Uint64s) FindAll

func (s Uint64s) FindAll(matcher func(v uint64) bool) Uint64s

FindAll elements matching the pattern.

func (Uint64s) First

func (s Uint64s) First() (uint64, bool)

First return the value of the first element.

func (Uint64s) Get

func (s Uint64s) Get(i int) (uint64, bool)

Get the element "i" and say if it has been found.

func (Uint64s) Intersect

func (s Uint64s) Intersect(s2 Uint64s) Uint64s

Intersect return the intersection between "s" and "s2".

func (Uint64s) Last

func (s Uint64s) Last() (uint64, bool)

Last return the value of the last element.

func (Uint64s) Len

func (s Uint64s) Len() int

Len return the size of the slice.

func (Uint64s) LenIf

func (s Uint64s) LenIf(f func(v uint64) bool) (n int)

LenIf return the size of the slice if the filter is valid.

func (Uint64s) Mean

func (s Uint64s) Mean() (mean float64)

Mean of the slice.

func (Uint64s) MeanIf

func (s Uint64s) MeanIf(f func(v uint64) bool) (mean float64)

MeanIf the filter is valid of the slice.

func (*Uint64s) Reset

func (s *Uint64s) Reset()

Reset the slice.

func (Uint64s) S

func (s Uint64s) S() (out []any)

S convert Uint64s into []any

func (Uint64s) Sum

func (s Uint64s) Sum() (sum uint64)

Sum of the slice.

func (Uint64s) SumIf

func (s Uint64s) SumIf(f func(v uint64) bool) (sum uint64)

SumIf the filter is valid of the slice.

func (Uint64s) Take

func (s Uint64s) Take(n int) (out Uint64s)

Take n element and return a new slice.

type Uints

type Uints []uint

Uints is a slice of uint.

func (*Uints) Add

func (s *Uints) Add(values ...uint)

Add new elements to the slice.

func (Uints) Contains

func (s Uints) Contains(values ...uint) bool

Contains say if "s" contains "values".

func (Uints) ContainsOneOf

func (s Uints) ContainsOneOf(values ...uint) bool

ContainsOneOf says if "s" contains one of the "values".

func (Uints) Copy

func (s Uints) Copy() Uints

Copy create a new copy of the slice.

func (Uints) Diff

func (s Uints) Diff(s2 Uints) Uints

Diff return the difference between "s" and "s2".

func (Uints) Empty

func (s Uints) Empty() bool

Empty says if the slice is empty.

func (Uints) Equal

func (s Uints) Equal(s2 Uints) bool

Equal says if "s" and "s2" are equal.

func (Uints) Find

func (s Uints) Find(matcher func(v uint) bool) (uint, bool)

Find the first element matching the pattern.

func (Uints) FindAll

func (s Uints) FindAll(matcher func(v uint) bool) Uints

FindAll elements matching the pattern.

func (Uints) First

func (s Uints) First() (uint, bool)

First return the value of the first element.

func (Uints) Get

func (s Uints) Get(i int) (uint, bool)

Get the element "i" and say if it has been found.

func (Uints) Intersect

func (s Uints) Intersect(s2 Uints) Uints

Intersect return the intersection between "s" and "s2".

func (Uints) Last

func (s Uints) Last() (uint, bool)

Last return the value of the last element.

func (Uints) Len

func (s Uints) Len() int

Len return the size of the slice.

func (Uints) Mean

func (s Uints) Mean() (mean float64)

Mean of the slice.

func (*Uints) Reset

func (s *Uints) Reset()

Reset the slice.

func (Uints) S

func (s Uints) S() (out []any)

S convert Uints into []any

func (Uints) Sum

func (s Uints) Sum() (sum uint)

Sum of the slice.

func (Uints) Take

func (s Uints) Take(n int) (out Uints)

Take n element and return a new slice.

func (Uints) Uint64s

func (s Uints) Uint64s() (out Uint64s)

Uint64s convert Uints to Uint64s

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL