Exemplo n.º 1
0
 public static bool IsPartialPoint <TLinkAddress, TConstants>(this ILinks <TLinkAddress, TConstants> links, TLinkAddress link)
     where TConstants : LinksConstants <TLinkAddress>
 {
     if (links.Constants.IsExternalReference(link))
     {
         return(true);
     }
     links.EnsureLinkExists(link);
     return(Point <TLinkAddress> .IsPartialPoint(links.GetLink(link)));
 }
Exemplo n.º 2
0
        public static TLink GetByKeys <TLink>(this ILinks <TLink> links, TLink root, params int[] path)
        {
            links.EnsureLinkExists(root, "root");
            var currentLink = root;

            for (var i = 0; i < path.Length; i++)
            {
                currentLink = links.GetLink(currentLink)[path[i]];
            }
            return(currentLink);
        }
Exemplo n.º 3
0
        public static TLink GetSquareMatrixSequenceElementByIndex <TLink>(this ILinks <TLink> links, TLink root, ulong size, ulong index)
        {
            var constants = links.Constants;
            var source    = constants.SourcePart;
            var target    = constants.TargetPart;

            if (!Platform.Numbers.Math.IsPowerOfTwo(size))
            {
                throw new ArgumentOutOfRangeException(nameof(size), "Sequences with sizes other than powers of two are not supported.");
            }
            var path   = new BitArray(BitConverter.GetBytes(index));
            var length = Bit.GetLowestPosition(size);

            links.EnsureLinkExists(root, "root");
            var currentLink = root;

            for (var i = length - 1; i >= 0; i--)
            {
                currentLink = links.GetLink(currentLink)[path[i] ? target : source];
            }
            return(currentLink);
        }