[Cuis] #storeOn: for Trie
Dan Norton
dnorton at mindspring.com
Tue Jun 16 16:25:05 CDT 2015
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: $)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Trie-storeOn.zip
Type: application/zip
Size: 475 bytes
Desc: not available
URL: <http://jvuletich.org/pipermail/cuis_jvuletich.org/attachments/20150616/c80060bf/attachment-0003.zip>
More information about the Cuis
mailing list