public BinaryHeapNode(TItem item, TPriority priority, int index, Guid heapIdentifier) { Item = item; Priority = priority; Index = index; HeapIdentifier = heapIdentifier; }
public HeapNode Get(int index, T item, TPriority priority) { var instance = Get(); instance.Index = index; instance.Priority = priority; instance.Value = item; return(instance); }
//************************************************************ // static helpers to generate a Term //************************************************************ // try to extract the next term from the string // put the term on the stack protected static CTerm_Base GetNextTerm(ref string Term, Stack <CTerm_Base> Stack, MMC.Calc.CEnvironment Env, TPriority Prio) { CTerm_Base Result = null; int Stack_Count = Stack.Count; while (!String.IsNullOrEmpty(Term) || Result != null) { // if we didn't find a term yet if (Result == null) { // find next operation Result = Env.FindOp(ref Term); // if we didn't find anything ... if (Result == null) { break; } } // This term ends if prio is less or equal, i.e. 2-3+2 = (2-3)+2 if (Result.Priotity <= Prio) { break; } // Let the Operation get their operands from stack or string CTerm_Base Next = Result.Compile(ref Term, Stack, Env); // and try to reduce the term as much as possible TTermType Type = Result.Type; Result = Result.Replace(Env); // check if we have to combine this Term with the TopOfStack // but only if the second term is not a number // e.g. "2sqrt2" = "2*sqrt2" if ((Type != TTermType.Number) && (Type != TTermType.Seperator) && (Stack.Count == Stack_Count + 1)) { Result = Env.Combine(Stack.Pop(), Result); Result = Result.Replace(Env); } // put the Operation onto the stack Stack.Push(Result); // and proceed with the next term (or null if none) Result = Next; } return(Result); }
/// <summary> /// Конструктор для полноценной задачи /// </summary> /// <param name="pname">Название задачи</param> /// <param name="ptext">Расшифровка задачи</param> /// <param name="plabel">Метка задачи</param> /// <param name="ptags">Тэги</param> /// <param name="pstatus">Статус</param> /// <param name="ptype">Тип задачи</param> /// <param name="ppriority">Приоритет</param> public TToDoItem(string pname, string ptext, string plabel, string ptags, TStatus pstatus, TType ptype, TPriority ppriority) { name = pname; text = ptext; label = plabel; tags = ptags; status = pstatus; type = ptype; priority = ppriority; dateCreated = DateTime.Now; // везде берем за отчет текущее время и дату, момент создания progress = 0; // инициализируем массив задач Items = new TToDoItem[0]; // добавляем историю теперь history = new THistory[0]; AddHistory(); }
protected bool _bTermB; // for compile: is TermB needed? (should be overwritten in the derived class) //------------------------------------------------------------ // standard constructor for 2Ops public CTerm_2Ops(string Name, TPriority Priority, bool TermA, bool TermB) : base(Name, Priority, TTermType.TwoOps) { _TermA = null; _bTermA = TermA; _TermB = null; _bTermB = TermB; }
Assert.True(queue.TryPeek(out TElement element, out TPriority priority));
public SynchronisedMaxPriorityQueueNode(TItem data, TPriority priority) { Data = data; Priority = priority; }
public static string GetPriorityString(TPriority type) { return PriorityStrs[(int)type]; }
public int Compare(TPriority x, TPriority y) { return(_comparer.Compare(x, y)); }
public FibonacciNode(TItem item, TPriority priority, Guid heapIdentifier) { Item = item; Priority = priority; HeapIdentifier = heapIdentifier; }
public ValueAndPriority(TValue value, TPriority priority) { this.value = value; this.priority = priority; }
public MaxPriorityQueueNode(TItem data, TPriority priority) { Data = data; Priority = priority; }
/// <summary>Adds an item to the heap.</summary> public void Insert(TPriority key, TElement value) { // Create the entry based on the provided key and value Insert(new KeyValuePair <TPriority, TElement>(key, value)); }
//------------------------------------------------------------ // construct this object with a function or variable name // e.g. "+" or "sin" or "pi" public CTerm_Base(string Name, TPriority Priority, TTermType TermType) { _Name = Name; _Priority = Priority; _TermType = TermType; }
public void Deconstruct(out TElement element, out TPriority priority) { element = Element; priority = Priority; }
public Node(TElement element, TPriority priority) { Priority = priority; Element = element; }
public ItemPriority(TItem item, TPriority priority) => (Item, Priority) = (item, priority);
public Node(int level, TPriority key, TItem item) : this(level) { Key = key; Item = item; }
public static Image GetPriorityImage(TPriority type) { return Image.GetInstance(DataPathGetter.GetImagesDir() + "\\" + PriorityImgs[(int)type]); }