01: //
02: // Copyright (C) 2005 United States Government as represented by the
03: // Administrator of the National Aeronautics and Space Administration
04: // (NASA). All Rights Reserved.
05: //
06: // This software is distributed under the NASA Open Source Agreement
07: // (NOSA), version 1.3. The NOSA has been approved by the Open Source
08: // Initiative. See the file NOSA-1.3-JPF at the top of the distribution
09: // directory tree for the complete NOSA document.
10: //
11: // THE SUBJECT SOFTWARE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY OF ANY
12: // KIND, EITHER EXPRESSED, IMPLIED, OR STATUTORY, INCLUDING, BUT NOT
13: // LIMITED TO, ANY WARRANTY THAT THE SUBJECT SOFTWARE WILL CONFORM TO
14: // SPECIFICATIONS, ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR
15: // A PARTICULAR PURPOSE, OR FREEDOM FROM INFRINGEMENT, ANY WARRANTY THAT
16: // THE SUBJECT SOFTWARE WILL BE ERROR FREE, OR ANY WARRANTY THAT
17: // DOCUMENTATION, IF PROVIDED, WILL CONFORM TO THE SUBJECT SOFTWARE.
18: //
19: package DEOS;
20:
21: /**
22: * DOCUMENT ME!
23: */
24: class DoubleLinkListNode {
25: protected DoubleLinkListNode previous;
26: protected DoubleLinkListNode next;
27:
28: protected DoubleLinkListNode() {
29: previous = null;
30: next = null;
31: }
32:
33: public boolean isOnAList() {
34: /* $$A20 */
35: return next != null;
36:
37: /* $$E20 */
38: }
39:
40: public void addAfter(DoubleLinkListNode newNode) {
41: // For some reason, the Borland 4.52 compiler was losing track of this
42: // in previous versions of this inline code, but was able to handle it
43: // if the code was not inlined. This version seems to work OK.
44:
45: /* $$A60 */
46: DoubleLinkListNode t = this ;
47: DoubleLinkListNode n = t.next;
48: DoubleLinkListNode nn = newNode;
49: nn.next = n;
50: nn.previous = t;
51: t.next = nn;
52: n.previous = nn;
53:
54: /* $$E60 */
55: }
56:
57: public void ensureNotOnList() {
58: if (isOnAList()) {
59: removeFromList();
60: }
61: }
62:
63: public DoubleLinkListNode nextNode() {
64: return next;
65: }
66:
67: public DoubleLinkListNode previousNode() {
68: return previous;
69: }
70:
71: public void removeFromList() {
72: /* $$A10 */
73:
74: // Copy "this", previous and next to locals to help compiler realize they
75: // won't change during the execution. Eliminates redundant memory
76: // references and copying.
77: //System.out.println("DoubleLinkListNode.removeFromList");
78: DoubleLinkListNode t = this ;
79: DoubleLinkListNode p = t.previous;
80: DoubleLinkListNode n = t.next;
81: n.previous = p;
82: p.next = n;
83:
84: DoubleLinkListNode zero = null;
85: t.previous = zero;
86: t.next = zero;
87:
88: /* $$E10 */
89: }
90: };
|