Skip to content

Collections is a an overhaul of slices that greatly extends OOTB functionality, saving a ton of code.

License

Notifications You must be signed in to change notification settings

kelceydamage/collections

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DEFUNCT (I am not working on Go at the moment and this project will not receive any updates in the forseable future)

collections

Build Status CircleCI Coverage Status Go Report Card CodeFactor Maintainability GoDoc License

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.

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
}
type Slice interface {
	BaseSlice
	Sort()
	Reverse()
}
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.

sort.Sort(sort.Reverse(sort.IntSlice(s))) 

Is the same as:

sort.Sort(sort.Reverse(collections.IntSlice(s)))

However this is also the same as:

collections.IntSlice.Reverse()

And

collections.Reverse(IntSlice)

Documentation

https://godoc.org/github.com/kelceydamage/collections

About

Collections is a an overhaul of slices that greatly extends OOTB functionality, saving a ton of code.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages