[FIX] ArrayedCollection>>isSorted

Henrik Gedenryd Henrik.Gedenryd at lucs.lu.se
Tue May 23 17:52:02 UTC 2000


Check for empty collection before sending #first.

Henrik



ArrayedCollection>>isSorted
    "Return true if the receiver is sorted by the given criterion.
    Optimization for isSorted: [:a :b | a <= b]."

    | lastElm elm |
    self isEmpty ifTrue: [^true].
    lastElm _ self first.
    2 to: self size do:
        [:index | 
        elm _ self at: index.
        lastElm <= elm ifFalse: [^ false].
        lastElm _ elm].
    ^ true






More information about the Squeak-dev mailing list