eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'SequenceableCollectionSorter':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: SequenceableCollectionSorter


Inheritance:

   Object
   |
   +--SequenceableCollectionSorter

Package:
stx:libbasic2
Category:
Collections-Support
Version:
rev: 1.6 date: 2017/01/26 10:55:16
user: cg
file: SequenceableCollectionSorter.st directory: libbasic2
module: stx stc-classLibrary: libbasic2

Description:


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.


Class protocol:

initialization
o  initialize
SequenceableCollectionSorter initialize

instance creation
o  on: aCollection

o  on: aCollection using: aTwoArgBlock

o  sort: aCollection

o  sort: aCollection using: aTwoArgBlock


Instance protocol:

accessing
o  atSelector: aSymbol
set the selector to access elements.
If nil (the default), elements are accessed via #at:

o  collection
return the collections being sorted.

o  collection: aCollection
set the collections being sorted.

o  putSelector: aSymbol
set the selector to access elements.
If nil (the default), elements are accessed via #at:put:

o  sizeSelector: aSymbol
set the selector to get the collections size.
If nil (the default), elements are accessed via #size

o  sortBlock
return the sortBlock which is used to compare two elements.
The default sortBlock compares elements by sending the #< message.

o  sortBlock: aTwoArgBlock
set the sortBlock which is used to compare two elements.
The default sortBlock compares elements by sending the #< message.

sorting
o  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.

o  nonDefaultSort3: inBegin to: inEnd with: p
actual sort worker for sorting when a non default sortBlock
with 3 args (stringSort) is used.

o  nonDefaultSort: inBegin to: inEnd
actual sort worker for sorting when a non default sortBlock
or nonNil access selectors are used.

o  sort

o  sort: from to: to
actual sort worker for sort-messages


Examples:


|a sorter| a := #(10 5 2 17 5 99 -5). sorter := SequenceableCollectionSorter on:a. sorter sort. Transcript showCR:a printString

ST/X 7.2.0.0; WebServer 1.670 at bd0aa1f87cdd.unknown:8081; Thu, 11 Aug 2022 11:41:37 GMT