with Semaphore;
generic
    type Item is private;
package Deque_Nonpriority_Balking_Concurrent_Unbounded_Managed_Iterator is

    type Deque is limited private;

    type Location is (Front, Back);

    procedure Copy (From_The_Deque : in Deque; To_The_Deque : in out Deque);
    procedure Clear (The_Deque : in out Deque);
    procedure Add (The_Item : in Item;
                   To_The_Deque : in out Deque;
                   At_The_Location : in Location);
    procedure Pop (The_Deque : in out Deque; At_The_Location : in Location);
    procedure Remove_Item (From_The_Deque : in out Deque;
                           At_The_Position : in Positive);

    function Is_Equal (Left : in Deque; Right : in Deque) return Boolean;
    function Length_Of (The_Deque : in Deque) return Natural;
    function Is_Empty (The_Deque : in Deque) return Boolean;
    function Front_Of (The_Deque : in Deque) return Item;
    function Back_Of (The_Deque : in Deque) return Item;
    function Position_Of
                (The_Item : in Item; In_The_Deque : in Deque) return Natural;

    generic
        with procedure Process (The_Item : in Item; Continue : out Boolean);
    procedure Iterate (Over_The_Deque : in Deque);

    Overflow : exception;
    Underflow : exception;
    Position_Error : exception;

private
    type Node;
    type Structure is access Node;
    type Deque is
        record
            Guard : Semaphore.Kind;
            The_Front : Structure;
            The_Back : Structure;
        end record;
end Deque_Nonpriority_Balking_Concurrent_Unbounded_Managed_Iterator;