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;
}
}
}
इस कक्षा में, वे एक को कमजोर संदर्भ के रूप में और एक को मजबूत संदर्भ के रूप में कैसे दर्शाते हैं।कमजोर संदर्भ और मजबूत संदर्भ
तुम मुझे कमजोर और मजबूत संदर्भ के लिए परिभाषा दे सकते हैं। मैं पाने में सक्षम नहीं हूँ। क्षमा करें – Kevin
@theband: कृपया मेरा अपडेट देखें। साथ ही, आप अधिक जानकारी के लिए http://en.wikipedia.org/wiki/Reference_counting#Use_in_garbage_collection की जांच कर सकते हैं। – back2dos
अद्यतन के लिए बहुत कुछ धन्यवाद – Kevin