00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 require_once(dirname(__FILE__) . '/KjwObject.php');
00021
00027 class KjwResultSet extends KjwObject {
00031 function KjwResultSet() {
00032 parent::KjwObject();
00033 }
00034
00035
00036 function destroy() {
00037 parent::destroy();
00038 }
00039
00045 function getNext() {
00046 return $this->notImplemented();
00047 }
00048
00054 function at() {
00055 return $this->notImplemented();
00056 }
00057
00063 function size() {
00064 return $this->notImplemented();
00065 }
00066
00073 function seekAbs($offset) {
00074 return $this->notImplemented();
00075 }
00076
00083 function seekRel($offset) {
00084 return $this->seekAbs($this->at() + $offset);
00085 }
00086
00094 function getRandom($max = -1) {
00095 require_once(dirname(__FILE__) . '/KjwArrayResultSet.php');
00096 $at = $this->at();
00097
00098 $list = array();
00099 for ($i = 0, $size = $this->size(); $i < $size; ++$i)
00100 $list[] = $i;
00101 shuffle($list);
00102
00103 $out = array();
00104 $i = 0;
00105 foreach ($list as $v) {
00106 if ($i++ == $max)
00107 break;
00108 $this->seekAbs($v);
00109 array_push($out, $this->getNext());
00110 }
00111
00112 $this->seekAbs($at);
00113 return new KjwArrayResultSet($out);
00114 }
00115 }
00116
00117 ?>