예제 #1
0
파일: pvector.go 프로젝트: dmiller/go-seq
// Create a PVector from a slice (of interface{})
func NewPVectorFromSlice(items []interface{}) *PVector {
	// TODO: redo when we have transients
	var ret iseq.PVector = EmptyPVector
	for _, item := range items {
		ret = ret.ConsV(item)
	}
	return ret.(*PVector)
}
예제 #2
0
파일: pvector.go 프로젝트: dmiller/go-seq
// 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
0
func TestPVectorAssocNBig(t *testing.T) {
	v, _ := makeRangePVector(100000)
	var nv iseq.PVector = v
	for i := 0; i < 110000; i++ {
		nv = nv.AssocN(i, i+20)
	}

	if nv.Count() != 110000 {
		t.Error("PVector.AssocN: lots of appends at end of big vector: wrong number of items")
	}
	for i := 0; i < nv.Count(); i++ {
		if nv.Nth(i) != i+20 {
			t.Errorf("PVector.AssocN: lots of appends at end of big vector: bad value at %v", i)
		}
	}
}