algorithms_go

package module
v0.0.0-...-a80faa3 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

README

algorithms-go

Go coder library

Documentation

Overview

设计模式

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BubbleSort

func BubbleSort(arr []int)

func Contains

func Contains(s, substr string) bool

子串测试

func Fibonacci

func Fibonacci(n int) int

func HasPrefix

func HasPrefix(s, prefix string) bool

前缀测试

func HasSuffix

func HasSuffix(s, suffix string) bool

后缀测试

func Sort

func Sort(values []int)

排序

func SortString

func SortString(str string) string

方法二:首先字符串分割,得到字符串切片, 对切片排序, strings.join连接成新的字符串

func SortString2

func SortString2(str string)

方法一:首先,字符串转为[]byte, 对切片排序, 最后切片转字符串

Types

type IntSet

type IntSet struct {
	// contains filtered or unexported fields
}

func (*IntSet) Add

func (s *IntSet) Add(x int)

func (*IntSet) Has

func (s *IntSet) Has(x int) bool

因为每一个字都有64个二进制位,x/64的商作为字的下标,用x%64的余数作为这个字内的bit所在位置

func (*IntSet) String

func (s *IntSet) String() string

将IntSet作为一个字符串来打印。

func (*IntSet) UnionWith

func (s *IntSet) UnionWith(t *IntSet)

取并集

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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