File : sets1.ads


with Ints, Mods, Lin;
use Ints, Mods, Lin;

generic

  L_Last: in Natural;       -- if less than 64, see also package Sets2

package Sets1 is

  subtype S_Element is Integer range 0 .. 31;        -- variable index
  subtype S_Set is Int;                              -- set of variables
  type S_SetVec is array(Integer range <>) of S_Set;

  function Empty return S_Set;
  function Full return S_Set;
  function Cardinality(S: S_Set) return Integer;
  function Contains(E: S_Element; S: S_Set) return Boolean;
  procedure AddElement(E: in S_Element; S: in out S_Set);
  procedure RmElement(E: in S_Element; S: in out S_Set);
  procedure FillGap(N: in Positive; S: in out S_Set);
  procedure UnPack(S: in S_Set; U: out IVec; ULast: out Integer);
  function Hash(S: S_Set) return PMod;

  ILast: constant Natural := L_Last/32;

  subtype L_Element is Integer range 0 .. L_Last;    -- halfspace index
  type L_Set is array(0 .. ILast) of Int;            -- set of halfspaces
  type L_SetVec is array(Integer range <>) of L_Set;

  function Empty return L_Set;
  function Full return L_Set;
  function Cardinality(S: L_Set) return Integer;
  function Contains(E: L_Element; S: L_Set) return Boolean;
  procedure AddElement(E: in L_Element; S: in out L_Set);
  procedure RmElement(E: in L_Element; S: in out L_Set);
  procedure AddElements(S: in S_Set; T: in out S_Set);
  procedure FillGap(N: in Positive; S: in out L_Set);
  function Hash(S: L_Set) return PMod;

  pragma Inline (Empty,Full,Cardinality,Contains,AddElement,AddElements,RmElement);

private

  function ModP(S: S_Set) return PMod;
  function Hash(S: S_Set) return PMod renames ModP;

  function ModP(S: L_Set) return PMod;
  function Hash(S: L_Set) return PMod renames ModP;

end Sets1;