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