(*
This file is part of the dpll(t) engine sammy
Copyright (C) 2004  The University of Iowa
George Hagen

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*)

(* pqueue.mli *)

(** Priority queue module, implemented as an array of Pred.pred.  In order
to be able to backtrack, elements are not actually removed, rather an internal
size variable keeps track of how many elements are still "active", with 
dequeued elements being moved past the size position. *)

exception Empty
(** Attempted to dequeue from an empty pqueue *)

type pqueue

val peek_queue : pqueue -> Pred.pred
(** returns the max pred element without changing the queue *)

val dequeue : pqueue -> (Pred.pred * Global.status)
(** dequeue q
returns the max element (predicate,status pair) in the queue.
Side effect: moves this element to the size position (end) of the current queue.  Also restores queue ordering.
Raises [Pqueue.Empty] if attempted when size < 1.
Raises [Invalid_argument "Array.set"] if you attempt this on a queue with no elements (see create_queue).
*)

val mark_queue : pqueue -> unit
(** Marks the current queue for backtracking purposes.  Each mark is labeled by the current state.
*)

val create_queue : Pred.pred array -> State.state -> pqueue
(** [create_queue a state] Returns a new pqueue based on array [a] of 
predicates with initial state [state].
*)


val empty_queue : pqueue
(** Returns an empty queue. *)

val sort_queue : pqueue -> unit
(** Re-sorts the queue. *)

val backtrack_queue : pqueue -> State.state -> unit
(** Backtracks the queue to first mark with the indicated [State.state]. *)

val augment_queue : pqueue -> (Pred.pred list) -> unit
(** Adds new predicates to the queue (used when quantifier instances are generated). *)

(** {6 Debugging code} *)

val get_element_ids : pqueue -> Global.pred_id list
(** Returns a list of the ids currently active in the queue, *)

(*
val check_linkages : pqueue -> int -> bool
(** Checks that all input clauses are linked to an enqueued predicate. *)
*)

val print_queue : pqueue -> unit
(** prints the entre queue. *)

