public static TermTuple makeByReferers(TermOrCompoundTermOrVariableReferer[] referers) { TermTuple result = new TermTuple(); result.refererOrIntervals = referers.Select(v => RefererOrInterval.makeReferer(v)).ToArray(); return(result); }
internal TermTupleIndex returnIndexOfTermTupleForHumanReadableTermNameOrCreate(string name, out int termOrCompoundTermOrVariableRefererId) { bool nameIsPresentInHumanReadableNames = termNamesByhumanReadableName.ContainsKey(name); if (nameIsPresentInHumanReadableNames) { termOrCompoundTermOrVariableRefererId = termTuples[(int)termNamesByhumanReadableName[name].index].refererOrIntervals[0].referer.getAtomic; return(termNamesByhumanReadableName[name]); } // else here termOrCompoundTermOrVariableRefererId = TermOrCompoundTermOrVariableRefererCounter; TermOrCompoundTermOrVariableRefererCounter++; TermTuple termTuple = TermTuple.makeByReferers(new TermOrCompoundTermOrVariableReferer[] { TermOrCompoundTermOrVariableReferer.makeAtomic(termOrCompoundTermOrVariableRefererId) }); TermTupleIndex index = TermTupleIndex.make((ulong)termTuples.Count); termTuples.Add(termTuple); termNamesByhumanReadableName[name] = index; termOrCompoundTermOrVariableRefererIdToHumanReadableName[termOrCompoundTermOrVariableRefererId] = name; return(index); }
// TODO< overhaul so it returns RefererOrInterval > public TermOrCompoundTermOrVariableReferer right(CompoundAndTermContext compoundAndTermContext) { TermTuple dereferencedCompoundTuple = compoundAndTermContext.accessTermTupleByIndex(termTupleIndex); Debug.Assert(dereferencedCompoundTuple.refererOrIntervals.Length == 2, "only valid for binary compounds"); Debug.Assert(dereferencedCompoundTuple.refererOrIntervals[1].isReferer); return(dereferencedCompoundTuple.refererOrIntervals[1].referer); }
internal TermTupleIndex addTermTupleByReferers(TermOrCompoundTermOrVariableReferer[] referers) { ulong hash = calcHashOfTermOrCompoundTermOrVariableReferers(referers); TermTupleIndex insertionIndex = TermTupleIndex.make((ulong)termTuples.Count); termTuples.Add(TermTuple.makeByReferers(referers)); if (!termTupleIndicesByTermTupleHash.ContainsKey(hash)) { termTupleIndicesByTermTupleHash[hash] = new List <TermTupleIndex>() { insertionIndex }; return(insertionIndex); } termTupleIndicesByTermTupleHash[hash].Add(insertionIndex); return(insertionIndex); }
public uint getComponentLength(CompoundAndTermContext compoundAndTermContext) { TermTuple dereferencedCompoundTuple = compoundAndTermContext.accessTermTupleByIndex(termTupleIndex); return((uint)dereferencedCompoundTuple.refererOrIntervals.Length); }
public RefererOrInterval getComponentByIndex(CompoundAndTermContext compoundAndTermContext, uint index) { TermTuple dereferencedCompoundTuple = compoundAndTermContext.accessTermTupleByIndex(termTupleIndex); return(dereferencedCompoundTuple.refererOrIntervals[index]); }