public void Push(IntendedPlan ip) { plans.Insert(0, ip); if (ip.IsAtomic()) { atomicCount++; } }
public IntendedPlan Pop() { IntendedPlan top = plans[0]; plans.RemoveAt(0); if (IsAtomic() && top.IsAtomic()) { atomicCount--; } return(top); }
public object Clone() { IntendedPlan c = new IntendedPlan(); c.unif = unif.Clone(); if (planBody != null) { c.planBody = planBody.ClonePB(); } c.trigger = trigger.Clone(); c.plan = plan; return(c); }
// Remove all IP until the lowest IP with trigger te public virtual bool DropDesire(Trigger te, Unifier un) { bool r = false; IntendedPlan ip = GetIntendedPlan(te, un); while (ip != null) { r = true; while (Peek() != ip) { Pop(); } Pop(); // Remove IP ip = GetIntendedPlan(te, un); // Keep removing other occurrences of te } return(r); }
public virtual KeyValuePair <Event, int> FindEventForFailure(Trigger tevent, PlanLibrary pl, Circumstance c) { Trigger failTrigger = new Trigger(TEOperator.del, tevent.GetTEType(), tevent.GetLiteral()); IEnumerator <IntendedPlan> ii = GetEnumerator(); int posInStak = Size(); // synchronized (pl.GetLock()) while (!pl.HasCandidatePlan(failTrigger) && ii.MoveNext()) { IntendedPlan ip = ii.Current; tevent = ip.GetTrigger(); failTrigger = new Trigger(TEOperator.del, tevent.GetTEType(), tevent.GetLiteral()); posInStak--; } if (tevent.IsDesire() && tevent.IsAddition() && pl.HasCandidatePlan(failTrigger)) { return(new KeyValuePair <Event, int>(new Event(failTrigger.Clone(), this), posInStak)); } else { return(new KeyValuePair <Event, int>(null, 0)); } }