sort Pushes & Pops.

Maxim Litvinov 2018-12-31 09:03:58 +02:00
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