function C = myintersect(A,B)
% MYINTERSECT Intersection of two sets of positive integers
%
% C = MYINTERSECT(A,B)

% Jerod Weinman
% jerod@acm.org

% $Id: myintersect.m 1 2009-05-07 13:41:00Z weinman $
 
% Jerod Weinman
% jerod@acm.org
% /home/data/svn/vision/tools/package/GPL_STATEMENT
 

if isempty(A)
    szA = 0;
else
    szA = max(A);
end

if isempty(B)
    szB = 0;
else
    szB = max(B);
end

if (~szA || ~szB)
    C = [];
elseif (szA>szB)
    I = false(1, szA);
    I(A) = 1;
    C = B(I(B));
else
    I = false(1, szB);
    I(B) = 1;
    C = A(I(A));
end;

