#ifndef _UPQUEUE_
#define _UPQUEUE_ 
#include <math.h>
#include "memory.h"
typedef struct UPQ_HELP {
  unsigned capacity;
  unsigned size;
  unsigned* heap;
  PRIOR_T* prior;
  unsigned* pos;
  PRIOR_T upper_bound;
} UPQ_NODE, *UPQUEUE;
unsigned upq_GetSize(UPQUEUE);
unsigned upq_GetCapacity(UPQUEUE);
UPQUEUE upq_Create(MEMORY, unsigned);
UPQUEUE upq_Copy(MEMORY, UPQUEUE);
BOOL upq_Contains(UPQUEUE, unsigned);
BOOL upq_ExtendIfNecessary(MEMORY, UPQUEUE, unsigned);
BOOL upq_AddLazily(MEMORY, UPQUEUE, unsigned, PRIOR_T);
BOOL upq_Add(MEMORY, UPQUEUE, unsigned, PRIOR_T);
unsigned upq_ExtractMax(UPQUEUE);
unsigned upq_GetMax(UPQUEUE);
PRIOR_T upq_GetMaxPrior(UPQUEUE);
PRIOR_T upq_GetUpperBound(UPQUEUE);
void upq_SetUpperBound(UPQUEUE, PRIOR_T);
BOOL upq_Remove(UPQUEUE, unsigned);
unsigned upq_ReinsertElement(UPQUEUE, unsigned);
void upq_Rescale(UPQUEUE, signed);
void upq_SetValue(UPQUEUE, unsigned);
void upq_Normalize(UPQUEUE, unsigned);
void upq_UpdatePrior(UPQUEUE, unsigned, PRIOR_T);
void upq_UpdatePriorLazily(UPQUEUE, unsigned, PRIOR_T);
unsigned upq_IncreasePrior(UPQUEUE, unsigned, PRIOR_T);
unsigned upq_IncreasePriorLazily(UPQUEUE, unsigned, PRIOR_T);
void upq_Heapify(UPQUEUE);
PRIOR_T* upq_GetPrior(UPQUEUE);
void upq_Delete(MEMORY, UPQUEUE);
void upq_Show(UPQUEUE);
#endif
