diff --git a/Collections-Homogeneous/Array.extension.st b/Collections-Homogeneous/Array.extension.st new file mode 100644 index 000000000..7a51bfc8c --- /dev/null +++ b/Collections-Homogeneous/Array.extension.st @@ -0,0 +1,15 @@ +Extension { #name : #Array } + +{ #category : #'*Collections-Homogeneous' } +Array class >> of: elementSpecies [ + | mc c | + mc := HomogeneousArray class copy. + c := mc new + superclass: HomogeneousArray superclass + methodDictionary: HomogeneousArray methodDictionary + format: HomogeneousArray format; + setName: 'Array of: ', elementSpecies name; + instVarNamed: #elementSpecies put: elementSpecies; + yourself. + ^c +] diff --git a/Collections-Homogeneous/Class.extension.st b/Collections-Homogeneous/Class.extension.st new file mode 100644 index 000000000..770f8939b --- /dev/null +++ b/Collections-Homogeneous/Class.extension.st @@ -0,0 +1,6 @@ +Extension { #name : #Class } + +{ #category : #'*Collections-Homogeneous' } +Class >> array [ + ^Array of: self +] diff --git a/Collections-Homogeneous/Collection.extension.st b/Collections-Homogeneous/Collection.extension.st new file mode 100644 index 000000000..a456c9652 --- /dev/null +++ b/Collections-Homogeneous/Collection.extension.st @@ -0,0 +1,6 @@ +Extension { #name : #Collection } + +{ #category : #'*Collections-Homogeneous' } +Collection >> isHomogeneous [ + ^false +] diff --git a/Collections-Homogeneous/HomogeneousArray.class.st b/Collections-Homogeneous/HomogeneousArray.class.st new file mode 100644 index 000000000..564e8cd83 --- /dev/null +++ b/Collections-Homogeneous/HomogeneousArray.class.st @@ -0,0 +1,26 @@ +Class { + #name : #HomogeneousArray, + #superclass : #Array, + #type : #variable, + #classInstVars : [ + 'elementSpecies' + ], + #category : #'Collections-Homogeneous' +} + +{ #category : #accessing } +HomogeneousArray class >> elementSpecies [ + ^elementSpecies +] + +{ #category : #JSON } +HomogeneousArray class >> neoJsonMapping: mapper [ + mapper for: self customDo: [ :mapping | + mapping listOfElementSchema: elementSpecies + ] +] + +{ #category : #testing } +HomogeneousArray >> isHomogeneous [ + ^true +] diff --git a/Collections-Homogeneous/package.st b/Collections-Homogeneous/package.st new file mode 100644 index 000000000..97d68aa19 --- /dev/null +++ b/Collections-Homogeneous/package.st @@ -0,0 +1 @@ +Package { #name : #'Collections-Homogeneous' }