util

package
v0.0.0-...-b7372ca Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2017 License: MIT Imports: 8 Imported by: 18

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Contains

func Contains(array []string, a string) bool

func ContentAsString

func ContentAsString(filePath string) string

Takes a path to a text file as an argument and returns the file's contents as a single string. If no file could be found under the given path, an error is thrown.

func CreateLowercaseAlphabet

func CreateLowercaseAlphabet() []string

func Filter

func Filter(input []string, toFilter []string) []string

func FindMatching

func FindMatching(input string, regexString string) []string

func IsAlphanumeric

func IsAlphanumeric(c rune) bool

func ReadLineFromFile

func ReadLineFromFile(file *os.File) (string, int)

func Scan

func Scan(input string, separator string) []string

Types

type SortablePair

type SortablePair struct {
	Key string
	Val int
}

func (*SortablePair) IncrementCount

func (pair *SortablePair) IncrementCount()

type SortablePairList

type SortablePairList []*SortablePair

func CountWords

func CountWords(input []string) SortablePairList

func (*SortablePairList) Add

func (pairList *SortablePairList) Add(pair *SortablePair)

Appends an element to the list.

func (*SortablePairList) ContainsKey

func (pairList *SortablePairList) ContainsKey(key string) bool

Check if the pair list contains any pair with the given key. Returns true if key exists, false otherwise.

func (*SortablePairList) Foreach

func (pairList *SortablePairList) Foreach(f func(*SortablePair))

Takes a function which is subsequently applied on each element of the list of sortable pairs.

func (*SortablePairList) Get

func (pairList *SortablePairList) Get(key string) (*SortablePair, error)

Retrieve an element by the corresponding key. If no such key exists, an error is returned.

func (*SortablePairList) Len

func (pairList *SortablePairList) Len() int

func (*SortablePairList) Less

func (pairList *SortablePairList) Less(i, j int) bool

func (*SortablePairList) Sort

func (pairList *SortablePairList) Sort()

Executes a sorting of the list of pairs according to the implementation of the Sorter interface.

func (*SortablePairList) Swap

func (pairList *SortablePairList) Swap(i, j int)

type Stack

type Stack struct {
	Elements []StackElement
}

func (*Stack) ElementAt

func (s *Stack) ElementAt(index int) StackElement

func (*Stack) HasMoreElements

func (s *Stack) HasMoreElements() bool

func (*Stack) Pop

func (s *Stack) Pop() (StackElement, error)

func (*Stack) Push

func (s *Stack) Push(elem StackElement)

type StackElement

type StackElement struct {
	Val interface{}
}

Jump to

Keyboard shortcuts

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