From c62323a40a833d991c091f8cd99bf9a4f29bfc6c Mon Sep 17 00:00:00 2001 From: xue <> Date: Tue, 1 Aug 2006 12:27:41 +0000 Subject: Changed PHP minimum requirement to 5.1.0 --- framework/Collections/TMap.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'framework/Collections/TMap.php') diff --git a/framework/Collections/TMap.php b/framework/Collections/TMap.php index e3a26e5f..ef393866 100644 --- a/framework/Collections/TMap.php +++ b/framework/Collections/TMap.php @@ -24,16 +24,15 @@ * unset($map[$key]); // remove the value with the specified key * if(isset($map[$key])) // if the map contains the key * foreach($map as $key=>$value) // traverse the items in the map + * $n=count($map); // returns the number of items in the map * - * Note, count($map) will always return 1. You should use {@link getCount()} - * to determine the number of items in the map. * * @author Qiang Xue * @version $Revision: $ $Date: $ * @package System.Collections * @since 3.0 */ -class TMap extends TComponent implements IteratorAggregate,ArrayAccess +class TMap extends TComponent implements IteratorAggregate,ArrayAccess,Countable { /** * @var array internal data storage @@ -84,6 +83,16 @@ class TMap extends TComponent implements IteratorAggregate,ArrayAccess return new TMapIterator($this->_d); } + /** + * Returns the number of items in the map. + * This method is required by Countable interface. + * @return integer number of items in the map. + */ + public function count() + { + return $this->getCount(); + } + /** * @return integer the number of items in the map */ -- cgit v1.2.3