models

package
v1.0.0-...-8081051 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2014 License: BSD-3-Clause, MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Thing1

type Thing1 struct {
	Name   string
	Number int
}

+gen projections:"int,Thing2,string"

type Thing1s

type Thing1s []Thing1

Thing1s is a slice of type Thing1, for use with gen methods below. Use this type where you would use []Thing1. (This is required because slices cannot be method receivers.)

func (Thing1s) AggregateInt

func (rcv Thing1s) AggregateInt(fn func(int, Thing1) int) (result int)

AggregateInt iterates over Thing1s, operating on each element while maintaining ‘state’. See: http://clipperhouse.github.io/gen/#Aggregate

func (Thing1s) AggregateString

func (rcv Thing1s) AggregateString(fn func(string, Thing1) string) (result string)

AggregateString iterates over Thing1s, operating on each element while maintaining ‘state’. See: http://clipperhouse.github.io/gen/#Aggregate

func (Thing1s) AggregateThing2

func (rcv Thing1s) AggregateThing2(fn func(Thing2, Thing1) Thing2) (result Thing2)

AggregateThing2 iterates over Thing1s, operating on each element while maintaining ‘state’. See: http://clipperhouse.github.io/gen/#Aggregate

func (Thing1s) All

func (rcv Thing1s) All(fn func(Thing1) bool) bool

All verifies that all elements of Thing1s return true for the passed func. See: http://clipperhouse.github.io/gen/#All

func (Thing1s) Any

func (rcv Thing1s) Any(fn func(Thing1) bool) bool

Any verifies that one or more elements of Thing1s return true for the passed func. See: http://clipperhouse.github.io/gen/#Any

func (Thing1s) AverageInt

func (rcv Thing1s) AverageInt(fn func(Thing1) int) (result int, err error)

AverageInt sums int over all elements and divides by len(Thing1s). See: http://clipperhouse.github.io/gen/#Average

func (Thing1s) AverageThing2

func (rcv Thing1s) AverageThing2(fn func(Thing1) Thing2) (result Thing2, err error)

AverageThing2 sums Thing2 over all elements and divides by len(Thing1s). See: http://clipperhouse.github.io/gen/#Average

func (Thing1s) Count

func (rcv Thing1s) Count(fn func(Thing1) bool) (result int)

Count gives the number elements of Thing1s that return true for the passed func. See: http://clipperhouse.github.io/gen/#Count

func (Thing1s) Distinct

func (rcv Thing1s) Distinct() (result Thing1s)

Distinct returns a new Thing1s slice whose elements are unique. See: http://clipperhouse.github.io/gen/#Distinct

func (Thing1s) DistinctBy

func (rcv Thing1s) DistinctBy(equal func(Thing1, Thing1) bool) (result Thing1s)

DistinctBy returns a new Thing1s slice whose elements are unique, where equality is defined by a passed func. See: http://clipperhouse.github.io/gen/#DistinctBy

func (Thing1s) Each

func (rcv Thing1s) Each(fn func(Thing1))

Each iterates over Thing1s and executes the passed func against each element. See: http://clipperhouse.github.io/gen/#Each

func (Thing1s) First

func (rcv Thing1s) First(fn func(Thing1) bool) (result Thing1, err error)

First returns the first element that returns true for the passed func. Returns error if no elements return true. See: http://clipperhouse.github.io/gen/#First

func (Thing1s) GroupByInt

func (rcv Thing1s) GroupByInt(fn func(Thing1) int) map[int]Thing1s

GroupByInt groups elements into a map keyed by int. See: http://clipperhouse.github.io/gen/#GroupBy

func (Thing1s) GroupByString

func (rcv Thing1s) GroupByString(fn func(Thing1) string) map[string]Thing1s

GroupByString groups elements into a map keyed by string. See: http://clipperhouse.github.io/gen/#GroupBy

func (Thing1s) GroupByThing2

func (rcv Thing1s) GroupByThing2(fn func(Thing1) Thing2) map[Thing2]Thing1s

GroupByThing2 groups elements into a map keyed by Thing2. See: http://clipperhouse.github.io/gen/#GroupBy

func (Thing1s) IsSortedBy

func (rcv Thing1s) IsSortedBy(less func(Thing1, Thing1) bool) bool

IsSortedBy reports whether an instance of Thing1s is sorted, using the pass func to define ‘less’. See: http://clipperhouse.github.io/gen/#SortBy

func (Thing1s) IsSortedByDesc

func (rcv Thing1s) IsSortedByDesc(less func(Thing1, Thing1) bool) bool

IsSortedDesc reports whether an instance of Thing1s is sorted in descending order, using the pass func to define ‘less’. See: http://clipperhouse.github.io/gen/#SortBy

func (Thing1s) MaxBy

func (rcv Thing1s) MaxBy(less func(Thing1, Thing1) bool) (result Thing1, err error)

MaxBy returns an element of Thing1s containing the maximum value, when compared to other elements using a passed func defining ‘less’. In the case of multiple items being equally maximal, the last such element is returned. Returns error if no elements. See: http://clipperhouse.github.io/gen/#MaxBy

func (Thing1s) MaxInt

func (rcv Thing1s) MaxInt(fn func(Thing1) int) (result int, err error)

MaxInt selects the largest value of int in Thing1s. Returns error on Thing1s with no elements. See: http://clipperhouse.github.io/gen/#MaxCustom

func (Thing1s) MaxString

func (rcv Thing1s) MaxString(fn func(Thing1) string) (result string, err error)

MaxString selects the largest value of string in Thing1s. Returns error on Thing1s with no elements. See: http://clipperhouse.github.io/gen/#MaxCustom

func (Thing1s) MaxThing2

func (rcv Thing1s) MaxThing2(fn func(Thing1) Thing2) (result Thing2, err error)

MaxThing2 selects the largest value of Thing2 in Thing1s. Returns error on Thing1s with no elements. See: http://clipperhouse.github.io/gen/#MaxCustom

func (Thing1s) MinBy

func (rcv Thing1s) MinBy(less func(Thing1, Thing1) bool) (result Thing1, err error)

MinBy returns an element of Thing1s containing the minimum value, when compared to other elements using a passed func defining ‘less’. In the case of multiple items being equally minimal, the first such element is returned. Returns error if no elements. See: http://clipperhouse.github.io/gen/#MinBy

func (Thing1s) MinInt

func (rcv Thing1s) MinInt(fn func(Thing1) int) (result int, err error)

MinInt selects the least value of int in Thing1s. Returns error on Thing1s with no elements. See: http://clipperhouse.github.io/gen/#MinCustom

func (Thing1s) MinString

func (rcv Thing1s) MinString(fn func(Thing1) string) (result string, err error)

MinString selects the least value of string in Thing1s. Returns error on Thing1s with no elements. See: http://clipperhouse.github.io/gen/#MinCustom

func (Thing1s) MinThing2

func (rcv Thing1s) MinThing2(fn func(Thing1) Thing2) (result Thing2, err error)

MinThing2 selects the least value of Thing2 in Thing1s. Returns error on Thing1s with no elements. See: http://clipperhouse.github.io/gen/#MinCustom

func (Thing1s) SelectInt

func (rcv Thing1s) SelectInt(fn func(Thing1) int) (result []int)

SelectInt returns a slice of int in Thing1s, projected by passed func. See: http://clipperhouse.github.io/gen/#Select

func (Thing1s) SelectString

func (rcv Thing1s) SelectString(fn func(Thing1) string) (result []string)

SelectString returns a slice of string in Thing1s, projected by passed func. See: http://clipperhouse.github.io/gen/#Select

func (Thing1s) SelectThing2

func (rcv Thing1s) SelectThing2(fn func(Thing1) Thing2) (result []Thing2)

SelectThing2 returns a slice of Thing2 in Thing1s, projected by passed func. See: http://clipperhouse.github.io/gen/#Select

func (Thing1s) Single

func (rcv Thing1s) Single(fn func(Thing1) bool) (result Thing1, err error)

Single returns exactly one element of Thing1s that returns true for the passed func. Returns error if no or multiple elements return true. See: http://clipperhouse.github.io/gen/#Single

func (Thing1s) SortBy

func (rcv Thing1s) SortBy(less func(Thing1, Thing1) bool) Thing1s

SortBy returns a new ordered Thing1s slice, determined by a func defining ‘less’. See: http://clipperhouse.github.io/gen/#SortBy

func (Thing1s) SortByDesc

func (rcv Thing1s) SortByDesc(less func(Thing1, Thing1) bool) Thing1s

SortByDesc returns a new, descending-ordered Thing1s slice, determined by a func defining ‘less’. See: http://clipperhouse.github.io/gen/#SortBy

func (Thing1s) SumInt

func (rcv Thing1s) SumInt(fn func(Thing1) int) (result int)

SumInt sums int over elements in Thing1s. See: http://clipperhouse.github.io/gen/#Sum

func (Thing1s) SumThing2

func (rcv Thing1s) SumThing2(fn func(Thing1) Thing2) (result Thing2)

SumThing2 sums Thing2 over elements in Thing1s. See: http://clipperhouse.github.io/gen/#Sum

func (Thing1s) Where

func (rcv Thing1s) Where(fn func(Thing1) bool) (result Thing1s)

Where returns a new Thing1s slice whose elements return true for func. See: http://clipperhouse.github.io/gen/#Where

type Thing2

type Thing2 Thing3

+gen methods:"Max,Min,Sort,IsSorted,SortDesc,IsSortedDesc" containers:"List,Ring,Set"

type Thing2Element

type Thing2Element struct {

	// The value stored with this element.
	Value Thing2
	// contains filtered or unexported fields
}

Thing2Element is an element of a linked list.

func (*Thing2Element) Next

func (e *Thing2Element) Next() *Thing2Element

Next returns the next list element or nil.

func (*Thing2Element) Prev

func (e *Thing2Element) Prev() *Thing2Element

Prev returns the previous list element or nil.

type Thing2List

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

Thing2List represents a doubly linked list. The zero value for Thing2List is an empty list ready to use.

func NewThing2List

func NewThing2List() *Thing2List

New returns an initialized list.

func (*Thing2List) Back

func (l *Thing2List) Back() *Thing2Element

Back returns the last element of list l or nil.

func (*Thing2List) Front

func (l *Thing2List) Front() *Thing2Element

Front returns the first element of list l or nil

func (*Thing2List) Init

func (l *Thing2List) Init() *Thing2List

Init initializes or clears list l.

func (*Thing2List) InsertAfter

func (l *Thing2List) InsertAfter(v Thing2, mark *Thing2Element) *Thing2Element

InsertAfter inserts a new element e with value v immediately after mark and returns e. If mark is not an element of l, the list is not modified.

func (*Thing2List) InsertBefore

func (l *Thing2List) InsertBefore(v Thing2, mark *Thing2Element) *Thing2Element

InsertBefore inserts a new element e with value v immediately before mark and returns e. If mark is not an element of l, the list is not modified.

func (*Thing2List) Len

func (l *Thing2List) Len() int

Len returns the number of elements of list l. The complexity is O(1).

func (*Thing2List) MoveAfter

func (l *Thing2List) MoveAfter(e, mark *Thing2Element)

MoveAfter moves element e to its new position after mark. If e is not an element of l, or e == mark, the list is not modified.

func (*Thing2List) MoveBefore

func (l *Thing2List) MoveBefore(e, mark *Thing2Element)

MoveBefore moves element e to its new position before mark. If e is not an element of l, or e == mark, the list is not modified.

func (*Thing2List) MoveToBack

func (l *Thing2List) MoveToBack(e *Thing2Element)

MoveToBack moves element e to the back of list l. If e is not an element of l, the list is not modified.

func (*Thing2List) MoveToFront

func (l *Thing2List) MoveToFront(e *Thing2Element)

MoveToFront moves element e to the front of list l. If e is not an element of l, the list is not modified.

func (*Thing2List) PushBack

func (l *Thing2List) PushBack(v Thing2) *Thing2Element

PushBack inserts a new element e with value v at the back of list l and returns e.

func (*Thing2List) PushBackList

func (l *Thing2List) PushBackList(other *Thing2List)

PushBackList inserts a copy of an other list at the back of list l. The lists l and other may be the same.

func (*Thing2List) PushFront

func (l *Thing2List) PushFront(v Thing2) *Thing2Element

PushFront inserts a new element e with value v at the front of list l and returns e.

func (*Thing2List) PushFrontList

func (l *Thing2List) PushFrontList(other *Thing2List)

PushFrontList inserts a copy of an other list at the front of list l. The lists l and other may be the same.

func (*Thing2List) Remove

func (l *Thing2List) Remove(e *Thing2Element) Thing2

Remove removes e from l if e is an element of list l. It returns the element value e.Value.

type Thing2Ring

type Thing2Ring struct {
	Value Thing2 // for use by client; untouched by this library
	// contains filtered or unexported fields
}

A Ring is an element of a circular list, or ring. Rings do not have a beginning or end; a pointer to any ring element serves as reference to the entire ring. Empty rings are represented as nil Ring pointers. The zero value for a Ring is a one-element ring with a nil Value.

func NewThing2Ring

func NewThing2Ring(n int) *Thing2Ring

New creates a ring of n elements.

func (*Thing2Ring) Do

func (r *Thing2Ring) Do(f func(Thing2))

Do calls function f on each element of the ring, in forward order. The behavior of Do is undefined if f changes *r.

func (*Thing2Ring) Len

func (r *Thing2Ring) Len() int

Len computes the number of elements in ring r. It executes in time proportional to the number of elements.

func (r *Thing2Ring) Link(s *Thing2Ring) *Thing2Ring

Link connects ring r with ring s such that r.Next() becomes s and returns the original value for r.Next(). r must not be empty.

If r and s point to the same ring, linking them removes the elements between r and s from the ring. The removed elements form a subring and the result is a reference to that subring (if no elements were removed, the result is still the original value for r.Next(), and not nil).

If r and s point to different rings, linking them creates a single ring with the elements of s inserted after r. The result points to the element following the last element of s after insertion.

func (*Thing2Ring) Move

func (r *Thing2Ring) Move(n int) *Thing2Ring

Move moves n % r.Len() elements backward (n < 0) or forward (n >= 0) in the ring and returns that ring element. r must not be empty.

func (*Thing2Ring) Next

func (r *Thing2Ring) Next() *Thing2Ring

Next returns the next ring element. r must not be empty.

func (*Thing2Ring) Prev

func (r *Thing2Ring) Prev() *Thing2Ring

Prev returns the previous ring element. r must not be empty.

func (r *Thing2Ring) Unlink(n int) *Thing2Ring

Unlink removes n % r.Len() elements from the ring r, starting at r.Next(). If n % r.Len() == 0, r remains unchanged. The result is the removed subring. r must not be empty.

type Thing2Set

type Thing2Set map[Thing2]struct{}

The primary type that represents a set

func NewThing2Set

func NewThing2Set() Thing2Set

Creates and returns a reference to an empty set.

func NewThing2SetFromSlice

func NewThing2SetFromSlice(s []Thing2) Thing2Set

Creates and returns a reference to a set from an existing slice

func (Thing2Set) Add

func (set Thing2Set) Add(i Thing2) bool

Adds an item to the current set if it doesn't already exist in the set.

func (Thing2Set) Cardinality

func (set Thing2Set) Cardinality() int

Cardinality returns how many items are currently in the set.

func (*Thing2Set) Clear

func (set *Thing2Set) Clear()

Clears the entire set to be the empty set.

func (Thing2Set) Clone

func (set Thing2Set) Clone() Thing2Set

Returns a clone of the set. Does NOT clone the underlying elements.

func (Thing2Set) Contains

func (set Thing2Set) Contains(i Thing2) bool

Determines if a given item is already in the set.

func (Thing2Set) ContainsAll

func (set Thing2Set) ContainsAll(i ...Thing2) bool

Determines if the given items are all in the set

func (Thing2Set) Difference

func (set Thing2Set) Difference(other Thing2Set) Thing2Set

Returns a new set with items in the current set but not in the other set

func (Thing2Set) Equal

func (set Thing2Set) Equal(other Thing2Set) bool

Equal determines if two sets are equal to each other. If they both are the same size and have the same items they are considered equal. Order of items is not relevent for sets to be equal.

func (Thing2Set) Intersect

func (set Thing2Set) Intersect(other Thing2Set) Thing2Set

Returns a new set with items that exist only in both sets.

func (Thing2Set) IsSubset

func (set Thing2Set) IsSubset(other Thing2Set) bool

Determines if every item in the other set is in this set.

func (Thing2Set) IsSuperset

func (set Thing2Set) IsSuperset(other Thing2Set) bool

Determines if every item of this set is in the other set.

func (Thing2Set) Iter

func (set Thing2Set) Iter() <-chan Thing2

Iter() returns a channel of type Thing2 that you can range over.

func (Thing2Set) Remove

func (set Thing2Set) Remove(i Thing2)

Allows the removal of a single item in the set.

func (Thing2Set) SymmetricDifference

func (set Thing2Set) SymmetricDifference(other Thing2Set) Thing2Set

Returns a new set with items in the current set or the other set but not in both.

func (Thing2Set) Union

func (set Thing2Set) Union(other Thing2Set) Thing2Set

Returns a new set with all items in both sets.

type Thing2s

type Thing2s []Thing2

Thing2s is a slice of type Thing2, for use with gen methods below. Use this type where you would use []Thing2. (This is required because slices cannot be method receivers.)

func (Thing2s) IsSorted

func (rcv Thing2s) IsSorted() bool

IsSorted reports whether Thing2s is sorted. See: http://clipperhouse.github.io/gen/#Sort

func (Thing2s) IsSortedDesc

func (rcv Thing2s) IsSortedDesc() bool

IsSortedDesc reports whether Thing2s is reverse-sorted. See: http://clipperhouse.github.io/gen/#Sort

func (Thing2s) Len

func (rcv Thing2s) Len() int

func (Thing2s) Less

func (rcv Thing2s) Less(i, j int) bool

func (Thing2s) Max

func (rcv Thing2s) Max() (result Thing2, err error)

Max returns the maximum value of Thing2s. In the case of multiple items being equally maximal, the first such element is returned. Returns error if no elements. See: http://clipperhouse.github.io/gen/#Max

func (Thing2s) Min

func (rcv Thing2s) Min() (result Thing2, err error)

Min returns the minimum value of Thing2s. In the case of multiple items being equally minimal, the first such element is returned. Returns error if no elements. See: http://clipperhouse.github.io/gen/#Min

func (Thing2s) Sort

func (rcv Thing2s) Sort() Thing2s

Sort returns a new ordered Thing2s slice. See: http://clipperhouse.github.io/gen/#Sort

func (Thing2s) SortDesc

func (rcv Thing2s) SortDesc() Thing2s

SortDesc returns a new reverse-ordered Thing2s slice. See: http://clipperhouse.github.io/gen/#Sort

func (Thing2s) Swap

func (rcv Thing2s) Swap(i, j int)

type Thing3

type Thing3 float64

Jump to

Keyboard shortcuts

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