bools

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 Bools

type Bools []bool

Bools 定义方便操作[]bool的类型

Example
package main

import (
	"fmt"

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

func main() {
	s := bools.Bools{}
	s.Append(false, false)
	s.Prepend(true, true, true, false, true)
	fmt.Println(s, s.Len())

	s1 := s.Copy()
	s1.Sort()
	fmt.Println(s1, s1.Len())

	s2 := s.Copy()
	s2.ReverseSort()
	fmt.Println(s2, s2.Len())

}
Output:
[true true true false true false false] 7
[false false false true true true true] 7
[true true true true false false false] 7

func (*Bools) Append

func (s *Bools) Append(data ...bool)

Append 追加数据

func (Bools) Cap

func (s Bools) Cap() int

Cap 返回slice容量

func (Bools) Copy

func (s Bools) Copy() Bools

Copy 拷贝一份数据

func (*Bools) Insert

func (s *Bools) Insert(index int, data ...bool)

Insert 插入数据

func (Bools) Len

func (s Bools) Len() int

Len 返回slice长度

func (Bools) Less

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

Less 比较两个位置上的数据

func (*Bools) Prepend

func (s *Bools) Prepend(data ...bool)

Prepend 向前添加数据

func (*Bools) Remove

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

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

func (Bools) ReverseSort

func (s Bools) ReverseSort() Bools

func (Bools) Shuffle

func (s Bools) Shuffle() Bools

Shuffle 随机打乱slice数据

func (Bools) Sort

func (s Bools) Sort() Bools

Sort 对切片进行排序

func (Bools) Swap

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

Swap 交换两个位置上的数据

Jump to

Keyboard shortcuts

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