gil

package module
v0.0.0-...-51d7257 Latest Latest
Warning

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

Go to latest
Published: May 7, 2014 License: MPL-2.0 Imports: 2 Imported by: 0

README

gil

Build Status Coverage Status

Go Interface Library

A humble attempt to add some common data structures and algorithms to Go in a generic fashion without resorting to methods like code generators.

So far there are only a few packages.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArgumentError

type ArgumentError string

ArgumentError is returned when an invalid argument or number of arguments is passed to a function, often variadic.

func (ArgumentError) Error

func (e ArgumentError) Error() string

type Int

type Int int

Int is an int implementing Interface

func (Int) Less

func (i Int) Less(iface Interface) bool

Less returns true if i Int is smaller than iface Interface

type Interface

type Interface interface {
	Less(iface Interface) bool
}

Interface is the interface used for storing data generically within gil

type NotFoundError

type NotFoundError struct {
	Interface
}

NotFoundError is returned when a search value is not found within a set

func (NotFoundError) Error

func (NotFoundError) Error() string

type Queue

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

Queue is a generic FIFO implementation

func (*Queue) Len

func (q *Queue) Len() int

Len returns the number of items in the queue

func (*Queue) Peek

func (q *Queue) Peek() Interface

Peek at the next item in the queue without removing it

func (*Queue) Pop

func (q *Queue) Pop() Interface

Pop an item off the front of the queue

func (*Queue) Push

func (q *Queue) Push(item Interface) QueueInterface

Push an item onto the end queue

type QueueInterface

type QueueInterface interface {
	Len() int
	Push(item Interface) QueueInterface
	Pop() Interface
	Peek() Interface
}

QueueInterface is a generic queue interface implemented by some types in gil

type Slice

type Slice []Interface

Slice is a slice type that contains only objects that implement Interface. It should be homogenous, e.g. every object should be the same type, just as a regular slice would be typed.

func CopyToIntSlice

func CopyToIntSlice(data []int) Slice

CopyToIntSlice takes a slice of ints and returns a slice of Interfaces.

func CopyToStringSlice

func CopyToStringSlice(data []string) Slice

CopyToStringSlice takes a slice of ints and returns a slice of Interfaces.

func (Slice) Find

func (s Slice) Find(val Interface) int

Find uses a binary search algorithm (sort.Search) to find val in a Slice

func (Slice) Len

func (s Slice) Len() int

required for sort.Interface

func (Slice) Less

func (s Slice) Less(i, j int) bool

required for sort.Interface

func (Slice) Sort

func (s Slice) Sort()

Sort the slice

func (Slice) Swap

func (s Slice) Swap(i, j int)

required for sort.Interface

type Stack

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

Stack is a generic LIFO implementation

func (*Stack) Len

func (s *Stack) Len() int

Len returns the number of items in the stack

func (*Stack) Peek

func (s *Stack) Peek() Interface

Peek at the item at the front of the stack without removing it

func (*Stack) Pop

func (s *Stack) Pop() Interface

Pop an item off the front of the linked list

func (*Stack) Push

func (s *Stack) Push(item Interface) QueueInterface

Push an item at the front of the linked list

type String

type String string

String is an string implementing Interface

func (String) Less

func (i String) Less(iface Interface) bool

Less returns true if i String is smaller than iface Interface

type TypeAssertionError

type TypeAssertionError struct{}

TypeAssertionError is returned when an internal type assertion failed. It indicates a library problem and should be reported. It should not be seen under normal circumstances

func (TypeAssertionError) Error

func (e TypeAssertionError) Error() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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