[squeak-dev] The Inbox: Collections-mt.932.mcz

Marcel Taeumel marcel.taeumel at hpi.de
Fri Mar 26 18:08:44 UTC 2021


Hi all!

What do you think? Does it makes sense to pursue this idea of "dictionaries with collections as values" and enrich it with tests and documentation?

Best,
Marcel
Am 26.03.2021 19:05:09 schrieb commits at source.squeak.org <commits at source.squeak.org>:
A new version of Collections was added to project The Inbox:
http://source.squeak.org/inbox/Collections-mt.932.mcz

==================== Summary ====================

Name: Collections-mt.932
Author: mt
Time: 26 March 2021, 7:04:57.368373 pm
UUID: b6c0c2c9-0a4f-684c-87a7-069813edd154
Ancestors: Collections-dtl.931

Sketch of a dictionary that has collections as values.

dict := CollectionsDictionary new.
(dict at: #fruits) addAll: #(apple apple peach).
(dict at: #sweets) add: #nougat.
dict removeKey: #sweets.
dict explore.

=============== Diff against Collections-dtl.931 ===============

Item was added:
+ Dictionary subclass: #CollectionsDictionary
+ instanceVariableNames: 'collectionClass'
+ classVariableNames: ''
+ poolDictionaries: ''
+ category: 'Collections-Unordered'!

Item was added:
+ ----- Method: CollectionsDictionary class>>defaultCollectionClass (in category 'defaults') -----
+ defaultCollectionClass
+
+ ^ OrderedCollection!

Item was added:
+ ----- Method: CollectionsDictionary class>>newOnBags (in category 'instance creation') -----
+ newOnBags
+
+ ^ self new
+ setCollectionClass: Bag;
+ yourself!

Item was added:
+ ----- Method: CollectionsDictionary class>>newOnOrderedCollections (in category 'instance creation') -----
+ newOnOrderedCollections
+
+ ^ self new
+ setCollectionClass: OrderedCollection;
+ yourself!

Item was added:
+ ----- Method: CollectionsDictionary class>>newOnSets (in category 'instance creation') -----
+ newOnSets
+
+ ^ self new
+ setCollectionClass: Set;
+ yourself!

Item was added:
+ ----- Method: CollectionsDictionary>>at: (in category 'accessing') -----
+ at: key
+
+ ^ self at: key ifAbsent: [super at: key put: collectionClass new]!

Item was added:
+ ----- Method: CollectionsDictionary>>at:put: (in category 'accessing') -----
+ at: key put: value
+
+ self shouldNotImplement.!

Item was added:
+ ----- Method: CollectionsDictionary>>collectionClass (in category 'accessing') -----
+ collectionClass
+
+ ^ collectionClass!

Item was added:
+ ----- Method: CollectionsDictionary>>initialize: (in category 'initialization') -----
+ initialize: n
+
+ super initialize: n.
+ self setCollectionClass: self class defaultCollectionClass.!

Item was added:
+ ----- Method: CollectionsDictionary>>setCollectionClass: (in category 'initialization') -----
+ setCollectionClass: aClass
+
+ collectionClass := aClass.!


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20210326/9e774953/attachment.html>


More information about the Squeak-dev mailing list