> while in 1.4 and 2.0 > OrderedCollection new replaceFrom: 1 to: 5 with: #(6 7 8 9 10) > startingAt: 1 > raised an error
The problem I have is in fact that (OrderedCollection new: 10) replaceFrom: 1 to: 5 with: #(6 7 8 9 10) startingAt: 1 So even if the collection has enough space only a collection with enough elements can get them replaced. So I fixed the tests of the XMLOrderedList to work but I'm a bit unsatisfied. Stef > Do you have an idea how I can handle that? Because XMLObservableList and > XMLOrderedList implements > replaceFrom: to: with: startingAt: > > because there is no self makeRoomFor: (stop - self capacity) invocation. > > > in 1.4>> > replaceFrom: start to: stop with: replacement startingAt: repStart > "This destructively replaces elements from start to stop in the > receiver > starting at index, repStart, in the sequenceable collection, > replacementCollection. Answer the receiver. No range checks are > performed." > > | index repOff | > repOff := repStart - start. > index := start - 1. > [(index := index + 1) <= stop] > whileTrue: [self at: index put: (replacement at: repOff + > index)] > > at: anInteger put: anObject > "Put anObject at element index anInteger. at:put: cannot be used to > append, front or back, to an ordered collection; it is used by a > knowledgeable client to replace an element." > self ensureBoundsFrom: anInteger to: anInteger. > ^array at: anInteger + firstIndex - 1 put: anObject > > > in 1.2.1 > > replaceFrom: start to: stop with: replacement startingAt: repStart > "An ordered collection is growable, so a call to this can make the > collection grow." > self makeRoomFor: (stop - self capacity). > array > replaceFrom: start + firstIndex - 1 > to: stop + firstIndex - 1 > with: replacement > startingAt: repStart. > lastIndex := lastIndex max: stop + firstIndex - 1.