ints

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2020 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Int8s

type Int8s []int8

Int8s 定义方便操作[]int8的类型

func (*Int8s) Append

func (s *Int8s) Append(data ...int8)

Append 追加数据

func (Int8s) Cap

func (s Int8s) Cap() int

Cap 返回slice容量

func (Int8s) Copy

func (s Int8s) Copy() Int8s

Copy 拷贝一份数据

func (*Int8s) Insert

func (s *Int8s) Insert(index int, data ...int8)

Insert 插入数据

func (Int8s) Len

func (s Int8s) Len() int

Len 返回slice长度

func (Int8s) Less

func (s Int8s) Less(i, j int) bool

Less 比较两个位置上的数据

func (*Int8s) Prepend

func (s *Int8s) Prepend(data ...int8)

Prepend 向前添加数据

func (*Int8s) Remove

func (s *Int8s) Remove(index, num int) int

Remove 从指定位置删除指定数量的数据,返回被删除的数据数量

func (Int8s) ReverseSort

func (s Int8s) ReverseSort() Int8s

func (Int8s) Shuffle

func (s Int8s) Shuffle() Int8s

Shuffle 随机打乱slice数据

func (Int8s) Sort

func (s Int8s) Sort() Int8s

Sort 对切片进行排序

func (Int8s) Swap

func (s Int8s) Swap(i, j int)

Swap 交换两个位置上的数据

type Int16s

type Int16s []int16

Int16s 定义方便操作[]int16的类型

func (*Int16s) Append

func (s *Int16s) Append(data ...int16)

Append 追加数据

func (Int16s) Cap

func (s Int16s) Cap() int

Cap 返回slice容量

func (Int16s) Copy

func (s Int16s) Copy() Int16s

Copy 拷贝一份数据

func (*Int16s) Insert

func (s *Int16s) Insert(index int, data ...int16)

Insert 插入数据

func (Int16s) Len

func (s Int16s) Len() int

Len 返回slice长度

func (Int16s) Less

func (s Int16s) Less(i, j int) bool

Less 比较两个位置上的数据

func (*Int16s) Prepend

func (s *Int16s) Prepend(data ...int16)

Prepend 向前添加数据

func (*Int16s) Remove

func (s *Int16s) Remove(index, num int) int

Remove 从指定位置删除指定数量的数据,返回被删除的数据数量

func (Int16s) ReverseSort

func (s Int16s) ReverseSort() Int16s

func (Int16s) Shuffle

func (s Int16s) Shuffle() Int16s

Shuffle 随机打乱slice数据

func (Int16s) Sort

func (s Int16s) Sort() Int16s

Sort 对切片进行排序

func (Int16s) Swap

func (s Int16s) Swap(i, j int)

Swap 交换两个位置上的数据

type Int32s

type Int32s []int32

Int32s 定义方便操作[]int32的类型

func (*Int32s) Append

func (s *Int32s) Append(data ...int32)

Append 追加数据

func (Int32s) Cap

func (s Int32s) Cap() int

Cap 返回slice容量

func (Int32s) Copy

func (s Int32s) Copy() Int32s

Copy 拷贝一份数据

func (*Int32s) Insert

func (s *Int32s) Insert(index int, data ...int32)

Insert 插入数据

func (Int32s) Len

func (s Int32s) Len() int

Len 返回slice长度

func (Int32s) Less

func (s Int32s) Less(i, j int) bool

Less 比较两个位置上的数据

func (*Int32s) Prepend

func (s *Int32s) Prepend(data ...int32)

Prepend 向前添加数据

func (*Int32s) Remove

func (s *Int32s) Remove(index, num int) int

Remove 从指定位置删除指定数量的数据,返回被删除的数据数量

func (Int32s) ReverseSort

func (s Int32s) ReverseSort() Int32s

func (Int32s) Shuffle

func (s Int32s) Shuffle() Int32s

Shuffle 随机打乱slice数据

func (Int32s) Sort

func (s Int32s) Sort() Int32s

Sort 对切片进行排序

func (Int32s) Swap

func (s Int32s) Swap(i, j int)

Swap 交换两个位置上的数据

type Int64s

type Int64s []int64

Int64s 定义方便操作[]int64的类型

func (*Int64s) Append

func (s *Int64s) Append(data ...int64)

Append 追加数据

func (Int64s) Cap

func (s Int64s) Cap() int

Cap 返回slice容量

func (Int64s) Copy

func (s Int64s) Copy() Int64s

Copy 拷贝一份数据

func (*Int64s) Insert

func (s *Int64s) Insert(index int, data ...int64)

Insert 插入数据

func (Int64s) Len

func (s Int64s) Len() int

Len 返回slice长度

func (Int64s) Less

func (s Int64s) Less(i, j int) bool

Less 比较两个位置上的数据

func (*Int64s) Prepend

func (s *Int64s) Prepend(data ...int64)

Prepend 向前添加数据

func (*Int64s) Remove

func (s *Int64s) Remove(index, num int) int

Remove 从指定位置删除指定数量的数据,返回被删除的数据数量

func (Int64s) ReverseSort

func (s Int64s) ReverseSort() Int64s

func (Int64s) Shuffle

func (s Int64s) Shuffle() Int64s

Shuffle 随机打乱slice数据

func (Int64s) Sort

func (s Int64s) Sort() Int64s

Sort 对切片进行排序

func (Int64s) Swap

func (s Int64s) Swap(i, j int)

Swap 交换两个位置上的数据

type Ints

type Ints []int

Ints 定义方便操作[]int的类型

Example
package main

import (
	"fmt"

	"github.com/recallsong/go-utils/container/slice/ints"
)

func main() {
	s := ints.Ints{}
	s.Append(1, 2)
	s.Prepend(-4, -3, -2, -1, 0)
	s.Insert(1, 3, 4, 5, 6)
	fmt.Println(s, s.Len())

	s1 := s.Copy()
	removed := s1.Remove(3, 6)
	fmt.Println(s1, s1.Len(), removed)
}
Output:
[-4 3 4 5 6 -3 -2 -1 0 1 2] 11
[-4 3 4 1 2] 5 6
Example (Order)
package main

import (
	"fmt"

	"github.com/recallsong/go-utils/container/slice/ints"
)

func main() {
	s := ints.Ints{}
	s.Append(9, 1, 8, 2, 7, 3, 6, 4, 5)
	s.Sort()
	fmt.Println(s)
	s.ReverseSort()
	fmt.Println(s)

	s.Shuffle() //随机打乱数据
	// fmt.Println(s)

}
Output:
[1 2 3 4 5 6 7 8 9]
[9 8 7 6 5 4 3 2 1]

func (*Ints) Append

func (s *Ints) Append(data ...int)

Append 追加数据

func (Ints) Cap

func (s Ints) Cap() int

Cap 返回slice容量

func (Ints) Copy

func (s Ints) Copy() Ints

Copy 拷贝一份数据

func (*Ints) Insert

func (s *Ints) Insert(index int, data ...int)

Insert 插入数据

func (Ints) Len

func (s Ints) Len() int

Len 返回slice长度

func (Ints) Less

func (s Ints) Less(i, j int) bool

Less 比较两个位置上的数据

func (*Ints) Prepend

func (s *Ints) Prepend(data ...int)

Prepend 向前添加数据

func (*Ints) Remove

func (s *Ints) Remove(index, num int) int

Remove 从指定位置删除指定数量的数据,返回被删除的数据数量

func (Ints) ReverseSort

func (s Ints) ReverseSort() Ints

func (Ints) Shuffle

func (s Ints) Shuffle() Ints

Shuffle 随机打乱slice数据

func (Ints) Sort

func (s Ints) Sort() Ints

Sort 对切片进行排序

func (Ints) Swap

func (s Ints) Swap(i, j int)

Swap 交换两个位置上的数据

Jump to

Keyboard shortcuts

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