public void Send(ICopyable data)
{
ConnectionList cl = Node.ConnectionTable.GetConnections(ConnectionType.Structured);
// We start with the node immediately after the starting index
int start = cl.IndexOf(From);
if (start < 0)
{
start = ~start;
}
// We end with the node immediately before the end index
int end = cl.IndexOf(To);
if (end < 0)
{
end = ~end;
}
// If start >= end, because From < To or because this is a terminal
// node and there are no other entities to forward it to. So the
// second test ensures that the first entity is actually inside the
// range to forward it to.
AHAddress start_addr = cl[start].Address as AHAddress;
if (start >= end && start_addr.IsBetweenFromLeft(From, To))
{
end += cl.Count;
}
List <Connection> cons = SortByDistance(cl, start, end, Forwarders);
for (int i = 0; i < cons.Count; i++)
{
Connection con = cons[i];
int next = i + 1;
AHAddress nfrom = con.Address as AHAddress;
Address nto = To;
if (next < cons.Count)
{
nto = GetLeftNearTarget(cons[next].Address as AHAddress);
}
con.Edge.Send(new CopyList(PType, Source.ToMemBlock(),
nfrom.ToMemBlock(), nto.ToMemBlock(), _forwarders, _hops, data));
}
_sent_to = cons.Count;
}