In order to perform a search of scalar ( sample ) in filed, we can form auxiliary filed in which all elements are equal to scalar and compare it for matching elements with source field. As a result the slice will be formed where matching elements are marked with set bits.
procedure STOF( refer slice f[ ]; index cap, val ); { Scalar to field }
index
i, n;
begin
{ Fill all elements of field ( f ) with values of scalar ( val ) }
for i := cap-1 downto 0 do
begin
n := ex2 i;
if ( val div n ) = 0 then CLEAR( f[ i ] ) else SET( f[ i ] );
val := val mod n
end
end;{ End of STOF }
procedure SEARCH( refer slice res, f[ ]; index cap, val );
const
equ = 9;
slice
tem[ ];
begin
{
Search of scalar ( val ) in filed ( f ), result put in slice ( res ).
}
slice tem[ cap ];{ Field for samples }
STOF( tem, cap, val );{ Fill samples field }
COMPF( res, tem, f, cap, equ ){ Get result }
end;{ End of SEARCH }