首页 > 移动平台 > 详细

golang append

时间:2016-04-15 21:29:34      阅读:320      评论:0      收藏:0      [点我收藏+]
1) Append a slice b to an existing slice a: a = append(a, b...)
2) Copy a slice a to a new slice b: b = make([]T, len(a))
copy(b, a)
3) Delete item at index i: a = append(a[:i], a[i+1:]...)
4) Cut from index i till j out of slice a: a = append(a[:i], a[j:]...)
5) Extend slice a with a new slice of length j: a = append(a, make([]T, j)...)
6) Insert item x at index i: a = append(a[:i], append([]T{x},a[i:]...)...)
7) Insert a new slice of length j at index i: a = append(a[:i], append(make([]T,j), a[i:]...)...)
8) Insert an existing slice b at index i: a = append(a[:i], append(b,a[i:]...)...)
9) Pop highest element from stack: x, a = a[len(a)-1], a[:len(a)-1]
10) Push an element x on a stack: a = append(a, x)

golang append

原文:http://www.cnblogs.com/-mok-/p/5396771.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!