[Pharo-project] about OrderedCollection new replaceFrom: 1 to: 5 with: #(6 7 8 9 10) startingAt: 1
Hi guys in 1.2.1 OrderedCollection new replaceFrom: 1 to: 5 with: #(6 7 8 9 10) startingAt: 1 gave an OrderedCollection(6 7 8 9 10) while in 1.4 and 2.0 OrderedCollection new replaceFrom: 1 to: 5 with: #(6 7 8 9 10) startingAt: 1 raised an error 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.
I could overwrite XMLOrderedList replaceFrom: aStartingIndex to: anEndingIndex with: aCollection startingAt: aReplacementStart collection replaceFrom: aStartingIndex to: anEndingIndex with: aCollection startingAt: aReplacementStart to make it grow? But I do not really know the impact on the XML library
self makeRoomFor: (anEndingIndex- self capacity).
any idea? Stef On Mar 3, 2013, at 9:34 AM, Stéphane Ducasse <Stephane.Ducasse@inria.fr> wrote:
Hi guys
in 1.2.1
OrderedCollection new replaceFrom: 1 to: 5 with: #(6 7 8 9 10) startingAt: 1 gave an OrderedCollection(6 7 8 9 10)
while in 1.4 and 2.0 OrderedCollection new replaceFrom: 1 to: 5 with: #(6 7 8 9 10) startingAt: 1 raised an error
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.
On Mar 3, 2013, at 9:42 AM, stephane ducasse <stephane.ducasse@free.fr> wrote:
I could overwrite XMLOrderedList
replaceFrom: aStartingIndex to: anEndingIndex with: aCollection startingAt: aReplacementStart
collection replaceFrom: aStartingIndex to: anEndingIndex with: aCollection startingAt: aReplacementStart
to make it grow? But I do not really know the impact on the XML library
self makeRoomFor: (anEndingIndex- self capacity).
any idea?
In fact it will not work since makeRoomFor: and others have been removed and I do not have the time to dive in OrderedCollection growing logic.
Stef
On Mar 3, 2013, at 9:34 AM, Stéphane Ducasse <Stephane.Ducasse@inria.fr> wrote:
Hi guys
in 1.2.1
OrderedCollection new replaceFrom: 1 to: 5 with: #(6 7 8 9 10) startingAt: 1 gave an OrderedCollection(6 7 8 9 10)
while in 1.4 and 2.0 OrderedCollection new replaceFrom: 1 to: 5 with: #(6 7 8 9 10) startingAt: 1 raised an error
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.
These important changes were made intentionally, so we need to find the rationale of the change. Like is the new behavior covered by new tests ? On 03 Mar 2013, at 09:45, stephane ducasse <stephane.ducasse@free.fr> wrote:
On Mar 3, 2013, at 9:42 AM, stephane ducasse <stephane.ducasse@free.fr> wrote:
I could overwrite XMLOrderedList
replaceFrom: aStartingIndex to: anEndingIndex with: aCollection startingAt: aReplacementStart
collection replaceFrom: aStartingIndex to: anEndingIndex with: aCollection startingAt: aReplacementStart
to make it grow? But I do not really know the impact on the XML library
self makeRoomFor: (anEndingIndex- self capacity).
any idea?
In fact it will not work since makeRoomFor: and others have been removed and I do not have the time to dive in OrderedCollection growing logic.
Stef
On Mar 3, 2013, at 9:34 AM, Stéphane Ducasse <Stephane.Ducasse@inria.fr> wrote:
Hi guys
in 1.2.1
OrderedCollection new replaceFrom: 1 to: 5 with: #(6 7 8 9 10) startingAt: 1 gave an OrderedCollection(6 7 8 9 10)
while in 1.4 and 2.0 OrderedCollection new replaceFrom: 1 to: 5 with: #(6 7 8 9 10) startingAt: 1 raised an error
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.
Hi sven yes I imagine now we should improve in trakcing such changes. In addition I do not understand why XMLOrderedList new: 10 breaks the inspectorâ¦. This is why all the important libraries should be covered by a jenkins job and tests. So that right on the spot we can identify problems. Stef
These important changes were made intentionally, so we need to find the rationale of the change. Like is the new behavior covered by new tests ?
On 03 Mar 2013, at 09:45, stephane ducasse <stephane.ducasse@free.fr> wrote:
On Mar 3, 2013, at 9:42 AM, stephane ducasse <stephane.ducasse@free.fr> wrote:
I could overwrite XMLOrderedList
replaceFrom: aStartingIndex to: anEndingIndex with: aCollection startingAt: aReplacementStart
collection replaceFrom: aStartingIndex to: anEndingIndex with: aCollection startingAt: aReplacementStart
to make it grow? But I do not really know the impact on the XML library
self makeRoomFor: (anEndingIndex- self capacity).
any idea?
In fact it will not work since makeRoomFor: and others have been removed and I do not have the time to dive in OrderedCollection growing logic.
Stef
On Mar 3, 2013, at 9:34 AM, Stéphane Ducasse <Stephane.Ducasse@inria.fr> wrote:
Hi guys
in 1.2.1
OrderedCollection new replaceFrom: 1 to: 5 with: #(6 7 8 9 10) startingAt: 1 gave an OrderedCollection(6 7 8 9 10)
while in 1.4 and 2.0 OrderedCollection new replaceFrom: 1 to: 5 with: #(6 7 8 9 10) startingAt: 1 raised an error
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.
On 03 Mar 2013, at 10:20, stephane ducasse <stephane.ducasse@free.fr> wrote:
Hi sven
yes I imagine now we should improve in trakcing such changes. In addition I do not understand why
XMLOrderedList new: 10
breaks the inspectorâ¦.
Yes, I once saw that as well, very strange, I guess that is what happens when you start making your own collection classes...
This is why all the important libraries should be covered by a jenkins job and tests. So that right on the spot we can identify problems.
Stef
These important changes were made intentionally, so we need to find the rationale of the change. Like is the new behavior covered by new tests ?
On 03 Mar 2013, at 09:45, stephane ducasse <stephane.ducasse@free.fr> wrote:
On Mar 3, 2013, at 9:42 AM, stephane ducasse <stephane.ducasse@free.fr> wrote:
I could overwrite XMLOrderedList
replaceFrom: aStartingIndex to: anEndingIndex with: aCollection startingAt: aReplacementStart
collection replaceFrom: aStartingIndex to: anEndingIndex with: aCollection startingAt: aReplacementStart
to make it grow? But I do not really know the impact on the XML library
self makeRoomFor: (anEndingIndex- self capacity).
any idea?
In fact it will not work since makeRoomFor: and others have been removed and I do not have the time to dive in OrderedCollection growing logic.
Stef
On Mar 3, 2013, at 9:34 AM, Stéphane Ducasse <Stephane.Ducasse@inria.fr> wrote:
Hi guys
in 1.2.1
OrderedCollection new replaceFrom: 1 to: 5 with: #(6 7 8 9 10) startingAt: 1 gave an OrderedCollection(6 7 8 9 10)
while in 1.4 and 2.0 OrderedCollection new replaceFrom: 1 to: 5 with: #(6 7 8 9 10) startingAt: 1 raised an error
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.
On Mar 3, 2013, at 10:23 AM, Sven Van Caekenberghe <sven@stfx.eu> wrote:
On 03 Mar 2013, at 10:20, stephane ducasse <stephane.ducasse@free.fr> wrote:
Hi sven
yes I imagine now we should improve in trakcing such changes. In addition I do not understand why
XMLOrderedList new: 10
breaks the inspectorâ¦.
Yes, I once saw that as well, very strange, I guess that is what happens when you start making your own collection classesâ¦
Yes they said that the inspector class is OrderedCollectionInspector but it does not work so I changed it to get the system debuggable right now. Stef
This is why all the important libraries should be covered by a jenkins job and tests. So that right on the spot we can identify problems.
Stef
These important changes were made intentionally, so we need to find the rationale of the change. Like is the new behavior covered by new tests ?
On 03 Mar 2013, at 09:45, stephane ducasse <stephane.ducasse@free.fr> wrote:
On Mar 3, 2013, at 9:42 AM, stephane ducasse <stephane.ducasse@free.fr> wrote:
I could overwrite XMLOrderedList
replaceFrom: aStartingIndex to: anEndingIndex with: aCollection startingAt: aReplacementStart
collection replaceFrom: aStartingIndex to: anEndingIndex with: aCollection startingAt: aReplacementStart
to make it grow? But I do not really know the impact on the XML library
self makeRoomFor: (anEndingIndex- self capacity).
any idea?
In fact it will not work since makeRoomFor: and others have been removed and I do not have the time to dive in OrderedCollection growing logic.
Stef
On Mar 3, 2013, at 9:34 AM, Stéphane Ducasse <Stephane.Ducasse@inria.fr> wrote:
Hi guys
in 1.2.1
OrderedCollection new replaceFrom: 1 to: 5 with: #(6 7 8 9 10) startingAt: 1 gave an OrderedCollection(6 7 8 9 10)
while in 1.4 and 2.0 OrderedCollection new replaceFrom: 1 to: 5 with: #(6 7 8 9 10) startingAt: 1 raised an error
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.
stephane ducasse wrote:
On Mar 3, 2013, at 10:23 AM, Sven Van Caekenberghe <sven@stfx.eu> wrote:
On 03 Mar 2013, at 10:20, stephane ducasse <stephane.ducasse@free.fr> wrote:
Hi sven
yes I imagine now we should improve in trakcing such changes. In addition I do not understand why
XMLOrderedList new: 10
breaks the inspectorâ¦.
Yes, I once saw that as well, very strange, I guess that is what happens when you start making your own collection classesâ¦
Yes they said that the inspector class is OrderedCollectionInspector but it does not work so I changed it to get the system debuggable right now.
Not sure if this is related, but back when I was using Squeak and just new to the system I was debugging through OrdereredCollection and got an MNU. OrderedCollectionInspector was somehow related but I don't quite remember the details, except that some of it is documented here... http://forum.world.st/OrderedCollection-gt-gt-size-fails-in-debugger-td36578... -ben
Stef
This is why all the important libraries should be covered by a jenkins job and tests. So that right on the spot we can identify problems.
Stef
These important changes were made intentionally, so we need to find the rationale of the change. Like is the new behavior covered by new tests ?
On 03 Mar 2013, at 09:45, stephane ducasse <stephane.ducasse@free.fr> wrote:
On Mar 3, 2013, at 9:42 AM, stephane ducasse <stephane.ducasse@free.fr> wrote:
I could overwrite XMLOrderedList
replaceFrom: aStartingIndex to: anEndingIndex with: aCollection startingAt: aReplacementStart
collection replaceFrom: aStartingIndex to: anEndingIndex with: aCollection startingAt: aReplacementStart
to make it grow? But I do not really know the impact on the XML library
self makeRoomFor: (anEndingIndex- self capacity).
any idea?
In fact it will not work since makeRoomFor: and others have been removed and I do not have the time to dive in OrderedCollection growing logic.
Stef
On Mar 3, 2013, at 9:34 AM, Stéphane Ducasse <Stephane.Ducasse@inria.fr> wrote:
Hi guys
in 1.2.1
OrderedCollection new replaceFrom: 1 to: 5 with: #(6 7 8 9 10) startingAt: 1 gave an OrderedCollection(6 7 8 9 10)
while in 1.4 and 2.0 OrderedCollection new replaceFrom: 1 to: 5 with: #(6 7 8 9 10) startingAt: 1 raised an error
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.
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.
On Sun, 3 Mar 2013, stephane ducasse wrote:
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.
That OrderedCollection still has 0 size, so there's nothing to replace there. It was an accident that the code worked before. Consider using #ofSize: instead of #new: if you want the collection to have slots. Levente P.S.: If XMLOrderedList is a subclass of OrderedCollection, then it's just plain wrong IMHO. Creating subclasses of collections in external packages is bad practice.
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.
Hi levente Thankx for the mail.
That OrderedCollection still has 0 size, so there's nothing to replace there.
indeed this is what I saw.
It was an accident that the code worked before. Consider using #ofSize: instead of #new: if you want the collection to have slots.
Yes I fixed the test by providing a receiver with equal size so that all the elements can be swapped nicely and all the tests are green now.
Levente
P.S.: If XMLOrderedList is a subclass of OrderedCollection, then it's just plain wrong IMHO. Creating subclasses of collections in external packages is bad practice.
It is wrapping an orderedCollection :)
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.
participants (5)
-
Ben Coman -
Levente Uzonyi -
stephane ducasse -
Stéphane Ducasse -
Sven Van Caekenberghe