Php/docs/class.weakmap
来自菜鸟教程
(PECL weakref >= 0.2.0)
简介
类摘要
WeakMap implements Countable , ArrayAccess , Iterator {
public __construct ( )
public count ( ) : int
public key ( ) : object
public next ( ) : void
public offsetExists
( object $object
) : bool
public offsetUnset
( object $object
) : void
public rewind ( ) : void
public valid ( ) : bool
}
范例
Example #1 Weakmap usage example
<?php$wm = new WeakMap();$o = new StdClass;class A { public function __destruct() { echo "Dead!\n"; }}$wm[$o] = new A;var_dump(count($wm));echo "Unsetting..\n";unset($o);echo "Done\n";var_dump(count($wm));
以上例程会输出:
int(1) Unsetting.. Dead! Done int(0)
Table of Contents
- WeakMap::__construct — Constructs a new map
- WeakMap::count — Counts the number of live entries in the map
- WeakMap::current — Returns the current value under iteration
- WeakMap::key — Returns the current key under iteration
- WeakMap::next — Advances to the next map element
- WeakMap::offsetExists — Checks whether a certain object is in the map
- WeakMap::offsetGet — Returns the value pointed to by a certain object
- WeakMap::offsetSet — Updates the map with a new key-value pair
- WeakMap::offsetUnset — Removes an entry from the map
- WeakMap::rewind — Rewinds the iterator to the beginning of the map
- WeakMap::valid — Returns whether the iterator is still on a valid map element
/* 方法 */