Does MagmaCollection preserve order, so that standard collection methods will always go through objects in the order of original insertion?
While doing some tests for that I ran into "Instances of MagmaCollection are not indexable" while using at: at: index "Primitive. Assumes receiver is indexable. Answer the value of an indexable element in the receiver. Fail if the argument index is not an Integer or is out of bounds. Essential. See Object documentation whatIsAPrimitive."
<primitive: 60> index isInteger ifTrue: [self class isVariable ifTrue: [self errorSubscriptBounds: index] ifFalse: [self errorNotIndexable]]. index isNumber ifTrue: [^self at: index asInteger] ifFalse: [self errorNonIntegerIndex]
The test was |c| c := MagmaCollection new. c add: 1; add: 2; add: 3. c do: [:x | Transcript show: x]. Transcript cr. c remove: 2. c do: [:x | Transcript show: x]. Transcript cr. c add: 4. c do: [:x | Transcript show: x]. Transcript cr. Transcript show: (c at: 2); cr.
and the error was in the last line. BTW, 4 did appear after 3 in the printout, not in the hole created from removing 2. So it looks as if insertion order is preserved. I did NOT have a magma session open when I ran the test.
I was expecting at: to work since http://wiki.squeak.org/squeak/2639 says that MagmaCollection "Provides size and absolute position access (at: anInteger) making it suitable for scrolling lists".
Finally, is it advisable to use the standard collection methods if the MagmaCollection is large, or is it better to use a reader? By "better" I am mostly thinking of whether the entire collection is forced into memory or not. Since the standard collection methods return a "self species", which is a Bag, I'm guessing it's better to use a reader.
Thanks. Ross Boylan