Exemplo n.º 1
0
// 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)
}
Exemplo n.º 2
0
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
}
Exemplo n.º 3
0
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
}