collection

package
v0.0.0-...-7e56bdc Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: MIT Imports: 1 Imported by: 1

Documentation

Overview

Package collection implements collection types as UniqueStrings

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type UniqueStrings

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

UniqueStrings is a collection of distinct strings.

func NewUniqueStrings

func NewUniqueStrings() *UniqueStrings

NewUniqueStrings return a new empty UniqueStrings collection.

func (*UniqueStrings) Add

func (col *UniqueStrings) Add(s string) int

Add method adds the given string to the collection, if not already present. New strings are added at the end of the collection. Returns the item's position.

func (*UniqueStrings) AddSlice

func (col *UniqueStrings) AddSlice(astr []string)

AddSlice adds all element of the slice to the collection.

func (*UniqueStrings) Contains

func (col *UniqueStrings) Contains(s string) bool

Contains returns whether the given item is in the collection.

func (*UniqueStrings) Index

func (col *UniqueStrings) Index(s string) (int, bool)

Index returns the position of the given element in the collection.

func (*UniqueStrings) Len

func (col *UniqueStrings) Len() int

Len returns the number of elements of the collection.

func (*UniqueStrings) Sort

func (col *UniqueStrings) Sort()

Sort order the collection of strings.

func (*UniqueStrings) ToSlice

func (col *UniqueStrings) ToSlice() []string

ToSlice returns the collection items as a slice.

func (*UniqueStrings) Value

func (col *UniqueStrings) Value(i int) string

Value returns the element of the given position in the collection. if i<0 or i>=col.Len(), panic with "index out of range" runtime error.

Jump to

Keyboard shortcuts

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