|
Class: SequenceableCollectionSorter
Object
|
+--SequenceableCollectionSorter
- Package:
- stx:libbasic2
- Category:
- Collections-Support
- Version:
- rev:
1.8
date: 2021/01/20 14:09:22
- user: cg
- file: SequenceableCollectionSorter.st directory: libbasic2
- module: stx stc-classLibrary: libbasic2
a SequenceableCollectionSorter allows for anything which responds to
keyed at/atPut messages to be sorted just like a SequenceableCollection.
Since the access messages can be customized, even non collections
(or collection simulators, models etc.) can be sorted with these sorters.
(use #atSelector: / #putSelector: and #sizeSelector: for customization).
As with collection sorting, the sortBlock can be specified and defaults to
a block which compares using #< messages.
copyrightCOPYRIGHT (c) 1996 by Claus Gittinger
All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
inclusion of the above copyright notice. This software may not
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
initialization
-
initialize
-
SequenceableCollectionSorter initialize
instance creation
-
on: aCollection
-
-
on: aCollection using: aTwoArgBlock
-
-
sort: aCollection
-
-
sort: aCollection using: aTwoArgBlock
-
accessing
-
atSelector: aSymbol
-
set the selector to access elements.
If nil (the default), elements are accessed via #at:
-
collection
-
return the collections being sorted.
-
collection: aCollection
-
set the collections being sorted.
-
putSelector: aSymbol
-
set the selector to access elements.
If nil (the default), elements are accessed via #at:put:
-
sizeSelector: aSymbol
-
set the selector to get the collections size.
If nil (the default), elements are accessed via #size
-
sortBlock
-
return the sortBlock which is used to compare two elements.
The default sortBlock compares elements by sending the #< message.
-
sortBlock: aTwoArgBlock
-
set the sortBlock which is used to compare two elements.
The default sortBlock compares elements by sending the #< message.
sorting
-
defaultSort: inBegin to: inEnd
-
actual sort worker for sorting when the sortBlock is nil (or the default)
and default atSelector/putSelectors are to be used.
This will execute slightly faster, since no #perform-indirection is needed.
-
nonDefaultSort3: inBegin to: inEnd with: p
-
actual sort worker for sorting when a non default sortBlock
with 3 args (stringSort) is used.
-
nonDefaultSort: inBegin to: inEnd
-
actual sort worker for sorting when a non default sortBlock
or nonNil access selectors are used.
-
sort
-
-
sort: from to: to
-
actual sort worker for sort-messages
|a sorter|
a := #(10 5 2 17 5 99 -5).
sorter := SequenceableCollectionSorter on:a.
sorter sort.
Transcript showCR:a printString
|