#ifndef _SHARING_
#define _SHARING_ 
#include "term.h"
#include "sorting.h"
typedef struct SHARER_HELP {
  MEMORY mem;
  SYMBSTATE symbstate;
  TERMSTATE termstate;
  ARRAY cons;
  ARRAY vars;
  ARRAY shared;
  char* buffer;
  ARRAY subterms;
} SHARER_NODE,*SHARER;
SYMBOL sharing_IdxToSymb(unsigned);
unsigned sharing_ConstantSIdx(SYMBOL);
unsigned sharing_ConstantTIdx(TERM);
unsigned sharing_ComplexIdx(intptr_t);
unsigned sharing_SharedIdx(TERM);
SHARER sharing_Init(TERMSTATE);
void sharing_Free(SHARER);
TERM sharing_GetSharedTerm(SHARER,TERM);
TERM sharing_GetSharedTermFlat(SHARER,TERM);
TERM sharing_GetSharedTermByArgs(SHARER, SYMBOL, ARRAY);
BOOL sharing_IsShared(TERM);
BOOL sharing_IsSharedBySharer(SHARER, TERM);
ARRAY sharing_GenerateSmallerEqualTerms(SHARER, ARRAY, ARRAY, unsigned);
ARRAY sharing_GenerateSmallerEqualAtoms(SHARER, ARRAY, ARRAY, unsigned);
#endif
