Beispiel #1
0
 public LinkIndex Each(Func <IList <LinkIndex>, LinkIndex> handler, IList <LinkIndex> restrictions)
 {
     return(_sync.ExecuteReadOperation(() =>
     {
         if (restrictions.IsNullOrEmpty())
         {
             return Constants.Continue;
         }
         Links.EnsureInnerReferenceExists(restrictions, nameof(restrictions));
         if (restrictions.Count == 1)
         {
             var link = restrictions[0];
             var any = Constants.Any;
             if (link == any)
             {
                 if (Options.UseSequenceMarker)
                 {
                     return Links.Unsync.Each(handler, new Link <LinkIndex>(any, Options.SequenceMarkerLink, any));
                 }
                 else
                 {
                     return Links.Unsync.Each(handler, new Link <LinkIndex>(any, any, any));
                 }
             }
             if (Options.UseSequenceMarker)
             {
                 var sequenceLinkValues = Links.Unsync.GetLink(link);
                 if (sequenceLinkValues[Constants.SourcePart] == Options.SequenceMarkerLink)
                 {
                     link = sequenceLinkValues[Constants.TargetPart];
                 }
             }
             var sequence = Options.Walker.Walk(link).ToArray().ShiftRight();
             sequence[0] = link;
             return handler(sequence);
         }
         else if (restrictions.Count == 2)
         {
             throw new NotImplementedException();
         }
         else if (restrictions.Count == 3)
         {
             return Links.Unsync.Each(handler, restrictions);
         }
         else
         {
             var sequence = restrictions.SkipFirst();
             if (Options.UseIndex && !Options.Index.MightContain(sequence))
             {
                 return Constants.Break;
             }
             return EachCore(handler, sequence);
         }
     }));
 }
Beispiel #2
0
 public LinkIndex Compact(IList <LinkIndex> sequence)
 {
     return(_sync.ExecuteWriteOperation(() =>
     {
         if (sequence.IsNullOrEmpty())
         {
             return Constants.Null;
         }
         Links.EnsureInnerReferenceExists(sequence, nameof(sequence));
         return CompactCore(sequence);
     }));
 }
Beispiel #3
0
 public LinkIndex Create(IList <LinkIndex> restrictions)
 {
     return(_sync.ExecuteWriteOperation(() =>
     {
         if (restrictions.IsNullOrEmpty())
         {
             return Constants.Null;
         }
         Links.EnsureInnerReferenceExists(restrictions, nameof(restrictions));
         return CreateCore(restrictions);
     }));
 }