#ifndef _PATHINDEX_
#define _PATHINDEX_ 
#include "term.h"
#include "folsubst.h"
#include "array.h"
#include "ohash.h"
#include "misc.h"
typedef struct PATHIDX_HELP {
  MEMORY mem;
  SYMBSTATE symbstate;
  TERMSTATE termstate;
  SUBSTSTATE subststate;
  FOLSTATE folstate;
  OHASH root;
  TERM* terms;
  TYPING* types;
  unsigned* marked;
  intptr_t* data;
  unsigned capacity;
  unsigned maxpos;
  unsigned size;
  ARRAY empty_pos;
  ARRAY tempar1;
  ARRAY tempar2;
  unsigned iter_pos;
  unsigned leaves;
} PATHIDX_NODE,*PATHIDX;
typedef struct PIDXNODE_HELP {
  SYMBOL symb;
  unsigned arity;
  ARRAY indexed;
  OHASH children[];
} PIDXNODE_NODE,*PIDXNODE;
PATHIDX pathidx_Create(TERMSTATE,SUBSTSTATE,FOLSTATE,unsigned);
void pathidx_Delete(PATHIDX);
MEMORY pathidx_GetMemory(PATHIDX);
SYMBSTATE pathidx_GetSymbstate(PATHIDX);
TERMSTATE pathidx_GetTermstate(PATHIDX);
SUBSTSTATE pathidx_GetSubststate(PATHIDX);
FOLSTATE pathidx_GetFolstate(PATHIDX);
BOOL pathidx_Insert(PATHIDX,TERM,TYPING,intptr_t);
unsigned pathidx_ForceInsert(PATHIDX, TERM, TYPING, intptr_t);
BOOL pathidx_Remove(PATHIDX,TERM,TYPING);
BOOL pathidx_RemoveByPosition(PATHIDX,unsigned);
ARRAY pathidx_FindInstances(PATHIDX,TERM,SUBST,TYPING,unsigned);
ARRAY pathidx_FindInstancesPure(PATHIDX, TERM, SUBST, TYPING, ARRAY*);
ARRAY pathidx_FindUnifiables(PATHIDX,TERM,TYPING,unsigned);
BOOL pathidx_FindExactMatch(PATHIDX,TERM,SUBST,TYPING,TERM*,intptr_t*);
BOOL pathidx_IteratorIsRunning(PATHIDX);
BOOL pathidx_StartInstancesIterator(PATHIDX,TERM,SUBST,TYPING);
BOOL pathidx_NextInstanceFromIterator(PATHIDX,TERM,SUBST,TYPING);
intptr_t pathidx_DataFromCurrentIteratorInstance(PATHIDX);
void pathidx_StopInstancesIterator(PATHIDX);
BOOL pathidx_StartUnifiablesIterator(PATHIDX,TERM,TYPING,unsigned);
BOOL pathidx_NextUnifiableFromIterator(PATHIDX,TERM,TYPING,unsigned);
TERM pathidx_TermFromCurrentIteratorUnifiable(PATHIDX);
intptr_t pathidx_DataFromCurrentIteratorUnifiable(PATHIDX);
void pathidx_StopUnifiablesIterator(PATHIDX);
void pathidx_Print(PATHIDX);
#endif
