%% delete_g2s
%    function will delete all the cells that reference an inputed
%    condition cell as their Cell2.
% inputs:
%   object:RGrid - reference to current RGrid
%   cell:Cell - reference to cell being deleted
% outputs;
%   none
% Author: Colin Eles elesc@mcmaster.ca
% Organization: McMaster Centre for Software Certification
function [] = delete_g2s(object,cell)
deleted = [];
% loop through all the cells, if we find any Rcell with cell as
% its Cell2 then add the index to the array, if we were to
% delete the cell right away the array size would decrease and
% we would get out of bounds issues.
for i=1:size(object.Cells,2)
    if (object.Cells(i).Cell2 == cell)
        deleted = [deleted i];
    end
end
if(~isempty(deleted))
    delete(object.Cells(deleted).result);
    object.Cells(deleted) = [];
end
end

