![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
GO语言
文章平均质量分 69
小烧卖
这个作者很懒,什么都没留下…
展开
-
Golang算法(二)数据结构
栈 type Stack struct { head *Node } type Node struct { data interface{} next *Node } func NewStack()*Stack { s:=&Stack{ head: &Node{ data: nil, next: &Node{}, }, } return s } func (s *Stack)Push(data interface{}) { n:=&原创 2020-11-04 20:09:36 · 756 阅读 · 1 评论 -
Goroutine和OS线程的区别
前言 Goroutine作为go语言核心的特色,与其他语言线程并不太一样,其并发性远好于其他语言多线程实现方式,那么Goroutine和线程的区别有哪些呢? 区别 内容 goroutine 线程 内存占用 动态栈(2K~1G) 固定栈(2M) 调度 自带的调度器,不用内核上下文 调用scheduler内核函数状态保存到内存中 GOMAXPROCS 可以通过该参数设置cpu并行数,并且阻塞休眠都不会消耗其他Goroutine去调度 需要系统线程去调度 标识 没有ID,无法通过全局查原创 2020-10-20 17:13:25 · 109 阅读 · 0 评论 -
Golang算法(一)排序和分治
Golang算法学习,持续更新排序插入算法 排序 插入算法 思想: 想象成抽牌,左边是手上的牌,右边是牌堆,从右边不断抽取牌,并且同坐边一一比较,发现合适的位置就插入。时间复杂度:n~n^2;空间复杂度:1 难点: 查找到比自己小的数或者循环到-1时,退出循环,此时计数会-1,因此插入数的时候别忘了+1 func insertion_sort(arr []int) { for i := 1; i < len(arr); i++ { temp := arr[i] j := i - 1 fo原创 2020-07-24 19:20:15 · 290 阅读 · 0 评论