4 * Copyright (c) 2007, The University of Manchester (UK)
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
12 * - Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * - Redistributions in binary form must reproduce the above
15 * copyright notice, this list of conditions and the following
16 * disclaimer in the documentation and/or other materials provided
17 * with the distribution.
18 * - Neither the name of the University of Manchester nor the names
19 * of its contributors may be used to endorse or promote products
20 * derived from this software without specific prior written
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 public class WorkQueue {
38 public int x1, y1, x2, y2, nn;
40 public WorkQueue next;
46 WorkQueue(int xx1, int yy1, int xx2, int yy2, int n) {
54 public WorkQueue enQueue(int x1, int y1, int x2, int y2, int n) {
55 WorkQueue q = new WorkQueue(x1, y1, x2, y2, n);
60 public WorkQueue deQueue() {
61 WorkQueue q = this.next;
62 this.next = this.next.next;
66 public boolean less(int xx1, int yy1, int xx2, int yy2) {
67 return (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1) > (xx2 - xx1)
68 * (xx2 - xx1) + (yy2 - yy1) * (yy2 - yy1);
71 public boolean pass() {
74 WorkQueue a = ent.next;
75 while (a.next != null) {
77 if (a.less(b.x1, b.y1, b.x2, b.y2)) {
86 // System.out.print("#");
96 public WorkQueue enQueue(WorkQueue q) {
97 WorkQueue n = new WorkQueue(q.x1, q.y1, q.x2, q.y2, q.nn);
102 public int length() {
103 WorkQueue curr = this.next;