package uk.co.bigroom.utils
{
import flash.utils.Dictionary;
/**
* Class to create a weak reference to an object. A weak reference
* is a reference that does not prevent the object from being
* garbage collected. If the object has been garbage collected
* then the get method will return null.
*/
public class WeakRef
{
private var dic:Dictionary;
/**
* The constructor - creates a weak reference.
*
* @param obj the object to create a weak reference to
*/
public function WeakRef(obj:*)
{
dic = new Dictionary(true);
dic[obj] = 1;
}
/**
* To get a strong reference to the object.
*
* @return a strong reference to the object or null if the
* object has been garbage collected
*/
public function get():*
{
for (var item:* in dic)
{
return item;
}
return null;
}
}
}
In questa classe, come indicano uno come riferimento debole e uno come riferimento forte.Riferimento debole e riferimento sicuro
Mi può dare la definizione di riferimento debole e forte. non sono in grado di ottenere. spiacente – Kevin
@ theband: si prega di consultare il mio aggiornamento. inoltre, potresti voler controllare http://en.wikipedia.org/wiki/Reference_counting#Use_in_garbage_collection per ulteriori dettagli. – back2dos
Grazie mille per l'aggiornamento – Kevin