diff --git a/@queue/display.m b/@queue/display.m new file mode 100644 index 0000000000000000000000000000000000000000..815ba442907b03e8139d4dd994694cb6a13526c1 --- /dev/null +++ b/@queue/display.m @@ -0,0 +1,26 @@ +function display(self) +%DISPLAY Display a queue table object +% display(queue) + +% Copyright (c) 2004 Matthew Krauski (mkrauski@uci.edu), CNLM, UC Irvine + +%isLoose = strcmp(get(0,'FormatSpacing'),'loose'); +isLoose = 0; + +if(length(inputname(1)) ~= 0) + if isLoose, disp(' '), end + disp( sprintf('%s =', inputname(1)) ); +end + +if isLoose, disp(' '), end + +disp(struct(self)); + +%fprintf('\thashtable\n' ); +% if isempty(self) +% fprintf('\tEmpty\n\n' ); +% else +% % disp( sprintf('\tElements:') ); +% display( self.index ); +% end + diff --git a/@queue/get.m b/@queue/get.m new file mode 100644 index 0000000000000000000000000000000000000000..ba37c17ddedd7b69bc7e105d9c515825c1545c55 --- /dev/null +++ b/@queue/get.m @@ -0,0 +1,7 @@ +function data = get(self) +%GET Get last data from the queue table +% data = get(queue) + +% $Id$ + +data = self.data; diff --git a/@queue/isempty.m b/@queue/isempty.m new file mode 100644 index 0000000000000000000000000000000000000000..4451491a7ac32aec88d48bea91b154864d2219bc --- /dev/null +++ b/@queue/isempty.m @@ -0,0 +1,8 @@ +function bool = isempty(self) +%ISEMPTY Check to see if the queue is empty +% bool = isempty(queue) + +% + +bool = isempty(self.lifo); + diff --git a/@queue/pop.m b/@queue/pop.m new file mode 100644 index 0000000000000000000000000000000000000000..5f6a0b8a9f6832d0870f5e9c741d4d59f8d97e0e --- /dev/null +++ b/@queue/pop.m @@ -0,0 +1,16 @@ +function self = pop(self) +%PUT get data from the queue +% [queue data] = get(queue,data) +% +% $Id$ + +if self.index==0 + self.data = []; + self.lifo = []; + return +end + +self.data = self.lifo(self.index,:); + +self.lifo(self.index,:) = []; +self.index = self.index-1; diff --git a/@queue/push.m b/@queue/push.m new file mode 100644 index 0000000000000000000000000000000000000000..7f8eed5884824503338f42911cc9ba3d4476aaa5 --- /dev/null +++ b/@queue/push.m @@ -0,0 +1,17 @@ +function self = push(self,data) +%PUT Put data in the queue +% queue = put(queue,data) +% +% $Id$ + +if isempty(data) + return +end + +if isequal(data, self.data) + return +end + +self.index = self.index+1; +self.lifo(end+1,:) = data; +self.data = data; diff --git a/@queue/queue.m b/@queue/queue.m new file mode 100644 index 0000000000000000000000000000000000000000..3e9295d8c7d0638f354de1e7af784885451cffdd --- /dev/null +++ b/@queue/queue.m @@ -0,0 +1,19 @@ +function queue = queue(varargin) +%HASHTABLE Constructor for LIFO queue class +% q = queue - Default constructor, empty queue table +% mq = queue(q) - Copy constructor + +% $Id$ + +if nargin == 1 && isa(varargin{1},'queue') + queue = varargin{1}; + return; +elseif nargin == 0 + q.index = 0; + q.data = []; + q.lifo = []; +else + error('queue:queue', 'Invalid arguments.'); +end + +queue = class(q,'queue'); diff --git a/@queue/view.m b/@queue/view.m new file mode 100644 index 0000000000000000000000000000000000000000..449552ed300c2ed61b69cd02803ac290004c5a37 --- /dev/null +++ b/@queue/view.m @@ -0,0 +1,11 @@ +function data = view(self) +%GET Get last data from the queue table +% data = get(queue) + +% $Id$ + +self.index + +self.lifo + +self.data \ No newline at end of file