_list = $list; } /** * リストのデータ数を取得 * @return int */ function count() { $list =& $this->_list; if (!is_array($list)) { trigger_error("List is not array", E_USER_WARNING); return 0; } return count($list); } /** * リストに次のデータがあるか * @return boolean */ function hasNext() { $count = $this->count(); if (!$count) return false; $i =& $this->_iterate; if (!is_int($i) || $i < 0) { trigger_error("Iterate is not int", E_USER_WARNING); return false; } return ($count > $i); } /** * リストから次のデータを取得 * @return mixed */ function & next() { if (!$this->hasNext()) { trigger_error("List has no next", E_USER_NOTICE); $row = null; return $row; } return $this->_list[$this->_iterate++]; } /** * リストから指定位置のデータを取得 * @param int i * @return mixed */ function & get($i) { if (!is_int($i) || $i<0) { trigger_error("parameter is not int", E_USER_WARNING); $row = null; return $row; } if ($this->count() > $i) { return $this->_list[$i]; } else { trigger_error("List[{$i}] is not set", E_USER_NOTICE); $row = null; return $row; } } /** * ポインタをリストの先頭に戻す * @param int i * @return mixed */ function reset() { $this->_iterate = 0; } }