弱い参照目次
WeakRef クラスはじめにWeakRef クラスはオブジェクトへのゲートウェイを提供します。 ガベージコレクタがオブジェクトを解放するのを邪魔しません。 また、弱い参照を強い参照に切り替える方法も用意します。
クラス概要WeakRef
class WeakRef
{
/* メソッド */
public Weakref::__construct
( object
$object
)
public bool Weakref::acquire
( void
)
public object Weakref::get
( void
)
public bool Weakref::release
( void
)
public bool Weakref::valid
( void
)
}例
例1 WeakRef の使用例
<?php 上の例の出力は以下となります。 Object still exists! object(MyClass)#1 (0) { } Destroying object! Object is dead! WeakMap クラスはじめに
クラス概要WeakMap
class WeakMap
implements
Countable
,
ArrayAccess
,
Iterator
{
/* メソッド */
public __construct
( void
)
public int count
( void
)
public mixed current
( void
)
public object key
( void
)
public void next
( void
)
public bool offsetExists
( object
$object
)
public mixed offsetGet
( object
$object
)
public void offsetSet
( object
$object
, mixed $value
)
public void offsetUnset
( object
$object
)
public void rewind
( void
)
public bool valid
( void
)
}例
例1 Weakmap の使用例
<?php 上の例の出力は以下となります。 int(1) Unsetting.. Dead! Done int(0) |