Unity [MenuItem] disappears when `priority` is 100

Create these classes:

public class MyTestComponent : MonoBehaviour
{
}

(CustomEditor(typeof(MyTestComponent)))
public class MyTestComponentEditor : Editor
{
    (MenuItem("GameObject/XXX/DoTest", false, 100))
    private static void DoTest()
    {
        Debug.Log("DoTest");
    }
}

save, and check if there is a new menu item in the context menu and it won’t be there. Now change the priority parameter to 10 or 1 and try again – it won’t appear anyway. Sometimes even commenting/uncommenting and reloading the editor doesn’t help.

Is this a bug or am I doing something wrong?

Graphics – Debugging the implementation of the priority queue taking care of updating the priorities

Please let me know if you need more information, but help me out here.

For an efficient implementation of algorithms like Dijkstra and Prim, we need a priority queue that supports decreasing priority operation. I found the following code (heap based priority queue) for that which stores the index of each entry in the priority queue using help A HashMap.

import java.util.HashMap;
import java.util.NoSuchElementException;

public class Heap> {
    private Key() heap;
    private int maxN, n;
    private HashMap map;
    @SuppressWarnings("unchecked")
    public Heap(int maxN) {
        if(maxN < 0 ) throw new IllegalArgumentException();
        this.maxN = maxN;
        n = 0;
        heap = (Key()) new Comparable(maxN);
        map = new HashMap<>();
    }

    boolean isEmpty() {
        return n == 0;
    }

    boolean insert(Key e) {
        if(n +1 > maxN) throw new IllegalArgumentException("maximum capacity reached " + maxN);
        heap(n) = e;
        map.put(e,n);
        int i = n;
        while ( (i+1)/2 - 1 >= 0){
            if ( e.compareTo(heap((i+1)/2 - 1)) < 0 ) {
                swap(i, (i+1)/2 - 1);
                i = (i+1)/2 - 1;
            }
            else 
                break;
        }
        n++;
        return true;
    }

    Key extractMin() {
        if(n == 0) throw new NoSuchElementException("Priority queue underflow ");
        Key min = heap(0);
        swap(0, n-1);
        map.remove(min);
        n--;
        int j = 0, s;
        while(j <= n/2 - 1){
            if(j == n/2 -1 && n == (j+1)*2 )
                s = (j+1)*2 - 1;
            else 
                s = heap((j+1)*2 - 1).compareTo(heap((j+1)*2)) < 0 ? (j+1)*2 - 1 : (j+1)*2; 
            if(heap(j).compareTo(heap(s)) > 0 ){
                swap(j, s);
                j = s;
            }
            else break;
        }
        return min;
    }

    Key delete(Key e){
        if(!map.containsKey(e)) throw new NoSuchElementException(e+"does not exist ");
        int j = map.get(e), s;
        Key del = heap(j);
        swap(j, n-1);
        map.remove(e);
        n--;
        while( j <= n/2 - 1){
            if(j == n/2 -1 && n == (j+1)*2)
                s = (j+1)*2 - 1;
            else
                s = heap((j+1)*2 - 1).compareTo(heap((j+1)*2)) < 0 ? (j+1)*2 - 1 : (j+1)*2; 
            if(heap(j).compareTo(heap(s)) > 0 ){
                swap(j, s);
                j = s;
            }
            else break;
        }
        return del;
    }

    boolean decreasePriority(Key e){
        if(n == 0)
            return insert(e);
        if(map.containsKey(e))
            delete(e);
        return insert(e);
    }

    private void swap(int i, int j) {
        Key t = heap(i);
        heap(i) = heap(j);
        heap(j) = t;
        map.replace(heap(i), i);
        map.replace(heap(j), j);
    }

    @Override
    public String toString() {
        String res = "(";
        int i;
        for (i = 0; i < n-1; i++)
            res += heap(i) + ", ";
        res += heap(i)+")";
        return res;
    }
}

For the problem I'm working on, the program is supposed to produce the total weight of the minimum spanning tree found by applying the Prim algorithm. The input graph is a 500 knot graph and the answer obtained by this implementation is incorrect.
I'm sure the problem lies in the heap and not in my implementation of the Prim algorithm, because using the built-in priority queue in java generates the right answer.
Here is my program running the Prims algorithm.

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

class Edge{
    Key v;
    int w;
    public Edge(Key v, int w){
        this.v = v; this.w = w;
    }
    @Override
    public String toString(){
        return "("+v+","+w+")";
    }
}

class vertex implements Comparable{
    int position, dis;
    public vertex(int position){
        this.position = position;
        dis = Integer.MAX_VALUE;
    }
    @Override
    public int compareTo(vertex v) {
        if(dis > v.dis)
            return 1;
        if(dis < v.dis)
            return -1;
        return 0;
    }
    @Override
    public String toString(){
        return Integer.toString(position+1);
    }
}
public class Prims {
    public static void main(String() args) throws FileNotFoundException {
        Scanner in = new Scanner(new FileReader("prims.txt"));
        int n = in.nextInt(), m = in.nextInt();
        List>> graph = new ArrayList>>();
        List nodes = new ArrayList();
        for(int i = 0; i());
            nodes.add(new vertex(i));
        }
        while(m-- > 0){
            int u = in.nextInt()-1, v = in.nextInt()-1, w = in.nextInt();
            graph.get(u).add(new Edge(nodes.get(v), w));
            graph.get(v).add(new Edge(nodes.get(u), w));
        }
        in.close();
        long st = System.currentTimeMillis();
        System.out.println(prims(graph,nodes));
        long end = System.currentTimeMillis();
        System.out.println("Runtime = "+(end-st)+"ms");
    }
    static int prims(List>> graph, List nodes){
        int n = graph.size(), weight = 0;
        boolean() inSpanTree = new boolean(n);
        Heap pq = new Heap<>(n);
        inSpanTree(0) = true;
        for(Edge e : graph.get(0)){
            e.v.dis = e.w;
            pq.insert(e.v);
        }
        while(!pq.isEmpty()){
            vertex u = pq.extractMin();
            inSpanTree(u.position) = true;
            weight += u.dis;
            for(Edge e : graph.get(u.position)){
                if(!inSpanTree(e.v.position)){
                    if(e.v.dis > e.w){
                        e.v.dis = e.w;
                        pq.decreasePriority(nodes.get(e.v.position));
                    }
                }
            }
        }
        return weight;
    }
}

If for this same implementation I use the integrated priority queue, I get the correct output(-3612829)

static int prims(List>> graph, List nodes){
        int n = graph.size(), weight = 0;
        boolean() inSpanTree = new boolean(n);
        PriorityQueue pq = new PriorityQueue<>();
        inSpanTree(0) = true;
        for(Edge e : graph.get(0)){
            e.v.dis = e.w;
            pq.add(e.v);
        }
        System.out.println(pq);
        while(!pq.isEmpty()){
            vertex u = pq.poll();
            if(u.position == 307)
                System.out.println(pq);
            inSpanTree(u.position) = true;
            weight += u.dis;
            for(Edge e : graph.get(u.position)){
                if(!inSpanTree(e.v.position)){
                    if(e.v.dis > e.w){
                        e.v.dis = e.w;
                        pq.remove(nodes.get(e.v.position));
                        pq.add(nodes.get(e.v.position));
                    }
                }
            }
        }
        return weight;
    }

The My Heap implementation works for almost all test cases, even up to 300 nodes. I don't understand how to debug and know where the problem is.
Here is the link to the Problem entry:

https://d3c33hcgiwev3.cloudfront.net/_d4f3531eac1d289525141e95a2fea52f_edges.txt?Expires=1589673600&Signature=WSP-z481nsQgNDfN6zo0XNWy9nNTLAIty2k4HNhoQgW3pAsY0vUVaMdjg3g-UnKz9tKajuYcgGpYO3cw9H7N24tqescamo0q0n3Rykfb6BSkcI~DiKuiGpeA4gb630CU4gLAS8tDoaFRCjKNiyXAbXqHLeWhmGAmOrAnYl2rAMU_&Key-Pair-Id=APKAJLTNE6QMUY6HBC5A

Can anyone help me debug my Heap implementation, I've been stuck with this for a long time now.
Thanks in advance.

Does aperture priority on Nikon DF not work with a pre-AI lens?

I just bought a 55 / 3.5 pre-IA.

In order to use the aperture priority mode, I did this:

  1. Counter coupling lever raised
  2. On lens data without microprocessor:
    focal length: 55
    maximum aperture: F / 3.5
    exposure meter coupling: no AI

As I change the aperture, the indicator stays at F / 10. No wonder my photos are underexposed.
But with other AI / AIS lenses, the camera correctly detects the aperture of the lens. And of course, the opening priority works well.

Is there a problem with my pre-AI 55 / 3.5?

Does aperture priority on Nikon DF not work with a pre-AI lens?

I just bought a 55 / 3.5 pre-IA.

In order to use the aperture priority mode, I did this:

  1. Counter coupling lever raised
  2. On lens data without microprocessor:
    focal length: 55
    maximum aperture: F3.5
    cutting the light meter: non-AI

While I am modifying the aperture, the indicator remains blocked on F10. No wonder my photos are underexposed.
But with other AI / AIS lenses, the camera correctly detects the aperture of the lens. And of course, the opening priority works well.

Is there a problem with my pre-AI 55 / 3.5?

spanning tree implemented by a min priority queue

if it is executed on unconnected graphs, what will it execute? I thought it would not execute because it is not connected, but since it is implemented by the min priority queue, will this affect it the results?

Minimum priority queue in Pascal for Dijkstra's shortest path algorithm

I have a record with an integer representing the name of a node and an array of integers representing the possible connections to other nodes in a directed graph. I want to use dijkstra's shortest path algorithm to find the shortest path to all the other nodes given the name of one. So I have made a minimum priority queue and I want to make sure it is implemented before continuing to implement the shortest path problem. In order for the priority queue to work for the dijkstra algorithm, I had to add a priority (key) and an index (idx).

unit uMinPrioQueue;

{$MODE OBJFPC}
{$ModeSwitch advancedrecords}

interface

uses SysUtils;

type
  TIntegerArray = Array of Integer;

  TNode = record
    name, idx, key: Integer;
    edges: TIntegerArray;
    procedure Init(const aName: Integer; const aEdges: TIntegerArray);
  end;
  TNodeArray = Array of TNode;

  TMinPrioQueue = class(TObject)
  private
    nodes: TNodeArray;
    len, size: Integer;
    procedure Swap(x, y: Integer);
    function Parent(i: Integer): Integer;
    function Left(i: Integer): Integer;
    function Right(i: Integer): Integer;
    procedure Heapify(i: Integer);
  public
    constructor Create;
    procedure Insert(node: TNode; key: Integer);
    procedure DecreaseKey(node: TNode; key: Integer);
    function GetMin: TNode;
  end;

implementation

procedure  TNode.Init(const aName: Integer; const aEdges: TIntegerArray);
begin
  name := aName;  idx := -1;  key := MAXINT;  edges := aEdges;
end;

{
  The first element of nodes is nodes(1)!!
  For Left and Right methods to work we leave a position unoccupied
}
constructor TMinPrioQueue.Create;
begin
  len := 0;  size := 1;
end;

function TMinPrioQueue.Parent(i: Integer): Integer;
begin
  Result := i div 2;
end;

function TMinPrioQueue.Left(i: Integer): Integer;
begin
  Result := 2 * i;
end;

function TMinPrioQueue.Right(i: Integer): Integer;
begin
  Result := 2 * i + 1;
end;

procedure TMinPrioQueue.Swap(x, y: Integer);
var
  tmp: TNode;
begin
  tmp := nodes(x);
  nodes(x) := nodes(y);
  nodes(y) := tmp;
  nodes(x).idx := x;
  nodes(y).idx := y;
end;

procedure TMinPrioQueue.DecreaseKey(node: TNode; key: Integer);
begin
  if  key > nodes(node.idx).key  then
    raise Exception.Create('DecreaseKey: new priority is larger than current one');

  nodes(node.idx).key := key;

  (*  While the parent has less priority exchange the node with it's parent *)
  while  (node.idx > 1)  and  (nodes(Parent(node.idx)).key > nodes(node.idx).key)  do
    Swap(node.idx, Parent(node.idx));
end;

procedure TMinPrioQueue.Insert(node: TNode; key: Integer);
begin
  len := len + 1;
  if  (len >= size)  then
    size := size * 2;
  SetLength(nodes, size);
  node.idx := len;
  nodes(len) := node;
  DecreaseKey(node, key);
end;

procedure TMinPrioQueue.Heapify(i: Integer);
var
  smallest: Integer;
begin
  if  (Left(i) <= len)  and  (nodes(Left(i)).key < nodes(i).key)  then
    smallest := Left(i)
  else
    smallest := i;

  if  (Right(i) <= Len)  and  (nodes(Right(i)).key < nodes(i).key)  then
    smallest := Right(i);

  if  smallest <> i  then
  begin
    Swap(i, smallest);
    Heapify(smallest);
  end;
end;

function TMinPrioQueue.GetMin: TNode;
var
  min: TNode;
begin
  if  len < 1  then
    raise Exception.Create('GetMin: heap underflow');

  min := nodes(1);
  nodes(1) := nodes(len);
  len := len - 1;
  if  (len < size div 2)  then
    size := size div 2;
  SetLength(Nodes, size);
  Heapify(1);

  Result := min;
end;
end.

Main

program MinPrioQueueMain;

{$MODE OBJFPC}

uses
  uMinPrioQueue;

type
  TIntegerArray = Array of Integer;

function NewNode(const aName: Integer; const aEdges: TIntegerArray): TNode;
begin
  Result.Init(aName, aEdges);
end;

procedure Main;
var
  queue: TMinPrioQueue;
  node: TNode;
begin
  queue := TMinPrioQueue.Create;
  try
    queue.Insert(NewNode(0, TIntegerArray.Create(1, 2)), 10);
    queue.Insert(NewNode(1, TIntegerArray.Create(0)), 20);
    queue.Insert(NewNode(2, nil), 5);
    node := queue.GetMin;
  finally
    queue.Free;
  end;
  WriteLn('node.name=',node.name,' node.idx=',node.idx,' node.key=',node.key);
end;

begin
  Main;
end.

design – is a higher priority a lower number?

There does not seem to be an established universal standard, only standards of different regimes choosing a standard of increasing or decreasing priority. That said, a lower number being the highest priority seems to be more common. For example, the registration priority number in the U.S. Fish and Wildlife Service uses a lower number to indicate a higher priority.

Risk priority numbers use a higher number to indicate higher risk.

RPN is not a measure of risk, but a priority of risk. You would do
apply your limited resources to the most important issues. RPN
gives you a model for allocating these resources. Higher numbers are
higher priority, so you should work on an RPN of 900, before setting
resources on an RPN of 30.

A good study of the increase in priority numbers is the resolution of queuing systems with the increase in priority numbers.
Panayiotopoulos
The Journal of the Operational Research Society
Flight. 31, n ° 7 (July 1980), pp. 637-646

Basically, in the end, there is no right or wrong answer. The choice is yours – just be sure to make it clear whether you are using higher or lower numbers to indicate higher priority.

One thing to note is that if you use the lower number being the highest priority, you define a absolute priority limit or ceiling. If a new event / item arrives, which takes precedence over all previous events / items in the list, including those already at priority one, so what do you do. Demote all events / items in the list? A horrible solution. So, it might be better to use a higher number indicating higher priority. In this way, the list can always accommodate a new very high priority. That said, events / items of much lower priority may all end up being grouped into priority category one, while some will obviously have intrinsically higher priority than others also of priority one. However, this is less of a problem, as they are all of low priority and can be redefined at a later date.

operating systems – Questions regarding CPU programming algorithms (Round Robin and Priority scheduling)

Consider the following processes:

enter description of image here

1) My first question is whether we should plan them using preemptive priority planning with Round-Robin for equal process priorities with a quantum of 3. Here is my answer to this problem:

enter description of image here

Sorry for this bad drawing. My problem here is at time 13. Right now, we have two equal priority processes (p1 and p3) that we need to plan using RR with a quantum of 3. My question is what process let's start planning it here? I started with p1 because it was already executed by the CPU. Is the rest of the answer true?

2) Let us now move on to the second question. Consider that we have to plan the same process with a round-robin with a quantum of 4. I used this website to check my answer http://cpuburst.com/ and here is his answer:
enter description of image here

According to this answer, at the moment 20 p4 should be executed, but according to my answer p1 is the process which should be executed ?? And because of this difference, the rest of the answer is different from mine.

Google Sheets – How Can I Have Conditional Formatting With Lower Priority Than Manual Formatting

I know how to do the formatting I want. The document must have conditional formatting. However when I added it. He covered manual formatting.

Is there a way to say do this conditional formatting, unless I say otherwise with manual formatting?

sorting – Best algorithm for sorting tasks by priority by a human

For 300 tasks, you need to ask thousands of questions. No one is going to do it, and even if they did, the results would not be very helpful.

For situations like this, I suggest you stick to the claimants by simply assigning a factor of importance to each of their requests. If you have competing users, the software may also have a hidden user importance factor which balances the importance of each applicant.

But if users can already assign weights to their requests, why not just let them change these weights whenever they want. Give them tools they can use to meet their needs, and there will be no need for scheduled task reviews.

And don't let your system (or users) confuse "importance" with "urgency". For example, buying a birthday present for your spouse can be very important, but if their birthday is not yet 6 months old, it is not urgent. . Likewise, "come here and see what this guy is doing across the street" is very urgent (he will stop doing it soon and you will miss it), but it really is not important.