Documentation ¶
Index ¶
- type List
- func (s *List) Add(v ...interface{})
- func (s *List) AddFront(v interface{})
- func (s *List) CartesianProduct(sets ...*List) [][]interface{}
- func (s *List) Clear()
- func (s *List) Clone() *List
- func (s *List) CloneAndClear() *List
- func (s *List) Contains(v interface{}) bool
- func (s *List) Get(idx int) interface{}
- func (s *List) IndexOf(v interface{}) int
- func (s *List) IsEmpty() bool
- func (s *List) Len() int
- func (s *List) Merge(l *List) *List
- func (s *List) MergeSlice(arr []interface{}) *List
- func (s *List) MergeStringSlice(arr []string) *List
- func (s *List) Pop() (v interface{})
- func (s *List) Range(f func(index int, value interface{}) bool)
- func (s *List) RangeFast(f func(index int, value interface{}) bool)
- func (s *List) Remove(idx int)
- func (s *List) Set(idx int, v interface{})
- func (s *List) Shift() (v interface{})
- func (s *List) String() string
- func (s *List) Sub(start, end int) *List
- func (s *List) ToSlice() []interface{}
- func (s *List) ToStringSlice() []string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type List ¶
type List struct {
// contains filtered or unexported fields
}
List then list container
func (*List) AddFront ¶
func (s *List) AddFront(v interface{})
AddFront adds a value to first of list s.
func (*List) CartesianProduct ¶
CartesianProduct → {(x, y) | ∀ x ∈ s1, ∀ y ∈ s2} For example:
CartesianProduct(A, B), where A = {1, 2} and B = {7, 8} => {(1, 7), (1, 8), (2, 7), (2, 8)}
func (*List) CloneAndClear ¶
CloneAndClear duplicates the list s and clear s.
func (*List) IndexOf ¶
IndexOf indicates the first index of value in list s, if not found returns -1.
idx start with 0.
func (*List) MergeSlice ¶
MergeSlice merge a array slice to end of list s.
func (*List) MergeStringSlice ¶
MergeStringSlice merge a array slice to end of list s.
func (*List) Pop ¶
func (s *List) Pop() (v interface{})
Pop returns last value of list s, and remove it.
func (*List) Range ¶
Range ranges the value in list s, if function f return false, the range loop will break.
func (*List) RangeFast ¶
RangeFast ranges the value in list s, if function f return false, the range loop will break.
RangeFast do not create a snapshot for range, so you can not modify list s in range loop, indicate do not call Delete(), Add(), Merge() etc.
func (*List) Shift ¶
func (s *List) Shift() (v interface{})
Shift returns first value of list s, and remove it.
func (*List) Sub ¶
Sub returns the sub list between two ranges With x the start and y the end, we are sending [x,y) sublist.
func (*List) ToStringSlice ¶
ToStringSlice returns the list as an array.