@@ -26,11 +26,6 @@ public void registerRequiredSlots(Neuron input) {
2626 }
2727
2828
29- private static void collectNotAncestorOf (List <Activation > results , INeuron n , Activation linkedAct ) {
30-
31- }
32-
33-
3429 private static void collectCommonAncestor (Collection <Activation > results , INeuron n , Activation linkedAct , long v ) {
3530 if (linkedAct .visited == v ) return ;
3631
@@ -111,15 +106,15 @@ private static void markAncestors(Activation act, long v) {
111106 }
112107
113108
114- private static void markDescendant (Activation act , long v ) {
109+ private static void markDescendants (Activation act , long v ) {
115110 if (act .visited == v ) return ;
116111 act .visited = v ;
117112
118113 act .markedAncDesc = v ;
119114
120- act .getInputLinks ( false , false )
115+ act .getOutputLinks ( false )
121116 .filter (l -> l .synapse .identity )
122- .forEach (l -> markDescendant (l .input , v ));
117+ .forEach (l -> markDescendants (l .input , v ));
123118 }
124119
125120
@@ -258,8 +253,12 @@ public boolean test(Activation act, Activation linkedAct) {
258253
259254 @ Override
260255 public Stream <Activation > getActivations (INeuron n , Activation linkedAct ) {
261- List <Activation > results = new ArrayList <>();
262- return results .stream ();
256+ long v = linkedAct .doc .visitedCounter ++;
257+ markDescendants (linkedAct , v );
258+
259+ INeuron .ThreadState th = n .getThreadState (linkedAct .doc .threadId , false );
260+ return th .getActivations ()
261+ .filter (act -> act .markedAncDesc != v );
263262 }
264263 }
265264
@@ -288,9 +287,12 @@ public boolean test(Activation act, Activation linkedAct) {
288287
289288 @ Override
290289 public Stream <Activation > getActivations (INeuron n , Activation linkedAct ) {
291- List <Activation > results = new ArrayList <>();
292- collectNotAncestorOf (results , n , linkedAct );
293- return results .stream ();
290+ long v = linkedAct .doc .visitedCounter ++;
291+ markAncestors (linkedAct , v );
292+
293+ INeuron .ThreadState th = n .getThreadState (linkedAct .doc .threadId , false );
294+ return th .getActivations ()
295+ .filter (act -> act .markedAncDesc != v );
294296 }
295297 }
296298}
0 commit comments