Skip to content
Snippets Groups Projects
queue.m 1.31 KiB
Newer Older
%QUEUE constructor for queue object
% usage:
%   q  = queue    - Default constructor, empty queue table
%   mq = queue(q) - Copy constructor 
%
% example:
%   q = queue 
%   q = push(q, [1:2])
%   q = push(q, ones(1,5))
%   q = undo(q)
%   data = get(q)
%   q = push(q, zeros(1,3))
%   etc ...
%
% todos: define maxSize dimension
% if nargin == 1 && isa(varargin{1},'integer')
%   q.maxSize = varargin{1};
% end
% and test maxSize in push

% copy constructor
% ----------------
  queue = varargin{1};
  return;
    
% default constructor
% -------------------
  % current index inside of queue, change by undo & redo 
  % ----------------------------------------------------
  % number of object currently stored 
  % ---------------------------------
  q.size = 0;
  
  % buffer where objects are stored
  % -------------------------------
  q.buffer = {};
  % one object buffer, prepared by undo & redo methods and disposed for get method
  % -----------------------------------------------------------------------
  q.data = {};
  error('queue:queue', 'Invalid arguments.');