/[fenfire]/fenfire/org/fenfire/fenmm/MindNet.java
ViewVC logotype

Diff of /fenfire/org/fenfire/fenmm/MindNet.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by humppake, Sun Aug 17 19:55:01 2003 UTC revision 1.3 by humppake, Mon Aug 18 00:50:20 2003 UTC
# Line 34  package org.fenfire.fenmm; Line 34  package org.fenfire.fenmm;
34  import java.util.HashMap;  import java.util.HashMap;
35  import java.util.ArrayList;  import java.util.ArrayList;
36  import java.util.Iterator;  import java.util.Iterator;
37    import java.lang.Integer;
38    
39  public class MindNet {  public class MindNet {
40      public static final String rcsid = "";      public static final String rcsid = "";
41    
42      private final static int INITIAL_CAPACITY = 10;      private final static int INITIAL_CAPACITY = 10;
43    
44      private HashMap net = null;      private final HashMap net;
45    
46      public MindNet() {net = new HashMap(); }      private final HashMap data;
47    
48        public MindNet() {
49            net = new HashMap();
50            data = new HashMap();
51        }
52    
53      /** Check if node a has been marked to be linked with node b.      /** Check if node a has been marked to be linked with node b.
54       * @param a The first node.       * @param a The first node.
# Line 61  public class MindNet { Line 67  public class MindNet {
67       * @param a The first node.       * @param a The first node.
68       * @param b The second node.       * @param b The second node.
69       */       */
70      public void link(Object node, Object with) {      public void link(Object a, Object b) {
71          linkImpl(node, with);          linkImpl(a, b);
72          linkImpl(with, node);          linkImpl(b, a);
73        }
74    
75        public Iterator iterator() { return net.keySet().iterator(); }
76        public Iterator iterator(Object a) {
77            if (net.get(a) == null) return null;
78            else return ((ArrayList)net.get(a)).iterator();
79        }
80    
81        private void linkImpl(Object a, Object b) {
82            if (net.get(a) == null) net.put(a, new ArrayList(INITIAL_CAPACITY));
83            ((ArrayList)net.get(a)).add(b);
84        }
85    
86        public Object set(Object a, Object pl, int depth) {
87            return data.put(a, new MMNode(pl, depth));
88        }
89        
90        public MMNode get(Object a) {
91            if (data.get(a) == null) return null;
92            return (MMNode)data.get(a);
93        }
94    
95        public Object getPlace(Object a) {
96            if (data.get(a) == null) return null;
97            return ((MMNode)data.get(a)).object;
98      }      }
99    
100      private void linkImpl(Object node, Object with) {      public int  getDepth(Object a) {
101          if (net.get(node) == null) net.put(node, new ArrayList(INITIAL_CAPACITY));          if (data.get(a) == null) return -1;
102          ((ArrayList)net.get(node)).add(with);          return ((MMNode)data.get(a)).depth;
103      }      }
104  }  }

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26