golist

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 8, 2020 License: MIT Imports: 4 Imported by: 0

README

Golist

Build Status Software License Go Doc Go Report Card

Golist provides useful functions for common list operations in Go.

Introduction

Working with lists of data in Go using the built-in slice data type and operators can sometimes be a pain. Simple and common operations such as sorting, removing duplicates, and manipulating data can often requires a lot of boilerplate code to accomplish. This package simplifies working with slices by providing easy to use methods for common operations. The methods can also be chained together to enable complex operations on the underlying data with a lot less code, but still highly-readable and easy to maintain.

Example

Here is an example that starts with a slice of integers, multiplies each item by 2, selects only those items that are greater than 20, removes any duplicates, then finally sorts the integers in ascending order.

	s := golist.NewSliceInt(-5, 3, 2, 21, 0, 40, -4, -20, 100, 40, -9, 18, 21, -33, 40)

	s.Transform(func(a int) int {
		return a * 2
	}).Filter(func(a int) bool {
		return a > 20
	}).Unique().Sort()

	for _, value := range s.Data() {
		fmt.Println(value)
	}

	// Output:
	// 36
	// 42
	// 80
	// 200

Inspiration

Warning

Golist is in active development and is not yet ready for use in production. The API is experimental and is subject to change without notice. Suggestions or contributions to improve Golist and help shape its design are welcome and encouraged!

Documentation

Overview

Package golist provides useful methods for working with slices of data.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SliceBool

type SliceBool struct {
	// contains filtered or unexported fields
}

SliceBool is a slice of type bool.

func NewSliceBool

func NewSliceBool(elems ...bool) *SliceBool

NewSliceBool returns a pointer to a new SliceBool initialized with the specified elements.

func (*SliceBool) Append

func (s *SliceBool) Append(elems ...bool) *SliceBool

Append adds the elements to the end of SliceBool.

func (*SliceBool) At

func (s *SliceBool) At(index int) bool

At returns the element in SliceBool at the specified index.

func (*SliceBool) Clone

func (s *SliceBool) Clone() *SliceBool

Clone performs a deep copy of SliceBool and returns it

func (*SliceBool) Count

func (s *SliceBool) Count() int

Count returns the number of elements in SliceBool.

func (*SliceBool) Data

func (s *SliceBool) Data() []bool

Data returns the raw elements of SliceBool.

func (*SliceBool) Equal

func (s *SliceBool) Equal(s2 *SliceBool) bool

Equal returns true if the SliceBool is logically equivalent to the specified SliceBool.

func (*SliceBool) Filter

func (s *SliceBool) Filter(fn func(elem bool) bool) *SliceBool

Filter removes elements from SliceBool that do not satisfy the filter function.

func (*SliceBool) Insert

func (s *SliceBool) Insert(index int, elems ...bool) *SliceBool

Insert inserts the elements into SliceBool at the specified index.

func (*SliceBool) Len

func (s *SliceBool) Len() int

Len returns the number of elements in SliceBool (alias for Count).

func (*SliceBool) Prepend

func (s *SliceBool) Prepend(elems ...bool) *SliceBool

Prepend adds the elements to the beginning of SliceBool.

func (*SliceBool) Remove

func (s *SliceBool) Remove(index int) *SliceBool

Remove removes the element from SliceBool at the specified index.

func (*SliceBool) Reverse

func (s *SliceBool) Reverse() *SliceBool

Reverse reverses the order of the elements of SliceBool.

func (*SliceBool) Set

func (s *SliceBool) Set(index int, elem bool) *SliceBool

Set sets the element of SliceBool at the specified index.

func (*SliceBool) Shuffle

func (s *SliceBool) Shuffle(seed int64) *SliceBool

Shuffle randomly shuffles the order of the elements in SliceBool.

func (*SliceBool) Swap

func (s *SliceBool) Swap(i, j int)

Swap swaps the elements in SliceBool specified by the indices i and j.

func (*SliceBool) Transform

func (s *SliceBool) Transform(fn func(elem bool) bool) *SliceBool

Transform modifies each element of SliceBool according to the specified function.

func (*SliceBool) Unique

func (s *SliceBool) Unique() *SliceBool

Unique modifies SliceBool to keep only the first occurrence of each element (removing any duplicates).

type SliceByte

type SliceByte struct {
	// contains filtered or unexported fields
}

SliceByte is a slice of type byte.

func NewSliceByte

func NewSliceByte(elems ...byte) *SliceByte

NewSliceByte returns a pointer to a new SliceByte initialized with the specified elements.

func (*SliceByte) Append

func (s *SliceByte) Append(elems ...byte) *SliceByte

Append adds the elements to the end of SliceByte.

func (*SliceByte) At

func (s *SliceByte) At(index int) byte

At returns the element in SliceByte at the specified index.

func (*SliceByte) Clone

func (s *SliceByte) Clone() *SliceByte

Clone performs a deep copy of SliceByte and returns it

func (*SliceByte) Count

func (s *SliceByte) Count() int

Count returns the number of elements in SliceByte.

func (*SliceByte) Data

func (s *SliceByte) Data() []byte

Data returns the raw elements of SliceByte.

func (*SliceByte) Equal

func (s *SliceByte) Equal(s2 *SliceByte) bool

Equal returns true if the SliceByte is logically equivalent to the specified SliceByte.

func (*SliceByte) Filter

func (s *SliceByte) Filter(fn func(elem byte) bool) *SliceByte

Filter removes elements from SliceByte that do not satisfy the filter function.

func (*SliceByte) Insert

func (s *SliceByte) Insert(index int, elems ...byte) *SliceByte

Insert inserts the elements into SliceByte at the specified index.

func (*SliceByte) Len

func (s *SliceByte) Len() int

Len returns the number of elements in SliceByte (alias for Count).

func (*SliceByte) Less

func (s *SliceByte) Less(i, j int) bool

Less returns true if the SliceByte element at index i is less than the element at index j.

func (*SliceByte) Max

func (s *SliceByte) Max() byte

Max returns the largest (greatest ordered) element in SliceByte.

func (*SliceByte) Min

func (s *SliceByte) Min() byte

Min returns the smallest (least ordered) element in SliceByte.

func (*SliceByte) Prepend

func (s *SliceByte) Prepend(elems ...byte) *SliceByte

Prepend adds the elements to the beginning of SliceByte.

func (*SliceByte) Remove

func (s *SliceByte) Remove(index int) *SliceByte

Remove removes the element from SliceByte at the specified index.

func (*SliceByte) Reverse

func (s *SliceByte) Reverse() *SliceByte

Reverse reverses the order of the elements of SliceByte.

func (*SliceByte) Set

func (s *SliceByte) Set(index int, elem byte) *SliceByte

Set sets the element of SliceByte at the specified index.

func (*SliceByte) Shuffle

func (s *SliceByte) Shuffle(seed int64) *SliceByte

Shuffle randomly shuffles the order of the elements in SliceByte.

func (*SliceByte) Sort

func (s *SliceByte) Sort() *SliceByte

Sort sorts the elements of SliceByte in increasing order.

func (*SliceByte) Swap

func (s *SliceByte) Swap(i, j int)

Swap swaps the elements in SliceByte specified by the indices i and j.

func (*SliceByte) Transform

func (s *SliceByte) Transform(fn func(elem byte) byte) *SliceByte

Transform modifies each element of SliceByte according to the specified function.

func (*SliceByte) Unique

func (s *SliceByte) Unique() *SliceByte

Unique modifies SliceByte to keep only the first occurrence of each element (removing any duplicates).

type SliceComplex128

type SliceComplex128 struct {
	// contains filtered or unexported fields
}

SliceComplex128 is a slice of type complex128.

func NewSliceComplex128

func NewSliceComplex128(elems ...complex128) *SliceComplex128

NewSliceComplex128 returns a pointer to a new SliceComplex128 initialized with the specified elements.

func (*SliceComplex128) Append

func (s *SliceComplex128) Append(elems ...complex128) *SliceComplex128

Append adds the elements to the end of SliceComplex128.

func (*SliceComplex128) At

func (s *SliceComplex128) At(index int) complex128

At returns the element in SliceComplex128 at the specified index.

func (*SliceComplex128) Clone

func (s *SliceComplex128) Clone() *SliceComplex128

Clone performs a deep copy of SliceComplex128 and returns it

func (*SliceComplex128) Count

func (s *SliceComplex128) Count() int

Count returns the number of elements in SliceComplex128.

func (*SliceComplex128) Data

func (s *SliceComplex128) Data() []complex128

Data returns the raw elements of SliceComplex128.

func (*SliceComplex128) Equal

func (s *SliceComplex128) Equal(s2 *SliceComplex128) bool

Equal returns true if the SliceComplex128 is logically equivalent to the specified SliceComplex128.

func (*SliceComplex128) Filter

func (s *SliceComplex128) Filter(fn func(elem complex128) bool) *SliceComplex128

Filter removes elements from SliceComplex128 that do not satisfy the filter function.

func (*SliceComplex128) Insert

func (s *SliceComplex128) Insert(index int, elems ...complex128) *SliceComplex128

Insert inserts the elements into SliceComplex128 at the specified index.

func (*SliceComplex128) Len

func (s *SliceComplex128) Len() int

Len returns the number of elements in SliceComplex128 (alias for Count).

func (*SliceComplex128) Prepend

func (s *SliceComplex128) Prepend(elems ...complex128) *SliceComplex128

Prepend adds the elements to the beginning of SliceComplex128.

func (*SliceComplex128) Remove

func (s *SliceComplex128) Remove(index int) *SliceComplex128

Remove removes the element from SliceComplex128 at the specified index.

func (*SliceComplex128) Reverse

func (s *SliceComplex128) Reverse() *SliceComplex128

Reverse reverses the order of the elements of SliceComplex128.

func (*SliceComplex128) Set

func (s *SliceComplex128) Set(index int, elem complex128) *SliceComplex128

Set sets the element of SliceComplex128 at the specified index.

func (*SliceComplex128) Shuffle

func (s *SliceComplex128) Shuffle(seed int64) *SliceComplex128

Shuffle randomly shuffles the order of the elements in SliceComplex128.

func (*SliceComplex128) Swap

func (s *SliceComplex128) Swap(i, j int)

Swap swaps the elements in SliceComplex128 specified by the indices i and j.

func (*SliceComplex128) Transform

func (s *SliceComplex128) Transform(fn func(elem complex128) complex128) *SliceComplex128

Transform modifies each element of SliceComplex128 according to the specified function.

func (*SliceComplex128) Unique

func (s *SliceComplex128) Unique() *SliceComplex128

Unique modifies SliceComplex128 to keep only the first occurrence of each element (removing any duplicates).

type SliceComplex64

type SliceComplex64 struct {
	// contains filtered or unexported fields
}

SliceComplex64 is a slice of type complex64.

func NewSliceComplex64

func NewSliceComplex64(elems ...complex64) *SliceComplex64

NewSliceComplex64 returns a pointer to a new SliceComplex64 initialized with the specified elements.

func (*SliceComplex64) Append

func (s *SliceComplex64) Append(elems ...complex64) *SliceComplex64

Append adds the elements to the end of SliceComplex64.

func (*SliceComplex64) At

func (s *SliceComplex64) At(index int) complex64

At returns the element in SliceComplex64 at the specified index.

func (*SliceComplex64) Clone

func (s *SliceComplex64) Clone() *SliceComplex64

Clone performs a deep copy of SliceComplex64 and returns it

func (*SliceComplex64) Count

func (s *SliceComplex64) Count() int

Count returns the number of elements in SliceComplex64.

func (*SliceComplex64) Data

func (s *SliceComplex64) Data() []complex64

Data returns the raw elements of SliceComplex64.

func (*SliceComplex64) Equal

func (s *SliceComplex64) Equal(s2 *SliceComplex64) bool

Equal returns true if the SliceComplex64 is logically equivalent to the specified SliceComplex64.

func (*SliceComplex64) Filter

func (s *SliceComplex64) Filter(fn func(elem complex64) bool) *SliceComplex64

Filter removes elements from SliceComplex64 that do not satisfy the filter function.

func (*SliceComplex64) Insert

func (s *SliceComplex64) Insert(index int, elems ...complex64) *SliceComplex64

Insert inserts the elements into SliceComplex64 at the specified index.

func (*SliceComplex64) Len

func (s *SliceComplex64) Len() int

Len returns the number of elements in SliceComplex64 (alias for Count).

func (*SliceComplex64) Prepend

func (s *SliceComplex64) Prepend(elems ...complex64) *SliceComplex64

Prepend adds the elements to the beginning of SliceComplex64.

func (*SliceComplex64) Remove

func (s *SliceComplex64) Remove(index int) *SliceComplex64

Remove removes the element from SliceComplex64 at the specified index.

func (*SliceComplex64) Reverse

func (s *SliceComplex64) Reverse() *SliceComplex64

Reverse reverses the order of the elements of SliceComplex64.

func (*SliceComplex64) Set

func (s *SliceComplex64) Set(index int, elem complex64) *SliceComplex64

Set sets the element of SliceComplex64 at the specified index.

func (*SliceComplex64) Shuffle

func (s *SliceComplex64) Shuffle(seed int64) *SliceComplex64

Shuffle randomly shuffles the order of the elements in SliceComplex64.

func (*SliceComplex64) Swap

func (s *SliceComplex64) Swap(i, j int)

Swap swaps the elements in SliceComplex64 specified by the indices i and j.

func (*SliceComplex64) Transform

func (s *SliceComplex64) Transform(fn func(elem complex64) complex64) *SliceComplex64

Transform modifies each element of SliceComplex64 according to the specified function.

func (*SliceComplex64) Unique

func (s *SliceComplex64) Unique() *SliceComplex64

Unique modifies SliceComplex64 to keep only the first occurrence of each element (removing any duplicates).

type SliceError

type SliceError struct {
	// contains filtered or unexported fields
}

SliceError is a slice of type error.

func NewSliceError

func NewSliceError(elems ...error) *SliceError

NewSliceError returns a pointer to a new SliceError initialized with the specified elements.

func (*SliceError) Append

func (s *SliceError) Append(elems ...error) *SliceError

Append adds the elements to the end of SliceError.

func (*SliceError) At

func (s *SliceError) At(index int) error

At returns the element in SliceError at the specified index.

func (*SliceError) Clone

func (s *SliceError) Clone() *SliceError

Clone performs a deep copy of SliceError and returns it

func (*SliceError) Count

func (s *SliceError) Count() int

Count returns the number of elements in SliceError.

func (*SliceError) Data

func (s *SliceError) Data() []error

Data returns the raw elements of SliceError.

func (*SliceError) Equal

func (s *SliceError) Equal(s2 *SliceError) bool

Equal returns true if the SliceError is logically equivalent to the specified SliceError.

func (*SliceError) Filter

func (s *SliceError) Filter(fn func(elem error) bool) *SliceError

Filter removes elements from SliceError that do not satisfy the filter function.

func (*SliceError) Insert

func (s *SliceError) Insert(index int, elems ...error) *SliceError

Insert inserts the elements into SliceError at the specified index.

func (*SliceError) Len

func (s *SliceError) Len() int

Len returns the number of elements in SliceError (alias for Count).

func (*SliceError) Prepend

func (s *SliceError) Prepend(elems ...error) *SliceError

Prepend adds the elements to the beginning of SliceError.

func (*SliceError) Remove

func (s *SliceError) Remove(index int) *SliceError

Remove removes the element from SliceError at the specified index.

func (*SliceError) Reverse

func (s *SliceError) Reverse() *SliceError

Reverse reverses the order of the elements of SliceError.

func (*SliceError) Set

func (s *SliceError) Set(index int, elem error) *SliceError

Set sets the element of SliceError at the specified index.

func (*SliceError) Shuffle

func (s *SliceError) Shuffle(seed int64) *SliceError

Shuffle randomly shuffles the order of the elements in SliceError.

func (*SliceError) Swap

func (s *SliceError) Swap(i, j int)

Swap swaps the elements in SliceError specified by the indices i and j.

func (*SliceError) Transform

func (s *SliceError) Transform(fn func(elem error) error) *SliceError

Transform modifies each element of SliceError according to the specified function.

func (*SliceError) Unique

func (s *SliceError) Unique() *SliceError

Unique modifies SliceError to keep only the first occurrence of each element (removing any duplicates).

type SliceFloat32

type SliceFloat32 struct {
	// contains filtered or unexported fields
}

SliceFloat32 is a slice of type float32.

func NewSliceFloat32

func NewSliceFloat32(elems ...float32) *SliceFloat32

NewSliceFloat32 returns a pointer to a new SliceFloat32 initialized with the specified elements.

func (*SliceFloat32) Append

func (s *SliceFloat32) Append(elems ...float32) *SliceFloat32

Append adds the elements to the end of SliceFloat32.

func (*SliceFloat32) At

func (s *SliceFloat32) At(index int) float32

At returns the element in SliceFloat32 at the specified index.

func (*SliceFloat32) Clone

func (s *SliceFloat32) Clone() *SliceFloat32

Clone performs a deep copy of SliceFloat32 and returns it

func (*SliceFloat32) Count

func (s *SliceFloat32) Count() int

Count returns the number of elements in SliceFloat32.

func (*SliceFloat32) Data

func (s *SliceFloat32) Data() []float32

Data returns the raw elements of SliceFloat32.

func (*SliceFloat32) Equal

func (s *SliceFloat32) Equal(s2 *SliceFloat32) bool

Equal returns true if the SliceFloat32 is logically equivalent to the specified SliceFloat32.

func (*SliceFloat32) Filter

func (s *SliceFloat32) Filter(fn func(elem float32) bool) *SliceFloat32

Filter removes elements from SliceFloat32 that do not satisfy the filter function.

func (*SliceFloat32) Insert

func (s *SliceFloat32) Insert(index int, elems ...float32) *SliceFloat32

Insert inserts the elements into SliceFloat32 at the specified index.

func (*SliceFloat32) Len

func (s *SliceFloat32) Len() int

Len returns the number of elements in SliceFloat32 (alias for Count).

func (*SliceFloat32) Less

func (s *SliceFloat32) Less(i, j int) bool

Less returns true if the SliceFloat32 element at index i is less than the element at index j.

func (*SliceFloat32) Max

func (s *SliceFloat32) Max() float32

Max returns the largest (greatest ordered) element in SliceFloat32.

func (*SliceFloat32) Min

func (s *SliceFloat32) Min() float32

Min returns the smallest (least ordered) element in SliceFloat32.

func (*SliceFloat32) Prepend

func (s *SliceFloat32) Prepend(elems ...float32) *SliceFloat32

Prepend adds the elements to the beginning of SliceFloat32.

func (*SliceFloat32) Remove

func (s *SliceFloat32) Remove(index int) *SliceFloat32

Remove removes the element from SliceFloat32 at the specified index.

func (*SliceFloat32) Reverse

func (s *SliceFloat32) Reverse() *SliceFloat32

Reverse reverses the order of the elements of SliceFloat32.

func (*SliceFloat32) Set

func (s *SliceFloat32) Set(index int, elem float32) *SliceFloat32

Set sets the element of SliceFloat32 at the specified index.

func (*SliceFloat32) Shuffle

func (s *SliceFloat32) Shuffle(seed int64) *SliceFloat32

Shuffle randomly shuffles the order of the elements in SliceFloat32.

func (*SliceFloat32) Sort

func (s *SliceFloat32) Sort() *SliceFloat32

Sort sorts the elements of SliceFloat32 in increasing order.

func (*SliceFloat32) Swap

func (s *SliceFloat32) Swap(i, j int)

Swap swaps the elements in SliceFloat32 specified by the indices i and j.

func (*SliceFloat32) Transform

func (s *SliceFloat32) Transform(fn func(elem float32) float32) *SliceFloat32

Transform modifies each element of SliceFloat32 according to the specified function.

func (*SliceFloat32) Unique

func (s *SliceFloat32) Unique() *SliceFloat32

Unique modifies SliceFloat32 to keep only the first occurrence of each element (removing any duplicates).

type SliceFloat64

type SliceFloat64 struct {
	// contains filtered or unexported fields
}

SliceFloat64 is a slice of type float64.

func NewSliceFloat64

func NewSliceFloat64(elems ...float64) *SliceFloat64

NewSliceFloat64 returns a pointer to a new SliceFloat64 initialized with the specified elements.

func (*SliceFloat64) Append

func (s *SliceFloat64) Append(elems ...float64) *SliceFloat64

Append adds the elements to the end of SliceFloat64.

func (*SliceFloat64) At

func (s *SliceFloat64) At(index int) float64

At returns the element in SliceFloat64 at the specified index.

func (*SliceFloat64) Clone

func (s *SliceFloat64) Clone() *SliceFloat64

Clone performs a deep copy of SliceFloat64 and returns it

func (*SliceFloat64) Count

func (s *SliceFloat64) Count() int

Count returns the number of elements in SliceFloat64.

func (*SliceFloat64) Data

func (s *SliceFloat64) Data() []float64

Data returns the raw elements of SliceFloat64.

func (*SliceFloat64) Equal

func (s *SliceFloat64) Equal(s2 *SliceFloat64) bool

Equal returns true if the SliceFloat64 is logically equivalent to the specified SliceFloat64.

func (*SliceFloat64) Filter

func (s *SliceFloat64) Filter(fn func(elem float64) bool) *SliceFloat64

Filter removes elements from SliceFloat64 that do not satisfy the filter function.

func (*SliceFloat64) Insert

func (s *SliceFloat64) Insert(index int, elems ...float64) *SliceFloat64

Insert inserts the elements into SliceFloat64 at the specified index.

func (*SliceFloat64) Len

func (s *SliceFloat64) Len() int

Len returns the number of elements in SliceFloat64 (alias for Count).

func (*SliceFloat64) Less

func (s *SliceFloat64) Less(i, j int) bool

Less returns true if the SliceFloat64 element at index i is less than the element at index j.

func (*SliceFloat64) Max

func (s *SliceFloat64) Max() float64

Max returns the largest (greatest ordered) element in SliceFloat64.

func (*SliceFloat64) Min

func (s *SliceFloat64) Min() float64

Min returns the smallest (least ordered) element in SliceFloat64.

func (*SliceFloat64) Prepend

func (s *SliceFloat64) Prepend(elems ...float64) *SliceFloat64

Prepend adds the elements to the beginning of SliceFloat64.

func (*SliceFloat64) Remove

func (s *SliceFloat64) Remove(index int) *SliceFloat64

Remove removes the element from SliceFloat64 at the specified index.

func (*SliceFloat64) Reverse

func (s *SliceFloat64) Reverse() *SliceFloat64

Reverse reverses the order of the elements of SliceFloat64.

func (*SliceFloat64) Set

func (s *SliceFloat64) Set(index int, elem float64) *SliceFloat64

Set sets the element of SliceFloat64 at the specified index.

func (*SliceFloat64) Shuffle

func (s *SliceFloat64) Shuffle(seed int64) *SliceFloat64

Shuffle randomly shuffles the order of the elements in SliceFloat64.

func (*SliceFloat64) Sort

func (s *SliceFloat64) Sort() *SliceFloat64

Sort sorts the elements of SliceFloat64 in increasing order.

func (*SliceFloat64) Swap

func (s *SliceFloat64) Swap(i, j int)

Swap swaps the elements in SliceFloat64 specified by the indices i and j.

func (*SliceFloat64) Transform

func (s *SliceFloat64) Transform(fn func(elem float64) float64) *SliceFloat64

Transform modifies each element of SliceFloat64 according to the specified function.

func (*SliceFloat64) Unique

func (s *SliceFloat64) Unique() *SliceFloat64

Unique modifies SliceFloat64 to keep only the first occurrence of each element (removing any duplicates).

type SliceInt

type SliceInt struct {
	// contains filtered or unexported fields
}

SliceInt is a slice of type int.

func NewSliceInt

func NewSliceInt(elems ...int) *SliceInt

NewSliceInt returns a pointer to a new SliceInt initialized with the specified elements.

func (*SliceInt) Append

func (s *SliceInt) Append(elems ...int) *SliceInt

Append adds the elements to the end of SliceInt.

func (*SliceInt) At

func (s *SliceInt) At(index int) int

At returns the element in SliceInt at the specified index.

func (*SliceInt) Clone

func (s *SliceInt) Clone() *SliceInt

Clone performs a deep copy of SliceInt and returns it

func (*SliceInt) Count

func (s *SliceInt) Count() int

Count returns the number of elements in SliceInt.

Example
package main

import (
	"fmt"

	"github.com/schoukri/golist"
)

func main() {
	s := golist.NewSliceInt(-5, 3, 2, 21, 0, 40, -4, -20, 100, 40, -9, 18, 21, -33, 40)

	count := s.Filter(func(a int) bool {
		return a > 10
	}).Count()

	uniqCount := s.Filter(func(a int) bool {
		return a > 10
	}).Unique().Count()

	fmt.Println("total count:", count)
	fmt.Println("unique count:", uniqCount)

}
Output:

total count: 7
unique count: 4

func (*SliceInt) Data

func (s *SliceInt) Data() []int

Data returns the raw elements of SliceInt.

func (*SliceInt) Equal

func (s *SliceInt) Equal(s2 *SliceInt) bool

Equal returns true if the SliceInt is logically equivalent to the specified SliceInt.

func (*SliceInt) Filter

func (s *SliceInt) Filter(fn func(elem int) bool) *SliceInt

Filter removes elements from SliceInt that do not satisfy the filter function.

func (*SliceInt) Insert

func (s *SliceInt) Insert(index int, elems ...int) *SliceInt

Insert inserts the elements into SliceInt at the specified index.

Example
package main

import (
	"fmt"

	"github.com/schoukri/golist"
)

func main() {
	s := golist.NewSliceInt(10, 40)
	s.Insert(1, 20, 30)

	for _, value := range s.Data() {
		fmt.Println(value)
	}

}
Output:

10
20
30
40

func (*SliceInt) Len

func (s *SliceInt) Len() int

Len returns the number of elements in SliceInt (alias for Count).

func (*SliceInt) Less

func (s *SliceInt) Less(i, j int) bool

Less returns true if the SliceInt element at index i is less than the element at index j.

func (*SliceInt) Max

func (s *SliceInt) Max() int

Max returns the largest (greatest ordered) element in SliceInt.

func (*SliceInt) Min

func (s *SliceInt) Min() int

Min returns the smallest (least ordered) element in SliceInt.

func (*SliceInt) Prepend

func (s *SliceInt) Prepend(elems ...int) *SliceInt

Prepend adds the elements to the beginning of SliceInt.

func (*SliceInt) Remove

func (s *SliceInt) Remove(index int) *SliceInt

Remove removes the element from SliceInt at the specified index.

func (*SliceInt) Reverse

func (s *SliceInt) Reverse() *SliceInt

Reverse reverses the order of the elements of SliceInt.

func (*SliceInt) Set

func (s *SliceInt) Set(index int, elem int) *SliceInt

Set sets the element of SliceInt at the specified index.

func (*SliceInt) Shuffle

func (s *SliceInt) Shuffle(seed int64) *SliceInt

Shuffle randomly shuffles the order of the elements in SliceInt.

func (*SliceInt) Sort

func (s *SliceInt) Sort() *SliceInt

Sort sorts the elements of SliceInt in increasing order.

func (*SliceInt) Swap

func (s *SliceInt) Swap(i, j int)

Swap swaps the elements in SliceInt specified by the indices i and j.

func (*SliceInt) Transform

func (s *SliceInt) Transform(fn func(elem int) int) *SliceInt

Transform modifies each element of SliceInt according to the specified function.

Example
package main

import (
	"fmt"

	"github.com/schoukri/golist"
)

func main() {
	s := golist.NewSliceInt(-5, 3, 2, 21, 0, 40, -4, -20, 100, 40, -9, 18, 21, -33, 40)

	s.Transform(func(a int) int {
		return a * 2
	}).Filter(func(a int) bool {
		return a > 20
	}).Unique().Sort()

	for _, value := range s.Data() {
		fmt.Println(value)
	}

}
Output:

36
42
80
200

func (*SliceInt) Unique

func (s *SliceInt) Unique() *SliceInt

Unique modifies SliceInt to keep only the first occurrence of each element (removing any duplicates).

type SliceInt16

type SliceInt16 struct {
	// contains filtered or unexported fields
}

SliceInt16 is a slice of type int16.

func NewSliceInt16

func NewSliceInt16(elems ...int16) *SliceInt16

NewSliceInt16 returns a pointer to a new SliceInt16 initialized with the specified elements.

func (*SliceInt16) Append

func (s *SliceInt16) Append(elems ...int16) *SliceInt16

Append adds the elements to the end of SliceInt16.

func (*SliceInt16) At

func (s *SliceInt16) At(index int) int16

At returns the element in SliceInt16 at the specified index.

func (*SliceInt16) Clone

func (s *SliceInt16) Clone() *SliceInt16

Clone performs a deep copy of SliceInt16 and returns it

func (*SliceInt16) Count

func (s *SliceInt16) Count() int

Count returns the number of elements in SliceInt16.

func (*SliceInt16) Data

func (s *SliceInt16) Data() []int16

Data returns the raw elements of SliceInt16.

func (*SliceInt16) Equal

func (s *SliceInt16) Equal(s2 *SliceInt16) bool

Equal returns true if the SliceInt16 is logically equivalent to the specified SliceInt16.

func (*SliceInt16) Filter

func (s *SliceInt16) Filter(fn func(elem int16) bool) *SliceInt16

Filter removes elements from SliceInt16 that do not satisfy the filter function.

func (*SliceInt16) Insert

func (s *SliceInt16) Insert(index int, elems ...int16) *SliceInt16

Insert inserts the elements into SliceInt16 at the specified index.

func (*SliceInt16) Len

func (s *SliceInt16) Len() int

Len returns the number of elements in SliceInt16 (alias for Count).

func (*SliceInt16) Less

func (s *SliceInt16) Less(i, j int) bool

Less returns true if the SliceInt16 element at index i is less than the element at index j.

func (*SliceInt16) Max

func (s *SliceInt16) Max() int16

Max returns the largest (greatest ordered) element in SliceInt16.

func (*SliceInt16) Min

func (s *SliceInt16) Min() int16

Min returns the smallest (least ordered) element in SliceInt16.

func (*SliceInt16) Prepend

func (s *SliceInt16) Prepend(elems ...int16) *SliceInt16

Prepend adds the elements to the beginning of SliceInt16.

func (*SliceInt16) Remove

func (s *SliceInt16) Remove(index int) *SliceInt16

Remove removes the element from SliceInt16 at the specified index.

func (*SliceInt16) Reverse

func (s *SliceInt16) Reverse() *SliceInt16

Reverse reverses the order of the elements of SliceInt16.

func (*SliceInt16) Set

func (s *SliceInt16) Set(index int, elem int16) *SliceInt16

Set sets the element of SliceInt16 at the specified index.

func (*SliceInt16) Shuffle

func (s *SliceInt16) Shuffle(seed int64) *SliceInt16

Shuffle randomly shuffles the order of the elements in SliceInt16.

func (*SliceInt16) Sort

func (s *SliceInt16) Sort() *SliceInt16

Sort sorts the elements of SliceInt16 in increasing order.

func (*SliceInt16) Swap

func (s *SliceInt16) Swap(i, j int)

Swap swaps the elements in SliceInt16 specified by the indices i and j.

func (*SliceInt16) Transform

func (s *SliceInt16) Transform(fn func(elem int16) int16) *SliceInt16

Transform modifies each element of SliceInt16 according to the specified function.

func (*SliceInt16) Unique

func (s *SliceInt16) Unique() *SliceInt16

Unique modifies SliceInt16 to keep only the first occurrence of each element (removing any duplicates).

type SliceInt32

type SliceInt32 struct {
	// contains filtered or unexported fields
}

SliceInt32 is a slice of type int32.

func NewSliceInt32

func NewSliceInt32(elems ...int32) *SliceInt32

NewSliceInt32 returns a pointer to a new SliceInt32 initialized with the specified elements.

func (*SliceInt32) Append

func (s *SliceInt32) Append(elems ...int32) *SliceInt32

Append adds the elements to the end of SliceInt32.

func (*SliceInt32) At

func (s *SliceInt32) At(index int) int32

At returns the element in SliceInt32 at the specified index.

func (*SliceInt32) Clone

func (s *SliceInt32) Clone() *SliceInt32

Clone performs a deep copy of SliceInt32 and returns it

func (*SliceInt32) Count

func (s *SliceInt32) Count() int

Count returns the number of elements in SliceInt32.

func (*SliceInt32) Data

func (s *SliceInt32) Data() []int32

Data returns the raw elements of SliceInt32.

func (*SliceInt32) Equal

func (s *SliceInt32) Equal(s2 *SliceInt32) bool

Equal returns true if the SliceInt32 is logically equivalent to the specified SliceInt32.

func (*SliceInt32) Filter

func (s *SliceInt32) Filter(fn func(elem int32) bool) *SliceInt32

Filter removes elements from SliceInt32 that do not satisfy the filter function.

func (*SliceInt32) Insert

func (s *SliceInt32) Insert(index int, elems ...int32) *SliceInt32

Insert inserts the elements into SliceInt32 at the specified index.

func (*SliceInt32) Len

func (s *SliceInt32) Len() int

Len returns the number of elements in SliceInt32 (alias for Count).

func (*SliceInt32) Less

func (s *SliceInt32) Less(i, j int) bool

Less returns true if the SliceInt32 element at index i is less than the element at index j.

func (*SliceInt32) Max

func (s *SliceInt32) Max() int32

Max returns the largest (greatest ordered) element in SliceInt32.

func (*SliceInt32) Min

func (s *SliceInt32) Min() int32

Min returns the smallest (least ordered) element in SliceInt32.

func (*SliceInt32) Prepend

func (s *SliceInt32) Prepend(elems ...int32) *SliceInt32

Prepend adds the elements to the beginning of SliceInt32.

func (*SliceInt32) Remove

func (s *SliceInt32) Remove(index int) *SliceInt32

Remove removes the element from SliceInt32 at the specified index.

func (*SliceInt32) Reverse

func (s *SliceInt32) Reverse() *SliceInt32

Reverse reverses the order of the elements of SliceInt32.

func (*SliceInt32) Set

func (s *SliceInt32) Set(index int, elem int32) *SliceInt32

Set sets the element of SliceInt32 at the specified index.

func (*SliceInt32) Shuffle

func (s *SliceInt32) Shuffle(seed int64) *SliceInt32

Shuffle randomly shuffles the order of the elements in SliceInt32.

func (*SliceInt32) Sort

func (s *SliceInt32) Sort() *SliceInt32

Sort sorts the elements of SliceInt32 in increasing order.

func (*SliceInt32) Swap

func (s *SliceInt32) Swap(i, j int)

Swap swaps the elements in SliceInt32 specified by the indices i and j.

func (*SliceInt32) Transform

func (s *SliceInt32) Transform(fn func(elem int32) int32) *SliceInt32

Transform modifies each element of SliceInt32 according to the specified function.

func (*SliceInt32) Unique

func (s *SliceInt32) Unique() *SliceInt32

Unique modifies SliceInt32 to keep only the first occurrence of each element (removing any duplicates).

type SliceInt64

type SliceInt64 struct {
	// contains filtered or unexported fields
}

SliceInt64 is a slice of type int64.

func NewSliceInt64

func NewSliceInt64(elems ...int64) *SliceInt64

NewSliceInt64 returns a pointer to a new SliceInt64 initialized with the specified elements.

func (*SliceInt64) Append

func (s *SliceInt64) Append(elems ...int64) *SliceInt64

Append adds the elements to the end of SliceInt64.

func (*SliceInt64) At

func (s *SliceInt64) At(index int) int64

At returns the element in SliceInt64 at the specified index.

func (*SliceInt64) Clone

func (s *SliceInt64) Clone() *SliceInt64

Clone performs a deep copy of SliceInt64 and returns it

func (*SliceInt64) Count

func (s *SliceInt64) Count() int

Count returns the number of elements in SliceInt64.

func (*SliceInt64) Data

func (s *SliceInt64) Data() []int64

Data returns the raw elements of SliceInt64.

func (*SliceInt64) Equal

func (s *SliceInt64) Equal(s2 *SliceInt64) bool

Equal returns true if the SliceInt64 is logically equivalent to the specified SliceInt64.

func (*SliceInt64) Filter

func (s *SliceInt64) Filter(fn func(elem int64) bool) *SliceInt64

Filter removes elements from SliceInt64 that do not satisfy the filter function.

func (*SliceInt64) Insert

func (s *SliceInt64) Insert(index int, elems ...int64) *SliceInt64

Insert inserts the elements into SliceInt64 at the specified index.

func (*SliceInt64) Len

func (s *SliceInt64) Len() int

Len returns the number of elements in SliceInt64 (alias for Count).

func (*SliceInt64) Less

func (s *SliceInt64) Less(i, j int) bool

Less returns true if the SliceInt64 element at index i is less than the element at index j.

func (*SliceInt64) Max

func (s *SliceInt64) Max() int64

Max returns the largest (greatest ordered) element in SliceInt64.

func (*SliceInt64) Min

func (s *SliceInt64) Min() int64

Min returns the smallest (least ordered) element in SliceInt64.

func (*SliceInt64) Prepend

func (s *SliceInt64) Prepend(elems ...int64) *SliceInt64

Prepend adds the elements to the beginning of SliceInt64.

func (*SliceInt64) Remove

func (s *SliceInt64) Remove(index int) *SliceInt64

Remove removes the element from SliceInt64 at the specified index.

func (*SliceInt64) Reverse

func (s *SliceInt64) Reverse() *SliceInt64

Reverse reverses the order of the elements of SliceInt64.

func (*SliceInt64) Set

func (s *SliceInt64) Set(index int, elem int64) *SliceInt64

Set sets the element of SliceInt64 at the specified index.

func (*SliceInt64) Shuffle

func (s *SliceInt64) Shuffle(seed int64) *SliceInt64

Shuffle randomly shuffles the order of the elements in SliceInt64.

func (*SliceInt64) Sort

func (s *SliceInt64) Sort() *SliceInt64

Sort sorts the elements of SliceInt64 in increasing order.

func (*SliceInt64) Swap

func (s *SliceInt64) Swap(i, j int)

Swap swaps the elements in SliceInt64 specified by the indices i and j.

func (*SliceInt64) Transform

func (s *SliceInt64) Transform(fn func(elem int64) int64) *SliceInt64

Transform modifies each element of SliceInt64 according to the specified function.

func (*SliceInt64) Unique

func (s *SliceInt64) Unique() *SliceInt64

Unique modifies SliceInt64 to keep only the first occurrence of each element (removing any duplicates).

type SliceInt8

type SliceInt8 struct {
	// contains filtered or unexported fields
}

SliceInt8 is a slice of type int8.

func NewSliceInt8

func NewSliceInt8(elems ...int8) *SliceInt8

NewSliceInt8 returns a pointer to a new SliceInt8 initialized with the specified elements.

func (*SliceInt8) Append

func (s *SliceInt8) Append(elems ...int8) *SliceInt8

Append adds the elements to the end of SliceInt8.

func (*SliceInt8) At

func (s *SliceInt8) At(index int) int8

At returns the element in SliceInt8 at the specified index.

func (*SliceInt8) Clone

func (s *SliceInt8) Clone() *SliceInt8

Clone performs a deep copy of SliceInt8 and returns it

func (*SliceInt8) Count

func (s *SliceInt8) Count() int

Count returns the number of elements in SliceInt8.

func (*SliceInt8) Data

func (s *SliceInt8) Data() []int8

Data returns the raw elements of SliceInt8.

func (*SliceInt8) Equal

func (s *SliceInt8) Equal(s2 *SliceInt8) bool

Equal returns true if the SliceInt8 is logically equivalent to the specified SliceInt8.

func (*SliceInt8) Filter

func (s *SliceInt8) Filter(fn func(elem int8) bool) *SliceInt8

Filter removes elements from SliceInt8 that do not satisfy the filter function.

func (*SliceInt8) Insert

func (s *SliceInt8) Insert(index int, elems ...int8) *SliceInt8

Insert inserts the elements into SliceInt8 at the specified index.

func (*SliceInt8) Len

func (s *SliceInt8) Len() int

Len returns the number of elements in SliceInt8 (alias for Count).

func (*SliceInt8) Less

func (s *SliceInt8) Less(i, j int) bool

Less returns true if the SliceInt8 element at index i is less than the element at index j.

func (*SliceInt8) Max

func (s *SliceInt8) Max() int8

Max returns the largest (greatest ordered) element in SliceInt8.

func (*SliceInt8) Min

func (s *SliceInt8) Min() int8

Min returns the smallest (least ordered) element in SliceInt8.

func (*SliceInt8) Prepend

func (s *SliceInt8) Prepend(elems ...int8) *SliceInt8

Prepend adds the elements to the beginning of SliceInt8.

func (*SliceInt8) Remove

func (s *SliceInt8) Remove(index int) *SliceInt8

Remove removes the element from SliceInt8 at the specified index.

func (*SliceInt8) Reverse

func (s *SliceInt8) Reverse() *SliceInt8

Reverse reverses the order of the elements of SliceInt8.

func (*SliceInt8) Set

func (s *SliceInt8) Set(index int, elem int8) *SliceInt8

Set sets the element of SliceInt8 at the specified index.

func (*SliceInt8) Shuffle

func (s *SliceInt8) Shuffle(seed int64) *SliceInt8

Shuffle randomly shuffles the order of the elements in SliceInt8.

func (*SliceInt8) Sort

func (s *SliceInt8) Sort() *SliceInt8

Sort sorts the elements of SliceInt8 in increasing order.

func (*SliceInt8) Swap

func (s *SliceInt8) Swap(i, j int)

Swap swaps the elements in SliceInt8 specified by the indices i and j.

func (*SliceInt8) Transform

func (s *SliceInt8) Transform(fn func(elem int8) int8) *SliceInt8

Transform modifies each element of SliceInt8 according to the specified function.

func (*SliceInt8) Unique

func (s *SliceInt8) Unique() *SliceInt8

Unique modifies SliceInt8 to keep only the first occurrence of each element (removing any duplicates).

type SliceRune

type SliceRune struct {
	// contains filtered or unexported fields
}

SliceRune is a slice of type rune.

func NewSliceRune

func NewSliceRune(elems ...rune) *SliceRune

NewSliceRune returns a pointer to a new SliceRune initialized with the specified elements.

func (*SliceRune) Append

func (s *SliceRune) Append(elems ...rune) *SliceRune

Append adds the elements to the end of SliceRune.

func (*SliceRune) At

func (s *SliceRune) At(index int) rune

At returns the element in SliceRune at the specified index.

func (*SliceRune) Clone

func (s *SliceRune) Clone() *SliceRune

Clone performs a deep copy of SliceRune and returns it

func (*SliceRune) Count

func (s *SliceRune) Count() int

Count returns the number of elements in SliceRune.

func (*SliceRune) Data

func (s *SliceRune) Data() []rune

Data returns the raw elements of SliceRune.

func (*SliceRune) Equal

func (s *SliceRune) Equal(s2 *SliceRune) bool

Equal returns true if the SliceRune is logically equivalent to the specified SliceRune.

func (*SliceRune) Filter

func (s *SliceRune) Filter(fn func(elem rune) bool) *SliceRune

Filter removes elements from SliceRune that do not satisfy the filter function.

func (*SliceRune) Insert

func (s *SliceRune) Insert(index int, elems ...rune) *SliceRune

Insert inserts the elements into SliceRune at the specified index.

func (*SliceRune) Len

func (s *SliceRune) Len() int

Len returns the number of elements in SliceRune (alias for Count).

func (*SliceRune) Less

func (s *SliceRune) Less(i, j int) bool

Less returns true if the SliceRune element at index i is less than the element at index j.

func (*SliceRune) Max

func (s *SliceRune) Max() rune

Max returns the largest (greatest ordered) element in SliceRune.

func (*SliceRune) Min

func (s *SliceRune) Min() rune

Min returns the smallest (least ordered) element in SliceRune.

func (*SliceRune) Prepend

func (s *SliceRune) Prepend(elems ...rune) *SliceRune

Prepend adds the elements to the beginning of SliceRune.

func (*SliceRune) Remove

func (s *SliceRune) Remove(index int) *SliceRune

Remove removes the element from SliceRune at the specified index.

func (*SliceRune) Reverse

func (s *SliceRune) Reverse() *SliceRune

Reverse reverses the order of the elements of SliceRune.

func (*SliceRune) Set

func (s *SliceRune) Set(index int, elem rune) *SliceRune

Set sets the element of SliceRune at the specified index.

func (*SliceRune) Shuffle

func (s *SliceRune) Shuffle(seed int64) *SliceRune

Shuffle randomly shuffles the order of the elements in SliceRune.

func (*SliceRune) Sort

func (s *SliceRune) Sort() *SliceRune

Sort sorts the elements of SliceRune in increasing order.

func (*SliceRune) Swap

func (s *SliceRune) Swap(i, j int)

Swap swaps the elements in SliceRune specified by the indices i and j.

func (*SliceRune) Transform

func (s *SliceRune) Transform(fn func(elem rune) rune) *SliceRune

Transform modifies each element of SliceRune according to the specified function.

func (*SliceRune) Unique

func (s *SliceRune) Unique() *SliceRune

Unique modifies SliceRune to keep only the first occurrence of each element (removing any duplicates).

type SliceString

type SliceString struct {
	// contains filtered or unexported fields
}

SliceString is a slice of type string.

func NewSliceString

func NewSliceString(elems ...string) *SliceString

NewSliceString returns a pointer to a new SliceString initialized with the specified elements.

func (*SliceString) Append

func (s *SliceString) Append(elems ...string) *SliceString

Append adds the elements to the end of SliceString.

func (*SliceString) At

func (s *SliceString) At(index int) string

At returns the element in SliceString at the specified index.

func (*SliceString) Clone

func (s *SliceString) Clone() *SliceString

Clone performs a deep copy of SliceString and returns it

func (*SliceString) Count

func (s *SliceString) Count() int

Count returns the number of elements in SliceString.

func (*SliceString) Data

func (s *SliceString) Data() []string

Data returns the raw elements of SliceString.

func (*SliceString) Equal

func (s *SliceString) Equal(s2 *SliceString) bool

Equal returns true if the SliceString is logically equivalent to the specified SliceString.

func (*SliceString) Filter

func (s *SliceString) Filter(fn func(elem string) bool) *SliceString

Filter removes elements from SliceString that do not satisfy the filter function.

func (*SliceString) Insert

func (s *SliceString) Insert(index int, elems ...string) *SliceString

Insert inserts the elements into SliceString at the specified index.

func (*SliceString) Len

func (s *SliceString) Len() int

Len returns the number of elements in SliceString (alias for Count).

func (*SliceString) Less

func (s *SliceString) Less(i, j int) bool

Less returns true if the SliceString element at index i is less than the element at index j.

func (*SliceString) Max

func (s *SliceString) Max() string

Max returns the largest (greatest ordered) element in SliceString.

func (*SliceString) Min

func (s *SliceString) Min() string

Min returns the smallest (least ordered) element in SliceString.

func (*SliceString) Prepend

func (s *SliceString) Prepend(elems ...string) *SliceString

Prepend adds the elements to the beginning of SliceString.

func (*SliceString) Remove

func (s *SliceString) Remove(index int) *SliceString

Remove removes the element from SliceString at the specified index.

func (*SliceString) Reverse

func (s *SliceString) Reverse() *SliceString

Reverse reverses the order of the elements of SliceString.

func (*SliceString) Set

func (s *SliceString) Set(index int, elem string) *SliceString

Set sets the element of SliceString at the specified index.

func (*SliceString) Shuffle

func (s *SliceString) Shuffle(seed int64) *SliceString

Shuffle randomly shuffles the order of the elements in SliceString.

func (*SliceString) Sort

func (s *SliceString) Sort() *SliceString

Sort sorts the elements of SliceString in increasing order.

func (*SliceString) Swap

func (s *SliceString) Swap(i, j int)

Swap swaps the elements in SliceString specified by the indices i and j.

func (*SliceString) Transform

func (s *SliceString) Transform(fn func(elem string) string) *SliceString

Transform modifies each element of SliceString according to the specified function.

func (*SliceString) Unique

func (s *SliceString) Unique() *SliceString

Unique modifies SliceString to keep only the first occurrence of each element (removing any duplicates).

type SliceUint

type SliceUint struct {
	// contains filtered or unexported fields
}

SliceUint is a slice of type uint.

func NewSliceUint

func NewSliceUint(elems ...uint) *SliceUint

NewSliceUint returns a pointer to a new SliceUint initialized with the specified elements.

func (*SliceUint) Append

func (s *SliceUint) Append(elems ...uint) *SliceUint

Append adds the elements to the end of SliceUint.

func (*SliceUint) At

func (s *SliceUint) At(index int) uint

At returns the element in SliceUint at the specified index.

func (*SliceUint) Clone

func (s *SliceUint) Clone() *SliceUint

Clone performs a deep copy of SliceUint and returns it

func (*SliceUint) Count

func (s *SliceUint) Count() int

Count returns the number of elements in SliceUint.

func (*SliceUint) Data

func (s *SliceUint) Data() []uint

Data returns the raw elements of SliceUint.

func (*SliceUint) Equal

func (s *SliceUint) Equal(s2 *SliceUint) bool

Equal returns true if the SliceUint is logically equivalent to the specified SliceUint.

func (*SliceUint) Filter

func (s *SliceUint) Filter(fn func(elem uint) bool) *SliceUint

Filter removes elements from SliceUint that do not satisfy the filter function.

func (*SliceUint) Insert

func (s *SliceUint) Insert(index int, elems ...uint) *SliceUint

Insert inserts the elements into SliceUint at the specified index.

func (*SliceUint) Len

func (s *SliceUint) Len() int

Len returns the number of elements in SliceUint (alias for Count).

func (*SliceUint) Less

func (s *SliceUint) Less(i, j int) bool

Less returns true if the SliceUint element at index i is less than the element at index j.

func (*SliceUint) Max

func (s *SliceUint) Max() uint

Max returns the largest (greatest ordered) element in SliceUint.

func (*SliceUint) Min

func (s *SliceUint) Min() uint

Min returns the smallest (least ordered) element in SliceUint.

func (*SliceUint) Prepend

func (s *SliceUint) Prepend(elems ...uint) *SliceUint

Prepend adds the elements to the beginning of SliceUint.

func (*SliceUint) Remove

func (s *SliceUint) Remove(index int) *SliceUint

Remove removes the element from SliceUint at the specified index.

func (*SliceUint) Reverse

func (s *SliceUint) Reverse() *SliceUint

Reverse reverses the order of the elements of SliceUint.

func (*SliceUint) Set

func (s *SliceUint) Set(index int, elem uint) *SliceUint

Set sets the element of SliceUint at the specified index.

func (*SliceUint) Shuffle

func (s *SliceUint) Shuffle(seed int64) *SliceUint

Shuffle randomly shuffles the order of the elements in SliceUint.

func (*SliceUint) Sort

func (s *SliceUint) Sort() *SliceUint

Sort sorts the elements of SliceUint in increasing order.

func (*SliceUint) Swap

func (s *SliceUint) Swap(i, j int)

Swap swaps the elements in SliceUint specified by the indices i and j.

func (*SliceUint) Transform

func (s *SliceUint) Transform(fn func(elem uint) uint) *SliceUint

Transform modifies each element of SliceUint according to the specified function.

func (*SliceUint) Unique

func (s *SliceUint) Unique() *SliceUint

Unique modifies SliceUint to keep only the first occurrence of each element (removing any duplicates).

type SliceUint16

type SliceUint16 struct {
	// contains filtered or unexported fields
}

SliceUint16 is a slice of type uint16.

func NewSliceUint16

func NewSliceUint16(elems ...uint16) *SliceUint16

NewSliceUint16 returns a pointer to a new SliceUint16 initialized with the specified elements.

func (*SliceUint16) Append

func (s *SliceUint16) Append(elems ...uint16) *SliceUint16

Append adds the elements to the end of SliceUint16.

func (*SliceUint16) At

func (s *SliceUint16) At(index int) uint16

At returns the element in SliceUint16 at the specified index.

func (*SliceUint16) Clone

func (s *SliceUint16) Clone() *SliceUint16

Clone performs a deep copy of SliceUint16 and returns it

func (*SliceUint16) Count

func (s *SliceUint16) Count() int

Count returns the number of elements in SliceUint16.

func (*SliceUint16) Data

func (s *SliceUint16) Data() []uint16

Data returns the raw elements of SliceUint16.

func (*SliceUint16) Equal

func (s *SliceUint16) Equal(s2 *SliceUint16) bool

Equal returns true if the SliceUint16 is logically equivalent to the specified SliceUint16.

func (*SliceUint16) Filter

func (s *SliceUint16) Filter(fn func(elem uint16) bool) *SliceUint16

Filter removes elements from SliceUint16 that do not satisfy the filter function.

func (*SliceUint16) Insert

func (s *SliceUint16) Insert(index int, elems ...uint16) *SliceUint16

Insert inserts the elements into SliceUint16 at the specified index.

func (*SliceUint16) Len

func (s *SliceUint16) Len() int

Len returns the number of elements in SliceUint16 (alias for Count).

func (*SliceUint16) Less

func (s *SliceUint16) Less(i, j int) bool

Less returns true if the SliceUint16 element at index i is less than the element at index j.

func (*SliceUint16) Max

func (s *SliceUint16) Max() uint16

Max returns the largest (greatest ordered) element in SliceUint16.

func (*SliceUint16) Min

func (s *SliceUint16) Min() uint16

Min returns the smallest (least ordered) element in SliceUint16.

func (*SliceUint16) Prepend

func (s *SliceUint16) Prepend(elems ...uint16) *SliceUint16

Prepend adds the elements to the beginning of SliceUint16.

func (*SliceUint16) Remove

func (s *SliceUint16) Remove(index int) *SliceUint16

Remove removes the element from SliceUint16 at the specified index.

func (*SliceUint16) Reverse

func (s *SliceUint16) Reverse() *SliceUint16

Reverse reverses the order of the elements of SliceUint16.

func (*SliceUint16) Set

func (s *SliceUint16) Set(index int, elem uint16) *SliceUint16

Set sets the element of SliceUint16 at the specified index.

func (*SliceUint16) Shuffle

func (s *SliceUint16) Shuffle(seed int64) *SliceUint16

Shuffle randomly shuffles the order of the elements in SliceUint16.

func (*SliceUint16) Sort

func (s *SliceUint16) Sort() *SliceUint16

Sort sorts the elements of SliceUint16 in increasing order.

func (*SliceUint16) Swap

func (s *SliceUint16) Swap(i, j int)

Swap swaps the elements in SliceUint16 specified by the indices i and j.

func (*SliceUint16) Transform

func (s *SliceUint16) Transform(fn func(elem uint16) uint16) *SliceUint16

Transform modifies each element of SliceUint16 according to the specified function.

func (*SliceUint16) Unique

func (s *SliceUint16) Unique() *SliceUint16

Unique modifies SliceUint16 to keep only the first occurrence of each element (removing any duplicates).

type SliceUint32

type SliceUint32 struct {
	// contains filtered or unexported fields
}

SliceUint32 is a slice of type uint32.

func NewSliceUint32

func NewSliceUint32(elems ...uint32) *SliceUint32

NewSliceUint32 returns a pointer to a new SliceUint32 initialized with the specified elements.

func (*SliceUint32) Append

func (s *SliceUint32) Append(elems ...uint32) *SliceUint32

Append adds the elements to the end of SliceUint32.

func (*SliceUint32) At

func (s *SliceUint32) At(index int) uint32

At returns the element in SliceUint32 at the specified index.

func (*SliceUint32) Clone

func (s *SliceUint32) Clone() *SliceUint32

Clone performs a deep copy of SliceUint32 and returns it

func (*SliceUint32) Count

func (s *SliceUint32) Count() int

Count returns the number of elements in SliceUint32.

func (*SliceUint32) Data

func (s *SliceUint32) Data() []uint32

Data returns the raw elements of SliceUint32.

func (*SliceUint32) Equal

func (s *SliceUint32) Equal(s2 *SliceUint32) bool

Equal returns true if the SliceUint32 is logically equivalent to the specified SliceUint32.

func (*SliceUint32) Filter

func (s *SliceUint32) Filter(fn func(elem uint32) bool) *SliceUint32

Filter removes elements from SliceUint32 that do not satisfy the filter function.

func (*SliceUint32) Insert

func (s *SliceUint32) Insert(index int, elems ...uint32) *SliceUint32

Insert inserts the elements into SliceUint32 at the specified index.

func (*SliceUint32) Len

func (s *SliceUint32) Len() int

Len returns the number of elements in SliceUint32 (alias for Count).

func (*SliceUint32) Less

func (s *SliceUint32) Less(i, j int) bool

Less returns true if the SliceUint32 element at index i is less than the element at index j.

func (*SliceUint32) Max

func (s *SliceUint32) Max() uint32

Max returns the largest (greatest ordered) element in SliceUint32.

func (*SliceUint32) Min

func (s *SliceUint32) Min() uint32

Min returns the smallest (least ordered) element in SliceUint32.

func (*SliceUint32) Prepend

func (s *SliceUint32) Prepend(elems ...uint32) *SliceUint32

Prepend adds the elements to the beginning of SliceUint32.

func (*SliceUint32) Remove

func (s *SliceUint32) Remove(index int) *SliceUint32

Remove removes the element from SliceUint32 at the specified index.

func (*SliceUint32) Reverse

func (s *SliceUint32) Reverse() *SliceUint32

Reverse reverses the order of the elements of SliceUint32.

func (*SliceUint32) Set

func (s *SliceUint32) Set(index int, elem uint32) *SliceUint32

Set sets the element of SliceUint32 at the specified index.

func (*SliceUint32) Shuffle

func (s *SliceUint32) Shuffle(seed int64) *SliceUint32

Shuffle randomly shuffles the order of the elements in SliceUint32.

func (*SliceUint32) Sort

func (s *SliceUint32) Sort() *SliceUint32

Sort sorts the elements of SliceUint32 in increasing order.

func (*SliceUint32) Swap

func (s *SliceUint32) Swap(i, j int)

Swap swaps the elements in SliceUint32 specified by the indices i and j.

func (*SliceUint32) Transform

func (s *SliceUint32) Transform(fn func(elem uint32) uint32) *SliceUint32

Transform modifies each element of SliceUint32 according to the specified function.

func (*SliceUint32) Unique

func (s *SliceUint32) Unique() *SliceUint32

Unique modifies SliceUint32 to keep only the first occurrence of each element (removing any duplicates).

type SliceUint64

type SliceUint64 struct {
	// contains filtered or unexported fields
}

SliceUint64 is a slice of type uint64.

func NewSliceUint64

func NewSliceUint64(elems ...uint64) *SliceUint64

NewSliceUint64 returns a pointer to a new SliceUint64 initialized with the specified elements.

func (*SliceUint64) Append

func (s *SliceUint64) Append(elems ...uint64) *SliceUint64

Append adds the elements to the end of SliceUint64.

func (*SliceUint64) At

func (s *SliceUint64) At(index int) uint64

At returns the element in SliceUint64 at the specified index.

func (*SliceUint64) Clone

func (s *SliceUint64) Clone() *SliceUint64

Clone performs a deep copy of SliceUint64 and returns it

func (*SliceUint64) Count

func (s *SliceUint64) Count() int

Count returns the number of elements in SliceUint64.

func (*SliceUint64) Data

func (s *SliceUint64) Data() []uint64

Data returns the raw elements of SliceUint64.

func (*SliceUint64) Equal

func (s *SliceUint64) Equal(s2 *SliceUint64) bool

Equal returns true if the SliceUint64 is logically equivalent to the specified SliceUint64.

func (*SliceUint64) Filter

func (s *SliceUint64) Filter(fn func(elem uint64) bool) *SliceUint64

Filter removes elements from SliceUint64 that do not satisfy the filter function.

func (*SliceUint64) Insert

func (s *SliceUint64) Insert(index int, elems ...uint64) *SliceUint64

Insert inserts the elements into SliceUint64 at the specified index.

func (*SliceUint64) Len

func (s *SliceUint64) Len() int

Len returns the number of elements in SliceUint64 (alias for Count).

func (*SliceUint64) Less

func (s *SliceUint64) Less(i, j int) bool

Less returns true if the SliceUint64 element at index i is less than the element at index j.

func (*SliceUint64) Max

func (s *SliceUint64) Max() uint64

Max returns the largest (greatest ordered) element in SliceUint64.

func (*SliceUint64) Min

func (s *SliceUint64) Min() uint64

Min returns the smallest (least ordered) element in SliceUint64.

func (*SliceUint64) Prepend

func (s *SliceUint64) Prepend(elems ...uint64) *SliceUint64

Prepend adds the elements to the beginning of SliceUint64.

func (*SliceUint64) Remove

func (s *SliceUint64) Remove(index int) *SliceUint64

Remove removes the element from SliceUint64 at the specified index.

func (*SliceUint64) Reverse

func (s *SliceUint64) Reverse() *SliceUint64

Reverse reverses the order of the elements of SliceUint64.

func (*SliceUint64) Set

func (s *SliceUint64) Set(index int, elem uint64) *SliceUint64

Set sets the element of SliceUint64 at the specified index.

func (*SliceUint64) Shuffle

func (s *SliceUint64) Shuffle(seed int64) *SliceUint64

Shuffle randomly shuffles the order of the elements in SliceUint64.

func (*SliceUint64) Sort

func (s *SliceUint64) Sort() *SliceUint64

Sort sorts the elements of SliceUint64 in increasing order.

func (*SliceUint64) Swap

func (s *SliceUint64) Swap(i, j int)

Swap swaps the elements in SliceUint64 specified by the indices i and j.

func (*SliceUint64) Transform

func (s *SliceUint64) Transform(fn func(elem uint64) uint64) *SliceUint64

Transform modifies each element of SliceUint64 according to the specified function.

func (*SliceUint64) Unique

func (s *SliceUint64) Unique() *SliceUint64

Unique modifies SliceUint64 to keep only the first occurrence of each element (removing any duplicates).

type SliceUint8

type SliceUint8 struct {
	// contains filtered or unexported fields
}

SliceUint8 is a slice of type uint8.

func NewSliceUint8

func NewSliceUint8(elems ...uint8) *SliceUint8

NewSliceUint8 returns a pointer to a new SliceUint8 initialized with the specified elements.

func (*SliceUint8) Append

func (s *SliceUint8) Append(elems ...uint8) *SliceUint8

Append adds the elements to the end of SliceUint8.

func (*SliceUint8) At

func (s *SliceUint8) At(index int) uint8

At returns the element in SliceUint8 at the specified index.

func (*SliceUint8) Clone

func (s *SliceUint8) Clone() *SliceUint8

Clone performs a deep copy of SliceUint8 and returns it

func (*SliceUint8) Count

func (s *SliceUint8) Count() int

Count returns the number of elements in SliceUint8.

func (*SliceUint8) Data

func (s *SliceUint8) Data() []uint8

Data returns the raw elements of SliceUint8.

func (*SliceUint8) Equal

func (s *SliceUint8) Equal(s2 *SliceUint8) bool

Equal returns true if the SliceUint8 is logically equivalent to the specified SliceUint8.

func (*SliceUint8) Filter

func (s *SliceUint8) Filter(fn func(elem uint8) bool) *SliceUint8

Filter removes elements from SliceUint8 that do not satisfy the filter function.

func (*SliceUint8) Insert

func (s *SliceUint8) Insert(index int, elems ...uint8) *SliceUint8

Insert inserts the elements into SliceUint8 at the specified index.

func (*SliceUint8) Len

func (s *SliceUint8) Len() int

Len returns the number of elements in SliceUint8 (alias for Count).

func (*SliceUint8) Less

func (s *SliceUint8) Less(i, j int) bool

Less returns true if the SliceUint8 element at index i is less than the element at index j.

func (*SliceUint8) Max

func (s *SliceUint8) Max() uint8

Max returns the largest (greatest ordered) element in SliceUint8.

func (*SliceUint8) Min

func (s *SliceUint8) Min() uint8

Min returns the smallest (least ordered) element in SliceUint8.

func (*SliceUint8) Prepend

func (s *SliceUint8) Prepend(elems ...uint8) *SliceUint8

Prepend adds the elements to the beginning of SliceUint8.

func (*SliceUint8) Remove

func (s *SliceUint8) Remove(index int) *SliceUint8

Remove removes the element from SliceUint8 at the specified index.

func (*SliceUint8) Reverse

func (s *SliceUint8) Reverse() *SliceUint8

Reverse reverses the order of the elements of SliceUint8.

func (*SliceUint8) Set

func (s *SliceUint8) Set(index int, elem uint8) *SliceUint8

Set sets the element of SliceUint8 at the specified index.

func (*SliceUint8) Shuffle

func (s *SliceUint8) Shuffle(seed int64) *SliceUint8

Shuffle randomly shuffles the order of the elements in SliceUint8.

func (*SliceUint8) Sort

func (s *SliceUint8) Sort() *SliceUint8

Sort sorts the elements of SliceUint8 in increasing order.

func (*SliceUint8) Swap

func (s *SliceUint8) Swap(i, j int)

Swap swaps the elements in SliceUint8 specified by the indices i and j.

func (*SliceUint8) Transform

func (s *SliceUint8) Transform(fn func(elem uint8) uint8) *SliceUint8

Transform modifies each element of SliceUint8 according to the specified function.

func (*SliceUint8) Unique

func (s *SliceUint8) Unique() *SliceUint8

Unique modifies SliceUint8 to keep only the first occurrence of each element (removing any duplicates).

type SliceUintptr

type SliceUintptr struct {
	// contains filtered or unexported fields
}

SliceUintptr is a slice of type uintptr.

func NewSliceUintptr

func NewSliceUintptr(elems ...uintptr) *SliceUintptr

NewSliceUintptr returns a pointer to a new SliceUintptr initialized with the specified elements.

func (*SliceUintptr) Append

func (s *SliceUintptr) Append(elems ...uintptr) *SliceUintptr

Append adds the elements to the end of SliceUintptr.

func (*SliceUintptr) At

func (s *SliceUintptr) At(index int) uintptr

At returns the element in SliceUintptr at the specified index.

func (*SliceUintptr) Clone

func (s *SliceUintptr) Clone() *SliceUintptr

Clone performs a deep copy of SliceUintptr and returns it

func (*SliceUintptr) Count

func (s *SliceUintptr) Count() int

Count returns the number of elements in SliceUintptr.

func (*SliceUintptr) Data

func (s *SliceUintptr) Data() []uintptr

Data returns the raw elements of SliceUintptr.

func (*SliceUintptr) Equal

func (s *SliceUintptr) Equal(s2 *SliceUintptr) bool

Equal returns true if the SliceUintptr is logically equivalent to the specified SliceUintptr.

func (*SliceUintptr) Filter

func (s *SliceUintptr) Filter(fn func(elem uintptr) bool) *SliceUintptr

Filter removes elements from SliceUintptr that do not satisfy the filter function.

func (*SliceUintptr) Insert

func (s *SliceUintptr) Insert(index int, elems ...uintptr) *SliceUintptr

Insert inserts the elements into SliceUintptr at the specified index.

func (*SliceUintptr) Len

func (s *SliceUintptr) Len() int

Len returns the number of elements in SliceUintptr (alias for Count).

func (*SliceUintptr) Less

func (s *SliceUintptr) Less(i, j int) bool

Less returns true if the SliceUintptr element at index i is less than the element at index j.

func (*SliceUintptr) Max

func (s *SliceUintptr) Max() uintptr

Max returns the largest (greatest ordered) element in SliceUintptr.

func (*SliceUintptr) Min

func (s *SliceUintptr) Min() uintptr

Min returns the smallest (least ordered) element in SliceUintptr.

func (*SliceUintptr) Prepend

func (s *SliceUintptr) Prepend(elems ...uintptr) *SliceUintptr

Prepend adds the elements to the beginning of SliceUintptr.

func (*SliceUintptr) Remove

func (s *SliceUintptr) Remove(index int) *SliceUintptr

Remove removes the element from SliceUintptr at the specified index.

func (*SliceUintptr) Reverse

func (s *SliceUintptr) Reverse() *SliceUintptr

Reverse reverses the order of the elements of SliceUintptr.

func (*SliceUintptr) Set

func (s *SliceUintptr) Set(index int, elem uintptr) *SliceUintptr

Set sets the element of SliceUintptr at the specified index.

func (*SliceUintptr) Shuffle

func (s *SliceUintptr) Shuffle(seed int64) *SliceUintptr

Shuffle randomly shuffles the order of the elements in SliceUintptr.

func (*SliceUintptr) Sort

func (s *SliceUintptr) Sort() *SliceUintptr

Sort sorts the elements of SliceUintptr in increasing order.

func (*SliceUintptr) Swap

func (s *SliceUintptr) Swap(i, j int)

Swap swaps the elements in SliceUintptr specified by the indices i and j.

func (*SliceUintptr) Transform

func (s *SliceUintptr) Transform(fn func(elem uintptr) uintptr) *SliceUintptr

Transform modifies each element of SliceUintptr according to the specified function.

func (*SliceUintptr) Unique

func (s *SliceUintptr) Unique() *SliceUintptr

Unique modifies SliceUintptr to keep only the first occurrence of each element (removing any duplicates).

Directories

Path Synopsis
cmd
golist
Golist is a tool that generates 'Slice*' type wrappers for a given slice type T. Typically this process would be run using go generate, like this: //go:generate golist -type=Foo running this command golist -type=Foo in the same directory will create the file slice_foo.go containing a definition of type SliceFoo struct { data []Foo } The default type is SliceT or sliceT (depending on if the type is exported) and output file is slice_t.go.
Golist is a tool that generates 'Slice*' type wrappers for a given slice type T. Typically this process would be run using go generate, like this: //go:generate golist -type=Foo running this command golist -type=Foo in the same directory will create the file slice_foo.go containing a definition of type SliceFoo struct { data []Foo } The default type is SliceT or sliceT (depending on if the type is exported) and output file is slice_t.go.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL