diff options
author | xue <> | 2006-08-02 02:24:29 +0000 |
---|---|---|
committer | xue <> | 2006-08-02 02:24:29 +0000 |
commit | 550ba06593b467b643862d41a00ca2dd12ee704b (patch) | |
tree | 16ad8180c2f0b96454453effff89dc236469ee4f /framework/Collections | |
parent | ccfa7850dc435ae9941cde18be827b3aac550f85 (diff) |
merge from 3.0 branch till 1320.
Diffstat (limited to 'framework/Collections')
-rw-r--r-- | framework/Collections/TDummyDataSource.php | 12 | ||||
-rw-r--r-- | framework/Collections/TList.php | 15 | ||||
-rw-r--r-- | framework/Collections/TMap.php | 15 | ||||
-rw-r--r-- | framework/Collections/TPagedDataSource.php | 12 | ||||
-rw-r--r-- | framework/Collections/TStack.php | 12 |
5 files changed, 57 insertions, 9 deletions
diff --git a/framework/Collections/TDummyDataSource.php b/framework/Collections/TDummyDataSource.php index 46e625ab..d7fee4a9 100644 --- a/framework/Collections/TDummyDataSource.php +++ b/framework/Collections/TDummyDataSource.php @@ -26,7 +26,7 @@ * @package System.Collections
* @since 3.0
*/
-class TDummyDataSource extends TComponent implements IteratorAggregate
+class TDummyDataSource extends TComponent implements IteratorAggregate, Countable
{
private $_count;
@@ -54,6 +54,16 @@ class TDummyDataSource extends TComponent implements IteratorAggregate {
return new TDummyDataSourceIterator($this->_count);
}
+
+ /**
+ * Returns the number of (virtual) items in the data source.
+ * This method is required by Countable interface.
+ * @return integer number of (virtual) items in the data source.
+ */
+ public function count()
+ {
+ return $this->getCount();
+ }
}
/**
diff --git a/framework/Collections/TList.php b/framework/Collections/TList.php index 015781cb..1104ec47 100644 --- a/framework/Collections/TList.php +++ b/framework/Collections/TList.php @@ -25,9 +25,8 @@ * unset($list[$index]); // remove the item at $index
* if(isset($list[$index])) // if the list has an item at $index
* foreach($list as $index=>$item) // traverse each item in the list
+ * $n=count($list); // returns the number of items in the list
* </code>
- * Note, count($list) will always return 1. You should use {@link getCount()}
- * to determine the number of items in the list.
*
* To extend TList by doing additional operations with each addition or removal
* operation, override {@link insertAt()}, and {@link removeAt()}.
@@ -37,7 +36,7 @@ * @package System.Collections
* @since 3.0
*/
-class TList extends TComponent implements IteratorAggregate,ArrayAccess
+class TList extends TComponent implements IteratorAggregate,ArrayAccess,Countable
{
/**
* internal data storage
@@ -95,6 +94,16 @@ class TList extends TComponent implements IteratorAggregate,ArrayAccess }
/**
+ * Returns the number of items in the list.
+ * This method is required by Countable interface.
+ * @return integer number of items in the list.
+ */
+ public function count()
+ {
+ return $this->getCount();
+ }
+
+ /**
* @return integer the number of items in the list
*/
public function getCount()
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
* </code>
- * Note, count($map) will always return 1. You should use {@link getCount()}
- * to determine the number of items in the map.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @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
@@ -85,6 +84,16 @@ class TMap extends TComponent implements IteratorAggregate,ArrayAccess }
/**
+ * 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
*/
public function getCount()
diff --git a/framework/Collections/TPagedDataSource.php b/framework/Collections/TPagedDataSource.php index 6192b1f7..a2bce9e3 100644 --- a/framework/Collections/TPagedDataSource.php +++ b/framework/Collections/TPagedDataSource.php @@ -28,7 +28,7 @@ * @package System.Collections
* @since 3.0
*/
-class TPagedDataSource extends TComponent implements IteratorAggregate
+class TPagedDataSource extends TComponent implements IteratorAggregate,Countable
{
/**
* @var mixed original data source
@@ -183,6 +183,16 @@ class TPagedDataSource extends TComponent implements IteratorAggregate }
/**
+ * Returns the number of items in the current page.
+ * This method is required by Countable interface.
+ * @return integer number of items in the current page.
+ */
+ public function count()
+ {
+ return $this->getCount();
+ }
+
+ /**
* @return integer number of pages
*/
public function getPageCount()
diff --git a/framework/Collections/TStack.php b/framework/Collections/TStack.php index 79d17902..f1118d90 100644 --- a/framework/Collections/TStack.php +++ b/framework/Collections/TStack.php @@ -31,7 +31,7 @@ * @package System.Collections
* @since 3.0
*/
-class TStack extends TComponent implements IteratorAggregate
+class TStack extends TComponent implements IteratorAggregate,Countable
{
/**
* internal data storage
@@ -160,6 +160,16 @@ class TStack extends TComponent implements IteratorAggregate {
return $this->_c;
}
+
+ /**
+ * Returns the number of items in the stack.
+ * This method is required by Countable interface.
+ * @return integer number of items in the stack.
+ */
+ public function count()
+ {
+ return $this->getCount();
+ }
}
/**
|