代码拉取完成,页面将自动刷新
package linq
// Append inserts an item to the end of a collection,
// so it becomes the last item.
func (q Query) Append(item interface{}) Query {
return Query{
Iterate: func() Iterator {
next := q.Iterate()
appended := false
return func() (interface{}, bool) {
i, ok := next()
if ok {
return i, ok
}
if !appended {
appended = true
return item, true
}
return nil, false
}
},
}
}
// Concat concatenates two collections.
//
// The Concat method differs from the Union method because the Concat method
// returns all the original elements in the input sequences.
// The Union method returns only unique elements.
func (q Query) Concat(q2 Query) Query {
return Query{
Iterate: func() Iterator {
next := q.Iterate()
next2 := q2.Iterate()
use1 := true
return func() (item interface{}, ok bool) {
if use1 {
item, ok = next()
if ok {
return
}
use1 = false
}
return next2()
}
},
}
}
// Prepend inserts an item to the beginning of a collection,
// so it becomes the first item.
func (q Query) Prepend(item interface{}) Query {
return Query{
Iterate: func() Iterator {
next := q.Iterate()
prepended := false
return func() (interface{}, bool) {
if prepended {
return next()
}
prepended = true
return item, true
}
},
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。