当前位置: 首页>>代码示例>>Golang>>正文


Golang iseq.Seq类代码示例

本文整理汇总了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
}
开发者ID:dmiller,项目名称:go-seq,代码行数:7,代码来源:helpers.go

示例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)
}
开发者ID:dmiller,项目名称:go-seq,代码行数:9,代码来源:pvector.go

示例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
}
开发者ID:dmiller,项目名称:go-seq,代码行数:11,代码来源:count.go

示例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)
}
开发者ID:dmiller,项目名称:go-seq,代码行数:11,代码来源:hash.go

示例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
}
开发者ID:dmiller,项目名称:go-seq,代码行数:12,代码来源:ptreemap.go

示例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
}
开发者ID:dmiller,项目名称:go-seq,代码行数:15,代码来源:phashmap.go


注:本文中的github.com/dmiller/go-seq/iseq.Seq类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。