Documentation ¶
Index ¶
- type Thing1
- type Thing1s
- func (rcv Thing1s) AggregateInt(fn func(int, Thing1) int) (result int)
- func (rcv Thing1s) AggregateString(fn func(string, Thing1) string) (result string)
- func (rcv Thing1s) AggregateThing2(fn func(Thing2, Thing1) Thing2) (result Thing2)
- func (rcv Thing1s) All(fn func(Thing1) bool) bool
- func (rcv Thing1s) Any(fn func(Thing1) bool) bool
- func (rcv Thing1s) AverageInt(fn func(Thing1) int) (result int, err error)
- func (rcv Thing1s) AverageThing2(fn func(Thing1) Thing2) (result Thing2, err error)
- func (rcv Thing1s) Count(fn func(Thing1) bool) (result int)
- func (rcv Thing1s) Distinct() (result Thing1s)
- func (rcv Thing1s) DistinctBy(equal func(Thing1, Thing1) bool) (result Thing1s)
- func (rcv Thing1s) Each(fn func(Thing1))
- func (rcv Thing1s) First(fn func(Thing1) bool) (result Thing1, err error)
- func (rcv Thing1s) GroupByInt(fn func(Thing1) int) map[int]Thing1s
- func (rcv Thing1s) GroupByString(fn func(Thing1) string) map[string]Thing1s
- func (rcv Thing1s) GroupByThing2(fn func(Thing1) Thing2) map[Thing2]Thing1s
- func (rcv Thing1s) IsSortedBy(less func(Thing1, Thing1) bool) bool
- func (rcv Thing1s) IsSortedByDesc(less func(Thing1, Thing1) bool) bool
- func (rcv Thing1s) MaxBy(less func(Thing1, Thing1) bool) (result Thing1, err error)
- func (rcv Thing1s) MaxInt(fn func(Thing1) int) (result int, err error)
- func (rcv Thing1s) MaxString(fn func(Thing1) string) (result string, err error)
- func (rcv Thing1s) MaxThing2(fn func(Thing1) Thing2) (result Thing2, err error)
- func (rcv Thing1s) MinBy(less func(Thing1, Thing1) bool) (result Thing1, err error)
- func (rcv Thing1s) MinInt(fn func(Thing1) int) (result int, err error)
- func (rcv Thing1s) MinString(fn func(Thing1) string) (result string, err error)
- func (rcv Thing1s) MinThing2(fn func(Thing1) Thing2) (result Thing2, err error)
- func (rcv Thing1s) SelectInt(fn func(Thing1) int) (result []int)
- func (rcv Thing1s) SelectString(fn func(Thing1) string) (result []string)
- func (rcv Thing1s) SelectThing2(fn func(Thing1) Thing2) (result []Thing2)
- func (rcv Thing1s) Single(fn func(Thing1) bool) (result Thing1, err error)
- func (rcv Thing1s) SortBy(less func(Thing1, Thing1) bool) Thing1s
- func (rcv Thing1s) SortByDesc(less func(Thing1, Thing1) bool) Thing1s
- func (rcv Thing1s) SumInt(fn func(Thing1) int) (result int)
- func (rcv Thing1s) SumThing2(fn func(Thing1) Thing2) (result Thing2)
- func (rcv Thing1s) Where(fn func(Thing1) bool) (result Thing1s)
- type Thing2
- type Thing2Element
- type Thing2List
- func (l *Thing2List) Back() *Thing2Element
- func (l *Thing2List) Front() *Thing2Element
- func (l *Thing2List) Init() *Thing2List
- func (l *Thing2List) InsertAfter(v Thing2, mark *Thing2Element) *Thing2Element
- func (l *Thing2List) InsertBefore(v Thing2, mark *Thing2Element) *Thing2Element
- func (l *Thing2List) Len() int
- func (l *Thing2List) MoveAfter(e, mark *Thing2Element)
- func (l *Thing2List) MoveBefore(e, mark *Thing2Element)
- func (l *Thing2List) MoveToBack(e *Thing2Element)
- func (l *Thing2List) MoveToFront(e *Thing2Element)
- func (l *Thing2List) PushBack(v Thing2) *Thing2Element
- func (l *Thing2List) PushBackList(other *Thing2List)
- func (l *Thing2List) PushFront(v Thing2) *Thing2Element
- func (l *Thing2List) PushFrontList(other *Thing2List)
- func (l *Thing2List) Remove(e *Thing2Element) Thing2
- type Thing2Ring
- type Thing2Set
- func (set Thing2Set) Add(i Thing2) bool
- func (set Thing2Set) Cardinality() int
- func (set *Thing2Set) Clear()
- func (set Thing2Set) Clone() Thing2Set
- func (set Thing2Set) Contains(i Thing2) bool
- func (set Thing2Set) ContainsAll(i ...Thing2) bool
- func (set Thing2Set) Difference(other Thing2Set) Thing2Set
- func (set Thing2Set) Equal(other Thing2Set) bool
- func (set Thing2Set) Intersect(other Thing2Set) Thing2Set
- func (set Thing2Set) IsSubset(other Thing2Set) bool
- func (set Thing2Set) IsSuperset(other Thing2Set) bool
- func (set Thing2Set) Iter() <-chan Thing2
- func (set Thing2Set) Remove(i Thing2)
- func (set Thing2Set) SymmetricDifference(other Thing2Set) Thing2Set
- func (set Thing2Set) Union(other Thing2Set) Thing2Set
- type Thing2s
- func (rcv Thing2s) IsSorted() bool
- func (rcv Thing2s) IsSortedDesc() bool
- func (rcv Thing2s) Len() int
- func (rcv Thing2s) Less(i, j int) bool
- func (rcv Thing2s) Max() (result Thing2, err error)
- func (rcv Thing2s) Min() (result Thing2, err error)
- func (rcv Thing2s) Sort() Thing2s
- func (rcv Thing2s) SortDesc() Thing2s
- func (rcv Thing2s) Swap(i, j int)
- type Thing3
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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 ¶
AggregateInt iterates over Thing1s, operating on each element while maintaining ‘state’. See: http://clipperhouse.github.io/gen/#Aggregate
func (Thing1s) AggregateString ¶
AggregateString iterates over Thing1s, operating on each element while maintaining ‘state’. See: http://clipperhouse.github.io/gen/#Aggregate
func (Thing1s) AggregateThing2 ¶
AggregateThing2 iterates over Thing1s, operating on each element while maintaining ‘state’. See: http://clipperhouse.github.io/gen/#Aggregate
func (Thing1s) All ¶
All verifies that all elements of Thing1s return true for the passed func. See: http://clipperhouse.github.io/gen/#All
func (Thing1s) Any ¶
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 ¶
AverageInt sums int over all elements and divides by len(Thing1s). See: http://clipperhouse.github.io/gen/#Average
func (Thing1s) AverageThing2 ¶
AverageThing2 sums Thing2 over all elements and divides by len(Thing1s). See: http://clipperhouse.github.io/gen/#Average
func (Thing1s) Count ¶
Count gives the number elements of Thing1s that return true for the passed func. See: http://clipperhouse.github.io/gen/#Count
func (Thing1s) Distinct ¶
Distinct returns a new Thing1s slice whose elements are unique. See: http://clipperhouse.github.io/gen/#Distinct
func (Thing1s) DistinctBy ¶
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 ¶
Each iterates over Thing1s and executes the passed func against each element. See: http://clipperhouse.github.io/gen/#Each
func (Thing1s) First ¶
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 ¶
GroupByInt groups elements into a map keyed by int. See: http://clipperhouse.github.io/gen/#GroupBy
func (Thing1s) GroupByString ¶
GroupByString groups elements into a map keyed by string. See: http://clipperhouse.github.io/gen/#GroupBy
func (Thing1s) GroupByThing2 ¶
GroupByThing2 groups elements into a map keyed by Thing2. See: http://clipperhouse.github.io/gen/#GroupBy
func (Thing1s) IsSortedBy ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
SelectInt returns a slice of int in Thing1s, projected by passed func. See: http://clipperhouse.github.io/gen/#Select
func (Thing1s) SelectString ¶
SelectString returns a slice of string in Thing1s, projected by passed func. See: http://clipperhouse.github.io/gen/#Select
func (Thing1s) SelectThing2 ¶
SelectThing2 returns a slice of Thing2 in Thing1s, projected by passed func. See: http://clipperhouse.github.io/gen/#Select
func (Thing1s) Single ¶
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 ¶
SortBy returns a new ordered Thing1s slice, determined by a func defining ‘less’. See: http://clipperhouse.github.io/gen/#SortBy
func (Thing1s) SortByDesc ¶
SortByDesc returns a new, descending-ordered Thing1s slice, determined by a func defining ‘less’. See: http://clipperhouse.github.io/gen/#SortBy
func (Thing1s) SumInt ¶
SumInt sums int over elements in Thing1s. See: http://clipperhouse.github.io/gen/#Sum
func (Thing1s) SumThing2 ¶
SumThing2 sums Thing2 over elements in Thing1s. See: http://clipperhouse.github.io/gen/#Sum
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 (*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 (*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 (*Thing2Ring) Link ¶
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 (*Thing2Ring) Unlink ¶
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 NewThing2SetFromSlice ¶
Creates and returns a reference to a set from an existing slice
func (Thing2Set) Cardinality ¶
Cardinality returns how many items are currently in the set.
func (Thing2Set) ContainsAll ¶
Determines if the given items are all in the set
func (Thing2Set) Difference ¶
Returns a new set with items in the current set but not in the other set
func (Thing2Set) Equal ¶
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) IsSuperset ¶
Determines if every item of this set is in the other set.
func (Thing2Set) SymmetricDifference ¶
Returns a new set with items in the current set or the other set but not in both.
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 ¶
IsSorted reports whether Thing2s is sorted. See: http://clipperhouse.github.io/gen/#Sort
func (Thing2s) IsSortedDesc ¶
IsSortedDesc reports whether Thing2s is reverse-sorted. See: http://clipperhouse.github.io/gen/#Sort
func (Thing2s) Max ¶
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 ¶
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 ¶
Sort returns a new ordered Thing2s slice. See: http://clipperhouse.github.io/gen/#Sort
func (Thing2s) SortDesc ¶
SortDesc returns a new reverse-ordered Thing2s slice. See: http://clipperhouse.github.io/gen/#Sort