mirror of
https://github.com/golang/go.git
synced 2024-11-21 21:11:11 +00:00
sort Pushes & Pops.
parent
f1e07061fb
commit
9ade7aa9a7
@ -86,9 +86,9 @@ s[i] = x
|
||||
a = append(a[:i], append(b, a[i:]...)...)
|
||||
```
|
||||
|
||||
#### Pop Front/Shift
|
||||
#### Push
|
||||
```go
|
||||
x, a = a[0], a[1:]
|
||||
a = append(a, x)
|
||||
```
|
||||
|
||||
#### Pop
|
||||
@ -96,16 +96,16 @@ x, a = a[0], a[1:]
|
||||
x, a = a[len(a)-1], a[:len(a)-1]
|
||||
```
|
||||
|
||||
#### Push
|
||||
```go
|
||||
a = append(a, x)
|
||||
```
|
||||
|
||||
#### Push Front/Unshift
|
||||
```go
|
||||
a = append([]T{x}, a...)
|
||||
```
|
||||
|
||||
#### Pop Front/Shift
|
||||
```go
|
||||
x, a = a[0], a[1:]
|
||||
```
|
||||
|
||||
## Additional Tricks
|
||||
### Filtering without allocating
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user