Squeak Class Documentation category index | class index  
 
SortedCollection
  category: Collections-Sequenceable
  superclass: OrderedCollection
  subclasses: CRLookupResult

I represent a collection of objects ordered by some property of the objects themselves. The ordering is specified in a BlockContext.

instance methods
  accessing
  at:put:
median
sortBlock
sortBlock:

  adding
  add:
addAll:
addFirst:
copyEmpty

  comparing
  =

  copying
  copy

  enumerating
  collect:

  private
  defaultSort:to:
indexForInserting:
insert:before:
reSort
sort:to:

class methods
  instance creation
  new:
sortBlock:

instance methods
  accessing top  
 

at:put:

Put anObject at element index anInteger. at:put: cannot be used to
append, front or back, to an ordered collection; it is used by a
knowledgeable client to replace an element.


 

median

Return the middle element, or as close as we can get.


 

sortBlock

Answer the blockContext which is the criterion for sorting elements of
the receiver.


 

sortBlock:

Make the argument, aBlock, be the criterion for ordering elements of the
receiver.


  adding top  
 

add:

Include newObject as one of the receiver's elements. Answer newObject.
ArrayedCollections cannot respond to this message.


 

addAll:

Add each element of aCollection at my end. Answer aCollection.


 

addFirst:

Add newObject to the beginning of the receiver. Answer newObject.


 

copyEmpty

Answer a copy of the receiver without any of the receiver's elements.


  comparing top  
 

=

Answer true if my and aSortedCollection's species are the same,
and if our blocks are the same, and if our elements are the same.


  copying top  
 

copy

Answer another instance just like the receiver. Subclasses typically
override this method; they typically do not override shallowCopy.


  enumerating top  
 

collect:

Evaluate aBlock with each of my elements as the argument. Collect the
resulting values into an OrderedCollection. Answer the new collection.
Override the superclass in order to produce an OrderedCollection instead
of a SortedCollection.


  private top  
 

defaultSort:to:

Sort elements i through j of self to be nondescending according to
sortBlock.


 

indexForInserting:


 

insert:before:


 

reSort


 

sort:to:

Sort elements i through j of self to be nondescending according to
sortBlock.


class methods
  instance creation top  
 

new:

The default sorting function is a <= comparison on elements.


 

sortBlock:

Answer an instance of me such that its elements are sorted according to
the criterion specified in aBlock.