Home > vbmeg > functions > common > utility > stack > tools > vb_m_stack_push.m

vb_m_stack_push

PURPOSE ^

push data into memory stack

SYNOPSIS ^

function [obj] = vb_m_stack_push(obj, push_data)

DESCRIPTION ^

 push data into memory stack
 [USAGE]
    [obj] = vb_m_stack_push(<obj>, <push_data>);
 [IN]
          obj : m_stack object.
    push_data : push data into m_stack.
 [OUT]
    obj : m_stack object

 Copyright (C) 2011, ATR All Rights Reserved.
 License : New BSD License(see VBMEG_LICENSE.txt)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [obj] = vb_m_stack_push(obj, push_data)
0002 % push data into memory stack
0003 % [USAGE]
0004 %    [obj] = vb_m_stack_push(<obj>, <push_data>);
0005 % [IN]
0006 %          obj : m_stack object.
0007 %    push_data : push data into m_stack.
0008 % [OUT]
0009 %    obj : m_stack object
0010 %
0011 % Copyright (C) 2011, ATR All Rights Reserved.
0012 % License : New BSD License(see VBMEG_LICENSE.txt)
0013 
0014 %
0015 % --- Previous check
0016 %
0017 if ~exist('obj', 'var'), error('obj is a required parameter.'); end
0018 if ~exist('push_data', 'var')
0019     error('push_data is a required parameter.');
0020 end
0021 
0022 %
0023 % --- Main Procedure
0024 %
0025 if ~isinf(obj.stack_size) && (length(obj.queue) >= obj.stack_size)
0026     % delete top
0027     obj.queue(1) = [];
0028 end
0029 
0030 % push back
0031 obj.queue = [obj.queue; push_data];
0032 
0033 %
0034 % --- After check
0035 %
0036 if nargout ~= 1
0037     error('function caller should receive obj.');
0038 end
0039

Generated on Mon 22-May-2023 06:53:56 by m2html © 2005