Category: Collections-Sequenceable
Superclass: OrderedCollection
My instances are OrderedCollections that automatically apply Run Length Encoding compression to the things they store. Be careful when using me: I can provide great space savings, but my instances don't grant linear access time. RunArray's behavior currently is similar to that of OrderedCollection (you can add elements to RunArrays); maybe it should behave like an ArrayedCollection.

Method category index

instance creation (class)
accessing (instance)
adding (instance)
basic (instance)
copying (instance)
enumerating (instance)
removing (instance)
searching (instance)
testing (instance)

instance creation (class)

new
Answer an empty RunArray

new: aSize

Answer a RunArray with space for aSize runs

top


accessing (instance)

at: anIndex
Answer the element at index anIndex

at: anIndex put: anObject

Replace the element at index anIndex with anObject and answer anObject

top


adding (instance)

add: anObject afterIndex: anIndex
Add anObject after the element at index anIndex

addAll: aCollection afterIndex: anIndex

Add all the elements of aCollection after the one at index anIndex. If aCollection is unordered, its elements could be added in an order which is not the #do: order

addAllFirst: aCollection

Add all the elements of aCollection at the beginning of the receiver. If aCollection is unordered, its elements could be added in an order which is not the #do: order

addAllLast: aCollection

Add all the elements of aCollection at the end of the receiver. If aCollection is unordered, its elements could be added in an order which is not the #do: order

addFirst: anObject

Add anObject at the beginning of the receiver. Watch out: this operation can cause serious performance pitfalls

addLast: anObject

Add anObject at the end of the receiver

top


basic (instance)

first
Answer the first element in the receiver

last

Answer the last element of the receiver

size

Answer the number of elements in the receiver

top


copying (instance)

deepCopy
Answer a copy of the receiver containing copies of the receiver's elements (#copy is used to obtain them)

shallowCopy

Answer a copy of the receiver. The elements are not copied

top


enumerating (instance)

do: aBlock
Enumerate all the objects in the receiver, passing each one to aBlock

objectsAndRunLengthsDo: aBlock

Enumerate all the runs in the receiver, passing to aBlock two parameters for every run: the first is the repeated object, the second is the number of copies

top


removing (instance)

removeAtIndex: anIndex
Remove the object at index anIndex from the receiver and answer the removed object

removeFirst

Remove the first object from the receiver and answer the removed object

removeLast

Remove the last object from the receiver and answer the removed object

top


searching (instance)

indexOf: anObject startingAt: anIndex ifAbsent: aBlock
Answer the index of the first copy of anObject in the receiver, starting the search at the element at index anIndex. If no equal object is found, answer the result of evaluating aBlock

top


testing (instance)

= anObject
Answer true if the receiver is equal to anObject

hash

Answer an hash value for the receiver

top