コード例 #1
0
        public Zen <Option <SimplePacket> > Forward(int[] path, Zen <SimplePacket> p, Zen <IList <Tuple <int, int> > > failedLinks)
        {
            Zen <Option <SimplePacket> > x = Some(p);

            for (int i = 0; i < path.Length - 1; i++)
            {
                var currNode = nodes[path[i]];
                var nextNode = nodes[path[i + 1]];

                // want to use path[i], path[i+1] to check failedLinks to see if link between them is failed. Use this condition to set x
                var linkOK = Not(Or(failedLinks.Contains(new Tuple <int, int>(path[i], path[i + 1])), failedLinks.Contains(new Tuple <int, int>(path[i + 1], path[i]))));
                x = If(linkOK, x, Null <SimplePacket>());
                x = If(x.HasValue(), currNode.ForwardInAndOut(x.Value(), nextNode.Address), x);
            }
            return(x);
        }