Collection and Stream (was: RE: [BUG] ReadStream>>isEmpty ?)
Andreas Raab
andreas.raab at gmx.de
Fri Aug 8 23:22:57 UTC 2003
> > > (ReadStream on: #(1 2 3 4 5) from: 3 to: 3) size
>
> On last thing and I'll let this go for now (which I already
> said I would do and then didn't) what does an answer of 3 in
> this example mean?
There is no good equivalent in the current collection hierarchy to model
this as the above is actually an optimized version of, e.g.,
subset := #(1 2 3 4 5) copyFrom: 1 to: 3.
rs := ReadStream on: subset.
rs position: 3.
The best we can probably get to is by introducing a #truncate: operation
which truncates the actual number of elements of some stream/collection. So
the above is really equivalent to:
rs := ReadStream on: #(1 2 3 4 5).
rs truncate: 3.
rs position: 3.
with the following assertions:
self assert: (rs size = 3).
self assert: (rs isEmpty not).
self assert: (rs atEnd).
self assert: (rs next == nil).
Cheers,
- Andreas
More information about the Squeak-dev
mailing list
|