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.8 date: 2021/01/20 14:09:22
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.

copyright

COPYRIGHT (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.

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.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Mon, 18 Nov 2024 04:39:38 GMT