Documentation ¶
Overview ¶
Package functools is a simple Golang library including some commonly used functional programming tools. There is no generic in golang, so most of the functions will return interface{}, be sure to type assert it to the type you want before you use it.
*********************************************************
- Author :
- Email :
- Last modified : 2016-01-23 10:24
- Filename : goerr.go
- Description : 错误生成
- ******************************************************
This example demonstrates a priority queue built using the heap interface.
*********************************************************
- Author :
- Email :
- Last modified : 2016-09-15 17:29:51
- Filename : random.go
- Description : 常用的随机数工具方法
- ******************************************************
Package randutil provides various convenience functions for dealing with random numbers and strings.
*********************************************************
- Author :
- Email :
- Last modified : 2016-09-15 16:22:18
- Filename : string.go
- Description : 常用的字符串工具方法
- ******************************************************
*********************************************************
- Author :
- Email :
- Last modified : 2016-09-15 16:22:18
- Filename : times.go
- Description : 常用的时间工具方法
- ******************************************************
*********************************************************
- Author :
- Email :
- Last modified : 2016-07-07 23:42
- Filename : to.go
- Description : go数据类型到字符数组的转换
- ******************************************************
Index ¶
- Constants
- Variables
- func AalidataPwd(name string) (b bool)
- func AccountRegexp(account string) bool
- func AddDateTime(year, month, day int) (int, time.Month, int)
- func After() bool
- func All(function, slice interface{}) (ret bool, err error)
- func AlphaString(n int) (string, error)
- func AlphaStringRange(min, max int) (string, error)
- func Any(function, slice interface{}) (ret bool, err error)
- func Apply(function, slice interface{}) (ret interface{}, err error)
- func Atoi(s string) (int, error)
- func Base62decode(base62 string) uint64
- func Base62encode(num uint64) string
- func Base64Decode(data string) string
- func Base64Encode(data string) string
- func Before() bool
- func Bool(value interface{}) bool
- func BsonNow() time.Time
- func BubbleSort(r []int)
- func Bytes(val interface{}) []byte
- func Bytes2String(b []byte) (s string)
- func BytesToInt(b []byte) int
- func BytesToInt64(b []byte) int64
- func CamelName(name string) string
- func ChoiceInt(choices []int) (int, error)
- func ChoiceString(choices []string) (string, error)
- func Clone(dst, src interface{}) error
- func Compose(functions ...interface{}) (ret func(...interface{}) interface{}, err error)
- func Convert(value interface{}, t reflect.Kind) (interface{}, error)
- func ConvertString(inter interface{}, precs ...int) string
- func Date(year, month, day, hour, min, sec, nsec int) time.Time
- func DateLocal(year int, month time.Month, day, hour, min, sec, nsec int) time.Time
- func DateStr() string
- func DateTime() (int, time.Month, int)
- func Day() int
- func DayDate() int
- func Decode(data []byte, to interface{}) error
- func Decrypt(data []byte, key []byte) []byte
- func Diff() time.Duration
- func Display(data ...interface{})
- func Dump(v interface{})
- func Duration(val interface{}) time.Duration
- func EmailRegexp(mail string) bool
- func Encode(data interface{}) ([]byte, error)
- func Encrypt(data []byte, key []byte) []byte
- func Equal() bool
- func FileExists(name string) bool
- func Filter(function, slice interface{}) (ret interface{}, err error)
- func Float64(val interface{}) float64
- func Format(format string, ts ...time.Time) string
- func GCSummary() string
- func GenSign(args url.Values, secretKey string) string
- func GetAuth() []rune
- func GetDisplayString(data ...interface{}) string
- func GetExternalIP() (exip string, err error)
- func GetFuncName(i interface{}) string
- func GetGuid() string
- func GetInternalIP() (inip string, err error)
- func GetInternalIP2() (inip string, err error)
- func GetMd5String(s string) string
- func GetPhoto(str string) string
- func GetRandInt32() int32
- func GetRandUint32() uint32
- func GetSalt() string
- func GrepFile(patten string, filename string) (lines []string, err error)
- func Gunzip(r io.Reader) ([]byte, error)
- func Gzip(b []byte, w io.Writer) (int, error)
- func Hour() int
- func InSlice(v string, sl []string) bool
- func InSliceIface(v interface{}, sl []interface{}) bool
- func InetToaton(ipnr string) uint32
- func InetTobton(ipnr net.IP) uint32
- func InetTontoa(ipnr uint32) net.IP
- func Init()
- func InitIllegalNameRune()
- func InsertSort(r []int)
- func InsertionSort(r []int)
- func Int2Str(i int) string
- func Int64(val interface{}) int64
- func Int64ToBytes(n int64) []byte
- func IntRange(min, max int) (int, error)
- func IntToBytes(n int) []byte
- func Ip2Long(ip_address string) float64
- func Ip2long(ipstr string) uint32
- func Itoa(i int) string
- func Kickers(per, second int, f func())
- func LastWeek() (start, end time.Time)
- func LegalName(name string, maxcount int) bool
- func LocalTime() time.Time
- func Long2Ip(long float64) string
- func Md5(text string) string
- func Md5Buf(buf []byte) string
- func Md5Copy(text string) string
- func Md5File(reader io.Reader) string
- func MergeSort(r []int) []int
- func Minute() int
- func Month() time.Month
- func MonthDate() int
- func MonthDays(year int, month int) (days int)
- func MustBool(s string, defaultVal ...bool) bool
- func MustFloat(inter interface{}, defaultVals ...float64) float64
- func MustInt(s string, defaultVal ...int) int
- func MustInt64(s string, defaultVal ...int64) int64
- func Nanosecond() int
- func New(format string, p ...interface{}) error
- func NewError(err error, format string, p ...interface{}) error
- func NewTicker(second int) *time.Ticker
- func NewTickerMilli(millisecond int) *time.Ticker
- func Partial(function interface{}, params ...interface{}) (ret func(...interface{}) interface{}, err error)
- func PhoneRegexp(phone string) bool
- func PhoneValidate(phone string) bool
- func PrintPointerInfo(buf *bytes.Buffer, headlen int, pointers *pointerInfo)
- func Qsort(arr []byte)
- func QuSort(arr []byte, start, end int)
- func QuickSort(r []int)
- func RadixSort(sz []int)
- func RandFloat32() (r float32)
- func RandFloat64() (r float64)
- func RandInt() (r int)
- func RandInt32() (r int32)
- func RandInt32N(n int32) (r int32)
- func RandInt64() (r int64)
- func RandInt64N(n int64) (r int64)
- func RandIntN(n int) (r int)
- func RandStr(i int) (s string)
- func RandString(n int, defaultCharsets ...string) string
- func RandUint32() (r uint32)
- func RandomCreateBytes(n int, alphabets ...byte) []byte
- func RandomCreateBytes2(n int, alphabets ...byte) []byte
- func Reduce(function, slice, initial interface{}) (ret interface{}, err error)
- func RemoteIp(req *http.Request) string
- func Reverse(s string) string
- func ReverseRune(runes []rune) []rune
- func Run(cmd string, args ...string) []byte
- func RunError(cmd string, args ...string) ([]byte, error)
- func RunPrint(cmd string, args ...string)
- func Sdump(v interface{}) string
- func SearchFile(filename string, paths ...string) (fullpath string, err error)
- func SearchString(slice []string, s string) int
- func Second() int
- func Seed()
- func SelectionSort(r []int)
- func SelfDir() string
- func SelfPath() string
- func ShellSort(r []int)
- func Sleep(second int)
- func Sleep64(second int64)
- func SleepRand(second int)
- func SleepRand64(second int64)
- func SliceChunk(slice []interface{}, size int) (chunkslice [][]interface{})
- func SliceDiff(slice1, slice2 []interface{}) (diffslice []interface{})
- func SliceFilter(slice []interface{}, a filtertype) (ftslice []interface{})
- func SliceIndexOf(arr []string, str string) int
- func SliceIntersect(slice1, slice2 []interface{}) (diffslice []interface{})
- func SliceLastIndexOf(arr []string, str string) int
- func SliceMerge(slice1, slice2 []interface{}) (c []interface{})
- func SlicePad(slice []interface{}, size int, val interface{}) []interface{}
- func SliceRand(a []interface{}) (b interface{})
- func SliceRandList(min, max int) []int
- func SliceRange(start, end, step int64) (intslice []int64)
- func SliceReduce(slice []interface{}, a reducetype) (dslice []interface{})
- func SliceRemoveFormSlice(oriArr []string, removeArr []string) []string
- func SliceShuffle(slice []interface{}) []interface{}
- func SliceSum(intslice []int64) (sum int64)
- func SliceUnique(slice []interface{}) (uniqueslice []interface{})
- func Split(s, sep string) []string
- func Stack(skip int, indent string) []byte
- func Stamp2Time(t int64) time.Time
- func Str2Int(s string) (int, error)
- func Str2Local(t string) (int64, error)
- func Str2Time(t string) time.Time
- func Str2Unix(t string) (int64, error)
- func StrToLocalTime(value string) time.Time
- func StrToTime(value string) time.Time
- func String(val interface{}) string
- func String2Bytes(s string) (b []byte)
- func StringAdd(numStr string) string
- func StringAdd2(numStr1, numStr2 string) string
- func StringRand(n int, charset string) (string, error)
- func StringRange(min, max int, charset string) (string, error)
- func Struct2Map(obj interface{}) map[string]interface{}
- func SubStr(str string, begin, length int) (substr string)
- func ThisWeek() (start, end time.Time)
- func Time(val interface{}) time.Time
- func Time2DayDate(now time.Time) int
- func Time2LocalStr(t time.Time) string
- func Time2MonthDate(now time.Time) int
- func Time2Stamp(t time.Time) int64
- func Time2Str(t time.Time) string
- func TimeToHeadphpoto(t int64, userid int, headname int64) (string, string)
- func TimeToPhpotoPath(t int64, userid int) string
- func TimerRun(second int, f func()) *time.Timer
- func TimerStop(timer *time.Timer) bool
- func Timestamp() int64
- func TimestampNano() int64
- func TimestampToday() int64
- func TimestampTodayTime() time.Time
- func TimestampTomorrow() int64
- func TimestampYesterday() int64
- func Uint64(val interface{}) uint64
- func UnderscoreName(name string) string
- func Unix2Day(t int64) int
- func Unix2Fstr(t int64) string
- func Unix2Month(t int64) time.Month
- func Unix2Str(t int64) string
- func Unix2Year(t int64) int
- func UseridCovToInvate(userid string) uint32
- func Weekday() time.Weekday
- func Year() int
- type AesEncrypt
- type Array
- type Attachment
- type BeeMap
- type Buffer
- type Choice
- type Config
- type Email
- type IPTaoBao
- type IPTaoBaoData
- type Item
- type Option
- type PriorityQueue
- type Queue
- type RPCConfig
- type TimeOuter
- type Timer
- type TimerManager
- type TimerQueue
Constants ¶
const ( // Set of characters to use for generating random strings Alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" Numerals = "1234567890" Alphanumeric = Alphabet + Numerals Ascii = Alphanumeric + "~!@#$%^&*()-_+={}[]\\|<,>.?/\"';:`" DefaultCharset = Alphanumeric + "!%@#" )
const ( KindTime reflect.Kind = iota + 1000000000 KindDuration )
const ( XForwardedFor = "X-Forwarded-For" XRealIP = "X-Real-IP" )
const FORMAT string = "2006-01-02 15:04:05"
const FORMATDATA string = "2006-01-02 "
const FORMATSTR string = "2006/01/02/15"
Variables ¶
var (
FormatString = "%v\nthe trace error is\n%s"
)
var IllegalNameRune [13]rune
var MinMaxError = errors.New("Min cannot be greater than max.")
var RandInt32Chan chan int32
*
- Chan中存放随机数
var RandUint32Chan chan uint32
Functions ¶
func AddDateTime ¶
*
- 获取相对年,月,日
- @return int, time.Month, int)
- Some examples: AddDateTime(0, -1, 0) 上月今天时间
func All ¶
All applys a function(the first parameter) returning a boolean value to each element of a slice(second parameter), if all elements make that function return true then All will return true, otherwise false. Notice that All return a boolean value NOT an interface{}
func AlphaString ¶
AlphaString returns a random alphanumeric string n characters long.
func AlphaStringRange ¶
AlphaRange returns a random alphanumeric string at least min and no more than max characters long.
func Any ¶
Any applys a function(the first parameter) returning a boolean value to each element of a slice(second parameter), if there exist at least one element make that function return true then Any will return true, otherwise false. Notice that Any return a boolean value NOT an interface{}
func Apply ¶
func Apply(function, slice interface{}) (ret interface{}, err error)
Apply applys a function(the first parameter) to each element of a slice(second parameter). Just like Map in other language.
func Base64Decode ¶
func Base64Encode ¶
func Bool ¶
func Bool(value interface{}) bool
Tries to convert the argument into a bool. Returns false if any error occurs.
func BsonNow ¶
Now returns the current time with millisecond precision. MongoDB stores timestamps with the same precision, so a Time returned from this method will not change after a roundtrip to the database. That's the only reason why this function exists. Using the time.Now function also works fine otherwise.
func Bytes ¶
func Bytes(val interface{}) []byte
Tries to convert the argument into a []byte array. Returns []byte{} if any error occurs.
func Bytes2String ¶
*
- Bytes2String force casts a []byte to a string.
- @param b []byte
- @return (s string)
func ChoiceString ¶
ChoiceString returns a random selection from an array of strings.
func Clone ¶
func Clone(dst, src interface{}) error
*
- 对象深度拷贝
- @param dst interface{}
- @param src interface{}
- @return error
func Compose ¶
func Compose(functions ...interface{}) (ret func(...interface{}) interface{}, err error)
Compose will compose the received functions, there is no limit on the number of functions. Notice that the return value of the composed function is interface{}.
func ConvertString ¶
func Decrypt ¶
Decrypt the data with key. data is the bytes to be decrypted. key is the decrypted key. It is the same as the encrypt key.
func Dump ¶
func Dump(v interface{})
Print to standard out the value that is passed as the argument with indentation. Pointers are dereferenced.
func Duration ¶
Tries to convert the argument into a time.Duration value. Returns time.Duration(0) if any error occurs.
func Encrypt ¶
Encrypt the data with key. data is the bytes to be encrypted. key is the encrypt key. It is the same as the decrypt key.
func FileExists ¶
FileExists reports whether the named file or directory exists.
func Filter ¶
func Filter(function, slice interface{}) (ret interface{}, err error)
Filter apply a function(the first parameter) to each element of a slice(second parameter), and filter out ones which make the function return true.
func Float64 ¶
func Float64(val interface{}) float64
Tries to convert the argument into a float64. Returns float64(0.0) if any error occurs.
func GetDisplayString ¶
func GetDisplayString(data ...interface{}) string
GetDisplayString return data print string
func GetExternalIP ¶
func GetInternalIP ¶
func GetInternalIP2 ¶
func GrepFile ¶
GrepFile like command grep -E for example: GrepFile(`^hello`, "hello.txt") \n is striped while read
func InSliceIface ¶
func InSliceIface(v interface{}, sl []interface{}) bool
InSliceIface checks given interface in interface slice.
func InetToaton ¶
*
- 点分结构的IP地址转成数值类型
- @param ipnr string
- @return uint32
- @eg t.Log((InetToaton("192.168.1.190")))
func InetTobton ¶
*
- 字节类型的IP地址转成数值类型
- @param ipnr string
- @return uint32
- @eg: t.Log((InetTobton(net.IPv4(192,168,1,190))))
func InetTontoa ¶
*
- 数值类型转成点分结构的IP地址
- @param ipnr string
- @return uint32
- @eg: t.Log((InetTontoa(3232235966).String()))
func InitIllegalNameRune ¶
func InitIllegalNameRune()
func InsertionSort ¶
func InsertionSort(r []int)
直接插入排序 稳定 额外空间 1 1.设置监视哨 r[i] = tmp 2.从r[1]开始比较 3.r[i] 和 r[i-1] 比较; r[i-1] >= tmp r[i]=tmp 即r[i-1]后移; r[i-1] < tmp r[i] = tmp
func Int64 ¶
func Int64(val interface{}) int64
Tries to convert the argument into an int64. Returns int64(0) if any error occurs.
func Kickers ¶
func Kickers(per, second int, f func())
*
- 指定second时间内每隔per执行一次
- @param per int
- @param second int
- @param f func()
func Partial ¶
func Partial(function interface{}, params ...interface{}) (ret func(...interface{}) interface{}, err error)
Partial will make a partial function. The first argument is the function being partialed, the rest arguments is the parameters sending to that function.
func PrintPointerInfo ¶
PrintPointerInfo dump pointer value
func RadixSort ¶
func RadixSort(sz []int)
基数排序 稳定 MSD法:从优先级最高的关键字开始 LSD法:从优先级最低的关键字开始,速度快,但对数据有类型要求 时间复杂度:O(d n) n为关键字数量
func RandString ¶
RandString 产生随机字符串,可用于密码等
func RandomCreateBytes ¶
*
- RandomCreateBytes generate random []byte by specify chars.
- @param n int
- @param alphabets []byte
- @return []byte
func RandomCreateBytes2 ¶
RandomCreateBytes generate random []byte by specify chars.
func Reduce ¶
func Reduce(function, slice, initial interface{}) (ret interface{}, err error)
Reduce applys a function(the first parameter) of two arguments cumulatively to each element of a slice(second parameter), and the initial value is the third parameter.
func Sdump ¶
func Sdump(v interface{}) string
Return the value that is passed as the argument with indentation. Pointers are dereferenced.
func SearchFile ¶
SearchFile Search a file in paths. this is often used in search config file in /etc ~/
func SliceChunk ¶
func SliceChunk(slice []interface{}, size int) (chunkslice [][]interface{})
SliceChunk separates one slice to some sized slice.
func SliceDiff ¶
func SliceDiff(slice1, slice2 []interface{}) (diffslice []interface{})
SliceDiff returns diff slice of slice1 - slice2.
func SliceFilter ¶
func SliceFilter(slice []interface{}, a filtertype) (ftslice []interface{})
SliceFilter generates a new slice after filter function.
func SliceIntersect ¶
func SliceIntersect(slice1, slice2 []interface{}) (diffslice []interface{})
SliceIntersect returns slice that are present in all the slice1 and slice2.
func SliceMerge ¶
func SliceMerge(slice1, slice2 []interface{}) (c []interface{})
SliceMerge merges interface slices to one slice.
func SlicePad ¶
func SlicePad(slice []interface{}, size int, val interface{}) []interface{}
SlicePad prepends size number of val into slice.
func SliceRand ¶
func SliceRand(a []interface{}) (b interface{})
SliceRand returns random one from slice.
func SliceRandList ¶
SliceRandList generate an int slice from min to max.
func SliceRange ¶
SliceRange generates a new slice from begin to end with step duration of int64 number.
func SliceReduce ¶
func SliceReduce(slice []interface{}, a reducetype) (dslice []interface{})
SliceReduce generates a new slice after parsing every value by reduce function
func SliceRemoveFormSlice ¶
*
- 从字符串切片中移除指定切片字符串
- @param oriArr []string
- @param removeArr []string
- @return []string
func SliceShuffle ¶
func SliceShuffle(slice []interface{}) []interface{}
SliceShuffle shuffles a slice.
func SliceUnique ¶
func SliceUnique(slice []interface{}) (uniqueslice []interface{})
SliceUnique cleans repeated values in slice.
func String ¶
func String(val interface{}) string
Tries to convert the argument into a string. Returns "" if any error occurs.
func String2Bytes ¶
*
- String2Bytes force casts a string to a []byte
- @param s string
- @return (b []byte)
func StringRand ¶
StringRand returns a random string n characters long, composed of entities from charset.
func StringRange ¶
StringRange returns a random string at least min and no more than max characters long, composed of entitites from charset.
func Struct2Map ¶
func Struct2Map(obj interface{}) map[string]interface{}
func TimeToHeadphpoto ¶
*
- 把时间戳转换成头像存储目录
- @param t int64
- @param userid int
- @param headname int64
- @return (string, string)
func Uint64 ¶
func Uint64(val interface{}) uint64
Tries to convert the argument into an uint64. Returns uint64(0) if any error occurs.
Types ¶
type AesEncrypt ¶
type AesEncrypt struct {
// contains filtered or unexported fields
}
func (*AesEncrypt) Decrypt ¶
func (this *AesEncrypt) Decrypt(src []byte) (strDesc []byte, err error)
解密字符串
func (*AesEncrypt) SetKey ¶
func (this *AesEncrypt) SetKey(key []byte)
type Array ¶
type Array interface { //Push 向链表尾部添加一个或者多个元素 Push(values ...interface{}) // Pop 从列表尾部移除并返回一个元素 Pop() interface{} //PushFront 向链表头部添加一个元素 PushFront(values ...interface{}) // PopFront从链表头部移除并返回一个元素 PopFront() interface{} // Len 返回集链表元素的长度 Len() int // Values 返回链表所有元素组成的 Slice Values() []interface{} // Iter 遍历链表的所有元素 Iter() <-chan interface{} // Clear 清空链表 Clear() }
type Attachment ¶
type Attachment struct { Filename string Header textproto.MIMEHeader Content []byte }
Attachment is a struct representing an email attachment. Based on the mime/multipart.FileHeader struct, Attachment contains the name, MIMEHeader, and content of the attachment in question
type BeeMap ¶
type BeeMap struct {
// contains filtered or unexported fields
}
BeeMap is a map with lock
func (*BeeMap) Get ¶
func (m *BeeMap) Get(k interface{}) interface{}
Get from maps return the k's value
type Choice ¶
type Choice struct { Weight int Item interface{} }
A Choice contains a generic item and a weight controlling the frequency with which it will be selected.
func WeightedChoice ¶
WeightedChoice used weighted random selection to return one of the supplied choices. Weights of 0 are never selected. All other weight values are relative. E.g. if you have two choices both weighted 3, they will be returned equally often; and each will be returned 3 times as often as a choice weighted 1.
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
func (*Config) DeleteValue ¶
Delete the corresponding key values
type Email ¶
type Email struct { Auth smtp.Auth Identity string `json:"identity"` Username string `json:"username"` Password string `json:"password"` Host string `json:"host"` Port int `json:"port"` From string `json:"from"` To []string Bcc []string Cc []string Subject string Text string // Plaintext message (optional) HTML string // Html message (optional) Headers textproto.MIMEHeader Attachments []*Attachment ReadReceipt []string }
Email is the type used for email messages
func NewEMail ¶
NewEMail create new Email struct with config json. config json is followed from Email struct fields.
func (*Email) Attach ¶
Attach is used to attach content from an io.Reader to the email. Parameters include an io.Reader, the desired filename for the attachment, and the Content-Type.
func (*Email) AttachFile ¶
func (e *Email) AttachFile(args ...string) (a *Attachment, err error)
AttachFile Add attach file to the send mail
type IPTaoBao ¶
type IPTaoBao struct { Code int `json:"code"` Data IPTaoBaoData `json:"data"` }
通过淘宝API获取ip物理地址
func GetIPAddrByTaoBao ¶
type IPTaoBaoData ¶
type IPTaoBaoData struct { Country string `json:country` Country_id string `json:country_id` Area string `json:area` Area_id string `json:area_id` Region string `json:region` Region_id string `json:region_id` City string `json:city` City_id string `json:city_id` County string `json:county` County_id string `json:county_id` Isp string `json:isp` Isp_id string `json:isp_id` Ip string `json:ip` }
type Item ¶
type Item struct {
// contains filtered or unexported fields
}
An Item is something we manage in a priority queue.
type Option ¶
type Option struct {
// contains filtered or unexported fields
}
Type Option represents an optional value: every Option is either Some and contains a value, or None, and contains a nil. They have a number of uses. For example, if a function call maybe failed, it can return an Option that None is returned on error.
func Some ¶
func Some(i interface{}) Option
Some will return a Option containing the given value. Some cannot use to generate a None. If the given value is nil, it will panic.
func (*Option) And ¶
And returns None if this option is None, otherwise returns the option received.
func (*Option) And_then ¶
And_then returns None if this option is None, otherwise calls the received function with the wrapped value and returns the result Option.
func (*Option) Bind ¶
Bind will apply a given function to the wrapped value of this Option and return a new Option. If this Option is None, then it will return None.
type PriorityQueue ¶
type PriorityQueue []*Item
A PriorityQueue implements heap.Interface and holds Items.
func (PriorityQueue) Len ¶
func (pq PriorityQueue) Len() int
func (PriorityQueue) Less ¶
func (pq PriorityQueue) Less(i, j int) bool
func (*PriorityQueue) Pop ¶
func (pq *PriorityQueue) Pop() interface{}
func (*PriorityQueue) Push ¶
func (pq *PriorityQueue) Push(x interface{})
func (PriorityQueue) Swap ¶
func (pq PriorityQueue) Swap(i, j int)
type TimerManager ¶
type TimerManager struct {
// contains filtered or unexported fields
}
func NewTimerManager ¶
func NewTimerManager(size int) *TimerManager
func (*TimerManager) AddTimer ¶
func (this *TimerManager) AddTimer(i TimeOuter, e int64, iv int64) uint32
func (*TimerManager) RemoveTimer ¶
func (this *TimerManager) RemoveTimer(id uint32)
func (*TimerManager) Run ¶
func (this *TimerManager) Run(now int64, limit int)
type TimerQueue ¶
type TimerQueue []*Timer
func (TimerQueue) Len ¶
func (this TimerQueue) Len() int
func (TimerQueue) Less ¶
func (this TimerQueue) Less(i, j int) bool
func (*TimerQueue) Pop ¶
func (this *TimerQueue) Pop() interface{}
func (*TimerQueue) Push ¶
func (this *TimerQueue) Push(x interface{})
func (TimerQueue) Swap ¶
func (this TimerQueue) Swap(i, j int)
Source Files ¶
- aes.go
- all.go
- any.go
- apply.go
- array.go
- caller.go
- compose.go
- compress.go
- debug.go
- err.go
- file.go
- filter.go
- goerr.go
- heap.go
- helper.go
- ini.go
- mail.go
- option.go
- os.go
- partial.go
- queue.go
- random.go
- randutil.go
- reduce.go
- safemap.go
- slice.go
- sorting.go
- string.go
- stringbuffer.go
- structandmap.go
- timer_queue.go
- times.go
- to.go
- utils.go
- xxtea.go