with Monitor;
generic
    type Item is private;
package Bag_Simple_Multiple_Bounded_Managed_Iterator is

    type Bag (The_Size : Positive) is limited private;

    procedure Copy (From_The_Bag : in Bag; To_The_Bag : in out Bag);
    procedure Clear (The_Bag : in out Bag);
    procedure Add (The_Item : in Item; To_The_Bag : in out Bag);
    procedure Remove (The_Item : in Item; From_The_Bag : in out Bag);
    procedure Union (Of_The_Bag : in Bag;
                     And_The_Bag : in Bag;
                     To_The_Bag : in out Bag);
    procedure Intersection (Of_The_Bag : in Bag;
                            And_The_Bag : in Bag;
                            To_The_Bag : in out Bag);
    procedure Difference (Of_The_Bag : in Bag;
                          And_The_Bag : in Bag;
                          To_The_Bag : in out Bag);

    function Is_Equal (Left : in Bag; Right : in Bag) return Boolean;
    function Extent_Of (The_Bag : in Bag) return Natural;
    function Unique_Extent_Of (The_Bag : in Bag) return Natural;
    function Number_Of
                (The_Item : in Item; In_The_Bag : in Bag) return Positive;
    function Is_Empty (The_Bag : in Bag) return Boolean;
    function Is_A_Member
                (The_Item : in Item; Of_The_Bag : in Bag) return Boolean;
    function Is_A_Subset (Left : in Bag; Right : in Bag) return Boolean;
    function Is_A_Proper_Subset (Left : in Bag; Right : in Bag) return Boolean;

    generic
        with procedure Process (The_Item : in Item;
                                The_Count : in Positive;
                                Continue : out Boolean);
    procedure Iterate (Over_The_Bag : in Bag);

    Overflow : exception;
    Item_Is_Not_In_Bag : exception;

private
    type Node is
        record
            The_Item : Item;
            The_Count : Positive;
        end record;
    type Items is array (Positive range <>) of Node;
    type Bag (The_Size : Positive) is
        record
            Guard : Monitor.Kind;
            The_Back : Natural := 0;
            The_Items : Items (1 .. The_Size);
        end record;
end Bag_Simple_Multiple_Bounded_Managed_Iterator;