list

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2023 License: Apache-2.0 Imports: 1 Imported by: 16

README

list 🔗

GoDoc Build Status Codecov Go Report Card Version

Simple List-Manipulation Utilities for Go

This library replicates a number of useful functions that I still miss from other languages. Feel free to use, or add to this library accordingly.

Pull Requests Welcome

This library is a work in progress, and will benefit from your experience reports, use cases, and contributions. If you have an idea for making this library better, send in a pull request. We're all in this together! 🔗

Documentation

Index

Constants

View Source
const DelimiterComma = ','
View Source
const DelimiterDot = '.'
View Source
const DelimiterEqual = '='
View Source
const DelimiterSemicolon = ';'
View Source
const DelimiterSlash = '/'
View Source
const DelimiterSpace = ' '

Variables

This section is empty.

Functions

func At

func At[T Stringlike](value T, delimiter byte, index int) string

at returns the list vaue at a particular index

func First added in v0.7.0

func First[T Stringlike](value T, delimiter byte) string

First returns the FIRST item in a list (alias for Head)

func Head[T Stringlike](value T, delimiter byte) string

Head returns the FIRST item in a list

func Index added in v0.3.0

func Index[T Stringlike](value T, delimiter byte) int

Index finds the first occurrence of the delimiter (-1 if not found)

func IsEmpty added in v0.3.0

func IsEmpty[T Stringlike](value T) bool

IsEmpty returns TRUE if the list is empty.

func IsEmptyTail added in v0.3.0

func IsEmptyTail[T Stringlike](value T, delimiter byte) bool

IsEmptyTail returns TRUE if this list only has one element

func Last

func Last[T Stringlike](value T, delimiter byte) string

Last returns the LAST item in a T-based-list

func LastIndex added in v0.3.0

func LastIndex[T Stringlike](value T, delimiter byte) int

LastIndex finds the last occurrence of the delimiter (-1 if not found)

func PushHead

func PushHead[T Stringlike](value T, headValue string, delimiter byte) T

PushHead adds a new item to the beginning of the list

func PushTail

func PushTail[T Stringlike](value T, tailValue string, delimiter byte) T

PushTail adds a new item to the end of the list

func RemoveLast

func RemoveLast[T Stringlike](value T, delimiter byte) T

RemoveLast returns the full list, with the last element removed.

func Split

func Split[T Stringlike](value T, delimiter byte) (string, T)

Split returns the FIRST element, and the REST element in one function call

func SplitTail

func SplitTail[T Stringlike](value T, delimiter byte) (T, string)

SplitTail behaves like split, but splits the beginning of the list from the last item in the list. So, the list "a,b,c" => "a,b", "c"

func Tail

func Tail[T Stringlike](value T, delimiter byte) T

Tail returns any values in the list AFTER the first item

Types

type Comma added in v0.3.0

type Comma string

func (Comma) At added in v0.3.0

func (list Comma) At(index int) string

func (Comma) Bytes added in v0.8.1

func (list Comma) Bytes() []byte

func (Comma) First added in v0.7.0

func (list Comma) First() string

func (Comma) Head added in v0.3.0

func (list Comma) Head() string

func (Comma) IsEmpty added in v0.3.0

func (list Comma) IsEmpty() bool

func (Comma) IsEmptyTail added in v0.3.0

func (list Comma) IsEmptyTail() bool

func (Comma) Last added in v0.3.0

func (list Comma) Last() string

func (Comma) PushHead added in v0.3.0

func (list Comma) PushHead(value string) List

func (Comma) PushTail added in v0.3.0

func (list Comma) PushTail(value string) List

func (Comma) RemoveLast added in v0.3.0

func (list Comma) RemoveLast() List

func (Comma) Split added in v0.3.0

func (list Comma) Split() (string, List)

func (Comma) SplitTail added in v0.3.0

func (list Comma) SplitTail() (List, string)

func (Comma) String added in v0.3.0

func (list Comma) String() string

func (Comma) Tail added in v0.3.0

func (list Comma) Tail() List

type Dot added in v0.3.0

type Dot string

func (Dot) At added in v0.3.0

func (list Dot) At(index int) string

func (Dot) Bytes added in v0.8.1

func (list Dot) Bytes() []byte

func (Dot) First added in v0.7.0

func (list Dot) First() string

func (Dot) Head added in v0.3.0

func (list Dot) Head() string

func (Dot) IsEmpty added in v0.3.0

func (list Dot) IsEmpty() bool

func (Dot) IsEmptyTail added in v0.3.0

func (list Dot) IsEmptyTail() bool

func (Dot) Last added in v0.3.0

func (list Dot) Last() string

func (Dot) PushHead added in v0.3.0

func (list Dot) PushHead(value string) List

func (Dot) PushTail added in v0.3.0

func (list Dot) PushTail(value string) List

func (Dot) RemoveLast added in v0.3.0

func (list Dot) RemoveLast() List

func (Dot) Split added in v0.3.0

func (list Dot) Split() (string, List)

func (Dot) SplitTail added in v0.3.0

func (list Dot) SplitTail() (List, string)

func (Dot) String added in v0.3.0

func (list Dot) String() string

func (Dot) Tail added in v0.3.0

func (list Dot) Tail() List

type Equal added in v0.3.0

type Equal string

func (Equal) At added in v0.3.0

func (list Equal) At(index int) string

func (Equal) Bytes added in v0.8.1

func (list Equal) Bytes() []byte

func (Equal) First added in v0.7.0

func (list Equal) First() string

func (Equal) Head added in v0.3.0

func (list Equal) Head() string

func (Equal) IsEmpty added in v0.3.0

func (list Equal) IsEmpty() bool

func (Equal) IsEmptyTail added in v0.3.0

func (list Equal) IsEmptyTail() bool

func (Equal) Last added in v0.3.0

func (list Equal) Last() string

func (Equal) PushHead added in v0.3.0

func (list Equal) PushHead(value string) List

func (Equal) PushTail added in v0.3.0

func (list Equal) PushTail(value string) List

func (Equal) RemoveLast added in v0.3.0

func (list Equal) RemoveLast() List

func (Equal) Split added in v0.3.0

func (list Equal) Split() (string, List)

func (Equal) SplitTail added in v0.3.0

func (list Equal) SplitTail() (List, string)

func (Equal) String added in v0.3.0

func (list Equal) String() string

func (Equal) Tail added in v0.3.0

func (list Equal) Tail() List

type List added in v0.6.0

type List interface {
	IsEmpty() bool
	IsEmptyTail() bool
	Head() string
	Tail() List
	First() string
	Last() string
	RemoveLast() List
	Split() (string, List)
	SplitTail() (List, string)
	At(index int) string
	PushHead(value string) List
	PushTail(value string) List
	String() string
	Bytes() []byte
}

List interface wraps all of the list manipulation methods implemented by standard lists in this library.

func ByComma added in v0.6.0

func ByComma(value ...string) List

func ByDot added in v0.6.0

func ByDot(value ...string) List

func ByEqual added in v0.6.0

func ByEqual(value ...string) List

func BySemicolon added in v0.7.0

func BySemicolon(value ...string) List

func BySlash added in v0.6.0

func BySlash(value ...string) List

func BySpace added in v0.6.0

func BySpace(value ...string) List

type Semicolon added in v0.7.0

type Semicolon string

func (Semicolon) At added in v0.7.0

func (list Semicolon) At(index int) string

func (Semicolon) Bytes added in v0.8.1

func (list Semicolon) Bytes() []byte

func (Semicolon) First added in v0.7.0

func (list Semicolon) First() string

func (Semicolon) Head added in v0.7.0

func (list Semicolon) Head() string

func (Semicolon) IsEmpty added in v0.7.0

func (list Semicolon) IsEmpty() bool

func (Semicolon) IsEmptyTail added in v0.7.0

func (list Semicolon) IsEmptyTail() bool

func (Semicolon) Last added in v0.7.0

func (list Semicolon) Last() string

func (Semicolon) PushHead added in v0.7.0

func (list Semicolon) PushHead(value string) List

func (Semicolon) PushTail added in v0.7.0

func (list Semicolon) PushTail(value string) List

func (Semicolon) RemoveLast added in v0.7.0

func (list Semicolon) RemoveLast() List

func (Semicolon) Split added in v0.7.0

func (list Semicolon) Split() (string, List)

func (Semicolon) SplitTail added in v0.7.0

func (list Semicolon) SplitTail() (List, string)

func (Semicolon) String added in v0.7.0

func (list Semicolon) String() string

func (Semicolon) Tail added in v0.7.0

func (list Semicolon) Tail() List

type Slash added in v0.3.0

type Slash string

func (Slash) At added in v0.3.0

func (list Slash) At(index int) string

func (Slash) Bytes added in v0.8.1

func (list Slash) Bytes() []byte

func (Slash) First added in v0.7.0

func (list Slash) First() string

func (Slash) Head added in v0.3.0

func (list Slash) Head() string

func (Slash) IsEmpty added in v0.3.0

func (list Slash) IsEmpty() bool

func (Slash) IsEmptyTail added in v0.3.0

func (list Slash) IsEmptyTail() bool

func (Slash) Last added in v0.3.0

func (list Slash) Last() string

func (Slash) PushHead added in v0.3.0

func (list Slash) PushHead(value string) List

func (Slash) PushTail added in v0.3.0

func (list Slash) PushTail(value string) List

func (Slash) RemoveLast added in v0.3.0

func (list Slash) RemoveLast() List

func (Slash) Split added in v0.3.0

func (list Slash) Split() (string, List)

func (Slash) SplitTail added in v0.3.0

func (list Slash) SplitTail() (List, string)

func (Slash) String added in v0.3.0

func (list Slash) String() string

func (Slash) Tail added in v0.3.0

func (list Slash) Tail() List

type Space added in v0.3.0

type Space string

func (Space) At added in v0.3.0

func (list Space) At(index int) string

func (Space) Bytes added in v0.8.1

func (list Space) Bytes() []byte

func (Space) First added in v0.7.0

func (list Space) First() string

func (Space) Head added in v0.3.0

func (list Space) Head() string

func (Space) IsEmpty added in v0.3.0

func (list Space) IsEmpty() bool

func (Space) IsEmptyTail added in v0.3.0

func (list Space) IsEmptyTail() bool

func (Space) Last added in v0.3.0

func (list Space) Last() string

func (Space) PushHead added in v0.3.0

func (list Space) PushHead(value string) List

func (Space) PushTail added in v0.3.0

func (list Space) PushTail(value string) List

func (Space) RemoveLast added in v0.3.0

func (list Space) RemoveLast() List

func (Space) Split added in v0.3.0

func (list Space) Split() (string, List)

func (Space) SplitTail added in v0.3.0

func (list Space) SplitTail() (List, string)

func (Space) String added in v0.3.0

func (list Space) String() string

func (Space) Tail added in v0.3.0

func (list Space) Tail() List

type Stringlike added in v0.3.0

type Stringlike interface {
	~string | []byte
}

Jump to

Keyboard shortcuts

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