#storeOn: for Trie

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

#storeOn: for Trie

Dan Norton
Greetings All,

Trie is a subclass of Collection and currently inherits its #storeOn: method, which does not
produce a correct store string for a Trie.

Attached is a better one, similar to the one in Dictionary, but please verify it. It reads as
follows:

storeOn: aStream
        "Refer to the comment in Object|storeOn:."
        | noneYet |
        aStream nextPutAll: '(('.
        aStream nextPutAll: self class name.
        aStream nextPutAll: ' new)'.
        noneYet := true.
        self keysAndValuesDo:
                        [:each :val |
                        noneYet
                                ifTrue: [noneYet := false]
                                ifFalse: [aStream nextPut: $;].
                        aStream
                                nextPutAll: ' at: ';
                                store: each;
                                nextPutAll: ' put: ';
                                store: val].
        noneYet ifFalse: [aStream nextPutAll: '; yourself'].
        aStream nextPut: $)

_______________________________________________
Cuis mailing list
[hidden email]
http://jvuletich.org/mailman/listinfo/cuis_jvuletich.org

Trie-storeOn.zip (654 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: #storeOn: for Trie

Juan Vuletich-4
Thanks, Dan. This is integrated in the latest push I did to GitHub last weekend.

Cheers,
Juan Vuletich

On 6/16/2015 6:25 PM, Dan Norton wrote:
Greetings All,

Trie is a subclass of Collection and currently inherits its #storeOn: method, which does not 
produce a correct store string for a Trie.

Attached is a better one, similar to the one in Dictionary, but please verify it. It reads as 
follows:

storeOn: aStream
	"Refer to the comment in Object|storeOn:."
	| noneYet |
	aStream nextPutAll: '(('.
	aStream nextPutAll: self class name.
	aStream nextPutAll: ' new)'.
	noneYet := true.
	self keysAndValuesDo: 
			[:each :val | 
			noneYet
				ifTrue: [noneYet := false]
				ifFalse: [aStream nextPut: $;].
			aStream 
				nextPutAll: ' at: ';
				store: each;
				nextPutAll: ' put: ';
				store: val].
	noneYet ifFalse: [aStream nextPutAll: '; yourself'].
	aStream nextPut: $) 
_______________________________________________ Cuis mailing list [hidden email] http://jvuletich.org/mailman/listinfo/cuis_jvuletich.org


_______________________________________________
Cuis mailing list
[hidden email]
http://jvuletich.org/mailman/listinfo/cuis_jvuletich.org