|
|
6.174 WeakArray
- Defined in namespace Smalltalk
- Category: Collections-Weak
I am similar to a plain array, but my items are stored in a weak object,
so I track which of them are garbage collected.
6.174.1 WeakArray class: instance creation
- new: size
- Private - Initialize the values array; plus, make it weak and create the ByteArray used to track garbage collected values
6.174.2 WeakArray: accessing
- aliveObjectsDo: aBlock
- Evaluate aBlock for all the elements in the array, excluding the garbage collected ones. Note: a finalized object stays alive until the next collection (the collector has no means to see whether it was resuscitated by the finalizer), so an object being alive does not mean that it is usable.
- at: index
- Answer the index-th item of the receiver, or nil if it has been garbage collected.
- at: index put: object
- Store the value associated to the given index; plus, store in nilValues whether the object is nil. nil objects whose associated item of nilValues is 1 were touched by the garbage collector.
- atAll: indices put: object
- Put object at every index contained in the indices collection
- atAllPut: object
- Put object at every index in the receiver
- clearGCFlag: index
- Clear the `object has been garbage collected' flag for the item at the given index
- do: aBlock
- Evaluate aBlock for all the elements in the array, including the garbage collected ones (pass nil for those).
- isAlive: index
- Answer whether the item at the given index is still alive or has been garbage collected. Note: a finalized object stays alive until the next collection (the collector has no means to see whether it was resuscitated by the finalizer), so an object being alive does not mean that it is usable.
- size
- Answer the number of items in the receiver
6.174.3 WeakArray: conversion
- asArray
- Answer a non-weak version of the receiver
- deepCopy
- Returns a deep copy of the receiver (the instance variables are copies of the receiver's instance variables)
- shallowCopy
- Returns a shallow copy of the receiver (the instance variables are not copied)
- species
- Answer Array; this method is used in the #copyEmpty: message, which in turn is used by all collection-returning methods (collect:, select:, reject:, etc.).
6.174.4 WeakArray: loading
- postLoad
- Called after loading an object; must restore it to the state before `preStore' was called. Make it weak again
|