Mercurial > hg > ishara
view sequences/+seq/cacher.m @ 61:eff6bddf82e3 tip
Finally implemented perceptual brightness thing.
author | samer |
---|---|
date | Sun, 11 Oct 2015 10:20:42 +0100 |
parents | 9e7be347b3a0 |
children |
line wrap: on
line source
% cacher- Cache each buffer to speed up multiple reads % % cacher :: seq(A) -> seq(A). % % The idea is that the data is cached on each call to next, % so that reading the array does not require calls to source. classdef cacher < seq properties (GetAccess=private, SetAccess=private) source x end methods function o=cacher(source), o.source=source; o.x=head(source); end function x=head(o), x=o.x; end function s=tostring(o), s=['cache(',tostring(o.source),')']; end function z=elsize(o), z=size(o.x); end function o=next(o) o.source=next(o.source); if ~isempty(o.source), o.x=head(o.source); else o=o.source; end end end end