[ENH]Shared streams (v 0.9)

Dan Ingalls Dan at SqueakLand.org
Fri Apr 12 05:23:51 UTC 2002


"David T. Lewis" <lewis at mail.msen.com>  wrote...

>By the way, I remember being very surprised when I went looking for
>a FIFO class, and the only thing I could find in the image was a
>SharedQueue. Somehow I had expected that this was one of the fundamental
>things that would just be there.

It is.

>Maybe lots of folks write little hacks
>like InternalPipe.

This is what OrderedCollection addFirst: and removeLast are made for.

The following code snippet...
	| oc | oc := OrderedCollection new.
	1 to: 9999 do:
		[:i | oc addFirst: i.
		i > 10 ifTrue: [oc removeLast]].
...leaves oc being
an OrderedCollection(9999 9998 9997 9996 9995 9994 9993 9992 9991 9990)

It's not superfast, but it's not bad either.

	- Dan



More information about the Squeak-dev mailing list