Brunet.Symphony.AHAddress.IsBetweenFromLeft C# (CSharp) Метод

IsBetweenFromLeft() публичный Метод

public IsBetweenFromLeft ( AHAddress start, AHAddress end ) : bool
start AHAddress
end AHAddress
Результат bool
    public bool IsBetweenFromLeft(AHAddress start, AHAddress end) {
      int se_comp = start.CompareTo(end);
      //simple case of no wrap around where "within" is greater
      if (se_comp < 0) {
	return start.CompareTo(this) < 0 && this.CompareTo(end) < 0;
      }
      else if( se_comp == 0 ) {
        //When start == end, nothing is between them
        return false;
      }
      else {
        //in case there is a wrap around
        //"within" has become lesser than "this"
        return start.CompareTo(this) < 0 || this.CompareTo(end) < 0;
      }
    }
    

Usage Example

Пример #1
0
        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;
        }
All Usage Examples Of Brunet.Symphony.AHAddress::IsBetweenFromLeft