Skip to content

Commit

Permalink
Move collection extensions to extensions package
Browse files Browse the repository at this point in the history
  • Loading branch information
gcotelli committed Aug 7, 2023
1 parent efcc662 commit a53f24e
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 30 deletions.
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
Extension { #name : #Collection }

{ #category : #'*Buoy-Collections' }
{ #category : #'*Buoy-Collections-Extensions' }
Collection >> asOrderedSet [

^ self as: OrderedSet
]

{ #category : #'*Buoy-Collections' }
{ #category : #'*Buoy-Collections-Extensions' }
Collection >> maxUsing: aBlock [

^ self maxUsing: aBlock ifEmpty: [ self errorEmptyCollection ]
]

{ #category : #'*Buoy-Collections' }
{ #category : #'*Buoy-Collections-Extensions' }
Collection >> maxUsing: aBlock ifEmpty: ifEmptyBlock [

^ self ifEmpty: ifEmptyBlock ifNotEmpty: [ self inject: ( aBlock value: self anyOne ) into: [ :max :each | max max: ( aBlock value: each ) ] ]
]

{ #category : #'*Buoy-Collections' }
{ #category : #'*Buoy-Collections-Extensions' }
Collection >> minUsing: aBlock [

^ self minUsing: aBlock ifEmpty: [ self errorEmptyCollection ]
]

{ #category : #'*Buoy-Collections' }
{ #category : #'*Buoy-Collections-Extensions' }
Collection >> minUsing: aBlock ifEmpty: ifEmptyBlock [

^ self ifEmpty: ifEmptyBlock ifNotEmpty: [ self inject: ( aBlock value: self anyOne ) into: [ :max :each | max min: ( aBlock value: each ) ] ]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
Extension { #name : #SequenceableCollection }

{ #category : #'*Buoy-Collections-Extensions' }
SequenceableCollection >> copyFirst: n [

^ [ self copyFrom: 1 to: n ] unless: n = 0 inWhichCase: [ self species new ]
]

{ #category : #'*Buoy-Collections-Extensions' }
SequenceableCollection >> copyLast: n [

^ [ self copyFrom: self size - n + 1 to: self size ] unless: n = 0 inWhichCase: [ self species new ]
]

{ #category : #'*Buoy-Collections-Extensions' }
SequenceableCollection >> copyNoMoreThanFirst: n [

^ self copyFirst: ( self size min: n )
]

{ #category : #'*Buoy-Collections-Extensions' }
SequenceableCollection >> copyNoMoreThanLast: n [

^ self copyLast: ( n min: self size )
]

{ #category : #'*Buoy-Collections-Extensions' }
SequenceableCollection >> equalityChecker [

Expand Down
25 changes: 0 additions & 25 deletions source/Buoy-Collections/SequenceableCollection.extension.st

This file was deleted.

0 comments on commit a53f24e

Please sign in to comment.