コード例 #1
0
 protected final function createDocument()
 {
     $author = [new Author('spock'), new Author('kirk'), new Author('scotty')];
     $sut = $this->createRootEntity($author[0]);
     // adding 'like' to the post
     foreach ($author as $a) {
         $sut->addFan($a);
     }
     // adding comments to the post
     foreach ($author as $a) {
         $comm = new Commentary($a);
         $comm->setMessage("a comment from " . $a->getNickname());
         // adding 'like' to each comment
         foreach ($author as $c) {
             $comm->addFan($c);
         }
         $sut->attachCommentary($comm);
     }
     return $sut;
 }
コード例 #2
0
ファイル: sizearray.php プロジェクト: xtrasmal/iinano
    }
    public function offsetUnset($offset)
    {
        foreach ($this->wrapped as $idx => $comm) {
            if ($comm->getUuid() === $offset) {
                unset($this->wrapped[$idx]);
                break;
            }
        }
    }
    public function rewind()
    {
        $this->ptr = 0;
    }
    public function valid()
    {
        return array_key_exists($this->ptr, $this->wrapped);
    }
}
$comment = [];
for ($k = 0; $k < 1000; $k++) {
    $obj = new Commentary(new Author("user {$k}"));
    $obj->setMessage("aaaaaaaaaaaaa {$k}");
    $comment[$k] = $obj;
}
$stop = microtime(true);
printf("%.0f kB\n", memory_get_peak_usage(true) / 1000.0);
$it = new CommentaryIterator($comment);
//echo $it->count() . PHP_EOL;
printf("%.0f kB\n", memory_get_peak_usage(true) / 1000.0);
$it[] = 'oto';