public function __construct(array $rawData) { foreach ($rawData as $y => $data) { for ($x = 0, $cols = strlen($data); $x < $cols; $x++) { $this["{$x},{$y}"] = $data[$x]; } } $this->neighborFinder = memoize([$this, 'findNeighbors']); }
/** * Returns a new function that calls the given function just once and then simply * returns its result on each subsequent call. * @param callable function to call just once and then remember the result */ public static function memoize($f) { return memoize($f); }
function getGalleryPhotoIndex($gallery, $photo) { return memoize($gallery, $photo, 'getGalleryPhotoIndexExec'); }