https://github.com/kelceydamage/collections
Collections is a an overhaul of slices that greatly extends OOTB functionality, saving a ton of code.
https://github.com/kelceydamage/collections
collections functionality go golang helpers manipulating-slices methods slices
Last synced: about 2 months ago
JSON representation
Collections is a an overhaul of slices that greatly extends OOTB functionality, saving a ton of code.
- Host: GitHub
- URL: https://github.com/kelceydamage/collections
- Owner: kelceydamage
- License: apache-2.0
- Created: 2018-03-15T23:53:02.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-08-22T17:46:23.000Z (over 7 years ago)
- Last Synced: 2024-06-20T14:28:31.568Z (over 1 year ago)
- Topics: collections, functionality, go, golang, helpers, manipulating-slices, methods, slices
- Language: Go
- Homepage: https://godoc.org/github.com/kelceydamage/collections
- Size: 87.9 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# DEFUNCT (I am not working on Go at the moment and this project will not receive any updates in the forseable future)
# collections
[](https://travis-ci.org/kelceydamage/collections) [](https://circleci.com/gh/kelceydamage/collections/tree/master) [](https://coveralls.io/github/kelceydamage/collections?branch=master) [](https://goreportcard.com/report/github.com/kelceydamage/collections) [](https://www.codefactor.io/repository/github/kelceydamage/collections) [](https://codeclimate.com/github/kelceydamage/collections/maintainability) [](https://godoc.org/github.com/kelceydamage/collections) [](https://opensource.org/licenses/Apache-2.0)
import "github.com/kelceydamage/collections"
Collections is a library of types and methods that make manipulating slices a lot easier by providing some basic functionality.
Included in collections are a couple interafaces:
### Slice
this is a base interface and all slice-types in collections implement this interface.
```Go
type BaseSlice interface {
All() []interface{}
Overwrite(interface{})
Append(interface{})
Len() int
Swap(int, int)
TruncateLeft(int)
TruncateRight(int)
Mirror()
Index(interface{}) int
IndexRight(interface{}) int
}
```
```Go
type Slice interface {
BaseSlice
Sort()
Reverse()
}
```
```Go
type NumSlice interface {
Slice
Avg() float64
AvgNonZero() float64
StdDev() float64
Variance() float64
}
```
### Types
* IntSlice
* IntSliceM
* IntQueue
* IntStack
* Float64Slice
* Float64SliceM
* Float64Queue
* Float64Stack
* StringSlice
* BoolSlice
### Compatibility
Collections is compatible with the built in Sort types, and should be familiar to use.
#### example:
you can use a collections.IntSlice as a direct replacement for sort.IntSlice, while using all the features of Sort. This goes for all types included in Sort.
```Go
sort.Sort(sort.Reverse(sort.IntSlice(s)))
```
Is the same as:
```Go
sort.Sort(sort.Reverse(collections.IntSlice(s)))
```
However this is also the same as:
```Go
collections.IntSlice.Reverse()
```
And
```Go
collections.Reverse(IntSlice)
```
# Documentation
https://godoc.org/github.com/kelceydamage/collections