Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
【PHP】シンプルな連結リストを実装
<?php
namespace Acme;
class LinkedList implements Iterator, Countable
{
private $list;
public function add($value)
{
$this->list[] = $value;
}
public function count()
{
return count($this->list);
}
public function current()
{
return current($this->list);
}
public function key()
{
return key($this->list);
}
public function next()
{
return next($this->list);
}
public function rewind()
{
return reset($this->list);
}
public function valid()
{
return key($this->list) !== null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.