本文整理汇总了Golang中github.com/dmiller/go-seq/iseq.Seq类的典型用法代码示例。如果您正苦于以下问题:Golang Seq类的具体用法?Golang Seq怎么用?Golang Seq使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Seq类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: moreFromSeq
func moreFromSeq(s iseq.Seq) iseq.Seq {
sn := s.Next()
if sn == nil {
return CachedEmptyList
}
return sn
}
示例2: NewPVectorFromISeq
// Create a PVector from an ISeq
func NewPVectorFromISeq(items iseq.Seq) *PVector {
// TODO: redo when we have transients
var ret iseq.PVector = EmptyPVector
for ; items != nil; items = items.Next() {
ret = ret.ConsV(items.First())
}
return ret.(*PVector)
}
示例3: SeqCount
// SeqCount computes the length of an iseq.Seq
// Only call this on known non-empty iseq.Seq
func SeqCount(s0 iseq.Seq) int {
i := 1 // if we are here, it is non-empty
for s := s0.Next(); s != nil; s, i = s.Next(), i+1 {
if cnt, ok := s.(iseq.Counted); ok {
return i + cnt.Count1()
}
}
return i
}
示例4: HashUnordered
// HashUnordered computes a hash for an iseq.Seq, independent of order of elements
func HashUnordered(s iseq.Seq) uint32 {
n := int32(0)
hash := uint32(0)
for ; s != nil; s = s.Next() {
hash += Hash(s.First)
n++
}
return murmur3.FinalizeCollHash(hash, n)
}
示例5: NewPTreeMapFromSeqC
func NewPTreeMapFromSeqC(items iseq.Seq, comp iseq.CompareFn) *PTreeMap {
ret := CreateEmptyPTreeMap(comp)
for i := 0; items != nil; items, i = items.Next().Next(), i+1 {
if items.Next() == nil {
panic(fmt.Sprintf("No value supplied for key: %v", items.First()))
}
ret = ret.AssocM(items.First(), items.Next().First()).(*PTreeMap)
}
return ret
}
示例6: NewPHashMapFromSeq
func NewPHashMapFromSeq(items iseq.Seq) *PHashMap {
// TODO: transients
ret := EmptyPHashMap
for i := 0; items != nil; items, i = items.Next().Next(), i+1 {
if items.Next() == nil {
panic(fmt.Sprintf("No value supplied for key: %v", items.First()))
}
ret = ret.AssocM(items.First(), items.Next().First()).(*PHashMap)
// if checkDup && ret.Count1() != i+1 {
// panic(fmt.Sprintf("Duplicate key: %v",items.First()))
// }
}
return ret
}