diff -r 970dbba3ad26 -r 4e649183cf0a Trie.st --- a/Trie.st Wed Jul 31 17:09:00 2019 +0200 +++ b/Trie.st Wed Jul 31 23:16:28 2019 +0200 @@ -1,3 +1,5 @@ +"{ Encoding: utf8 }" + "{ Package: 'stx:libbasic2' }" "{ NameSpace: Smalltalk }" @@ -9,13 +11,6 @@ category:'Collections-Ordered' ! -Dictionary subclass:#RegularDictionary - instanceVariableNames:'' - classVariableNames:'' - poolDictionaries:'' - privateIn:Trie -! - Object subclass:#SmallDictionaryWith1Element instanceVariableNames:'k1 v1' classVariableNames:'' @@ -65,7 +60,7 @@ t at:'12345' put:'hallo'. t at:'54923' put:'Welt'. t at:'1256' put:'bla'. - t at:'12' put:'zwölf'. + t at:'12' put:'zwölf'. t at:'123' put:'einszweidrei'. t at:'1234' put:'einszweidreivier'. @@ -296,15 +291,6 @@ "Created: / 04-08-2012 / 10:48:45 / cg" ! ! -!Trie::RegularDictionary methodsFor:'accessing'! - -newAt:key put:value - self at:key put:value. - ^ self - - "Created: / 04-08-2012 / 11:12:39 / cg" -! ! - !Trie::SmallDictionaryWith1Element methodsFor:'accessing'! at:key @@ -360,6 +346,14 @@ "Created: / 04-08-2012 / 11:19:10 / cg" ! ! +!Trie::SmallDictionaryWith1Element methodsFor:'visiting'! + +acceptVisitor:aVisitor with:aParameter + "dispatch for visitor pattern; send #visitDictionary:with: to aVisitor" + + ^ aVisitor visitDictionary:self with:aParameter +! ! + !Trie::SmallDictionaryWith2Elements methodsFor:'accessing'! at:key @@ -423,6 +417,14 @@ "Created: / 04-08-2012 / 11:19:23 / cg" ! ! +!Trie::SmallDictionaryWith2Elements methodsFor:'visiting'! + +acceptVisitor:aVisitor with:aParameter + "dispatch for visitor pattern; send #visitDictionary:with: to aVisitor" + + ^ aVisitor visitDictionary:self with:aParameter +! ! + !Trie::SmallDictionaryWith3Elements methodsFor:'accessing'! at:key @@ -470,7 +472,7 @@ key = k1 ifTrue:[ v1 := value. ^ self ]. key = k2 ifTrue:[ v2 := value. ^ self ]. key = k3 ifTrue:[ v3 := value. ^ self ]. - ^ Trie::RegularDictionary new + ^ Dictionary new at:k1 put:v1; at:k2 put:v2; at:k3 put:v3; @@ -498,6 +500,14 @@ "Created: / 04-08-2012 / 11:19:36 / cg" ! ! +!Trie::SmallDictionaryWith3Elements methodsFor:'visiting'! + +acceptVisitor:aVisitor with:aParameter + "dispatch for visitor pattern; send #visitDictionary:with: to aVisitor" + + ^ aVisitor visitDictionary:self with:aParameter +! ! + !Trie class methodsFor:'documentation'! version