Skip to content

Commit

Permalink
Conceive Homogeneous Collections
Browse files Browse the repository at this point in the history
  • Loading branch information
shingarov committed Oct 15, 2023
1 parent 93fcd70 commit f949377
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 0 deletions.
15 changes: 15 additions & 0 deletions Collections-Homogeneous/Array.extension.st
Original file line number Diff line number Diff line change
@@ -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
]
6 changes: 6 additions & 0 deletions Collections-Homogeneous/Class.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Extension { #name : #Class }

{ #category : #'*Collections-Homogeneous' }
Class >> array [
^Array of: self
]
6 changes: 6 additions & 0 deletions Collections-Homogeneous/Collection.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Extension { #name : #Collection }

{ #category : #'*Collections-Homogeneous' }
Collection >> isHomogeneous [
^false
]
26 changes: 26 additions & 0 deletions Collections-Homogeneous/HomogeneousArray.class.st
Original file line number Diff line number Diff line change
@@ -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
]
1 change: 1 addition & 0 deletions Collections-Homogeneous/package.st
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Package { #name : #'Collections-Homogeneous' }

0 comments on commit f949377

Please sign in to comment.