Squeak Class Documentation category index | class index  
 
ShortRunArray
  category: Balloon-Collections
  superclass: ArrayedCollection
  subclasses:

This class is run-length encoded representation of short integer (e.g., 16bit signed integer values)

instance methods
  accessing
  at:
at:put:
compressionRatio
lengthAtRun:
runSize
size
species
valueAtRun:

  enumerating
  do:
lengthsAndValuesDo:
runsAndValuesDo:
valuesCollect:
valuesDo:

  objects from disk
  restoreEndianness

  printing
  printOn:

  private
  pvtAt:
pvtAt:put:
setRunAt:toLength:value:
setRuns:values:
swapRuns

class methods
  class initialization
  initialize
startUp
startUpFrom:
swapRuns

  instance creation
  new:
newFrom:
runs:values:

instance methods
  accessing top  
 

at:

Return the short value at the given index


 

at:put:

ShortRunArrays are read-only


 

compressionRatio

Return the compression ratio.
The compression ratio is computed based
on how much space would be needed to
store the receiver in a ShortIntegerArray


 

lengthAtRun:

Return the length of the run starting at the given index


 

runSize

Return the number of runs in the receiver


 

size

Return the number of elements stored in the receiver


 

species

Answer the preferred class for reconstructing the receiver.


 

valueAtRun:

Return the value of the run starting at the given index


  enumerating top  
 

do:

Evaluate aBlock with all elements of the receiver


 

lengthsAndValuesDo:

Evaluate aBlock with the length and value of each run in the receiver


 

runsAndValuesDo:

Evaluate aBlock with the length and value of each run in the receiver


 

valuesCollect:

Evaluate aBlock with each of the receiver's values as the argument.
Collect the resulting values into a collection like the receiver. Answer
the new collection.


 

valuesDo:


  objects from disk top  
 

restoreEndianness

This word object was just read in from a stream. It was stored in Big Endian (Mac) format. Swap each pair of bytes (16-bit word), if the current machine is Little Endian.
Why is this the right thing to do? We are using memory as a byteStream. High and low bytes are reversed in each 16-bit word, but the stream of words ascends through memory. Different from a Bitmap.


  printing top  
 

printOn:

Append a sequence of characters that identify the receiver to aStream.


  private top  
 

pvtAt:

Private -- for swapping only


 

pvtAt:put:

Private -- for swapping only


 

setRunAt:toLength:value:


 

setRuns:values:


 

swapRuns

Private -- swap length/value pairs in the receiver


class methods
  class initialization top  
 

initialize

ShortRunArray initialize


 

startUp

Check if the word order has changed from the last save


 

startUpFrom:

In this case, do we need to swap word halves when reading this segement?


 

swapRuns


  instance creation top  
 

new:

ShortRunArrays must be created with either
someCollection as: ShortRunArray
or by using
ShortRunArray runs: runCollection values: valueCollection.


 

newFrom:

Compress aCollection into a ShortRunArray


 

runs:values: