Ejemplo n.º 1
0
 void testPriorityQueue()
 {
     Vector2[] vs = { new Vector2(0, 1), new Vector2(0, 3), new Vector2(0, 4), new Vector2(0, 2), new Vector2(0, 5),Vector2.zero };
     Comparison<Vector2> cmp = (v1, v2) => {
         float dist = (Vector2.zero - v1).sqrMagnitude - (Vector2.zero - v2).sqrMagnitude;
         //Debug.LogFormat("v1:{0} v2:{1} D:{2}",v1,v2,dist);
         return Mathf.RoundToInt(dist);
     };
     PriorityQueue<Vector2> pq = new PriorityQueue<Vector2>(cmp);
     pq.push(vs);
     Debug.Log(pq.showBuffer());
     int i = 0;
     while (pq.Count != 0) {
         Debug.LogFormat("[{1}]:{0}",pq.pop(),i++);
     }
 }