public PartitionBlockInterval[] ConvertToPartitionBlockIntervals(IUniqueIdentificationSet set) { PartitionBlockInterval[] intervals = null; set.__Access(segments => { intervals = segments.Select(segment => new PartitionBlockInterval(segment.low, segment.high + 1)).ToArray(); }); return intervals; }
public IUniqueIdentificationSet Intersect(IUniqueIdentificationSet setInput) { // [1 5] [10 16] [18 22] // [12] [4 6] [9 12] [15 20] var set = new UniqueIdentificationSet(false).With(x => setInput.__Access(x.__Assign)); lock (m_lock) { var resultList = new LinkedList <Segment>(); var leftCurrent = m_segments.First; var rightCurrent = set.m_segments.First; while (leftCurrent != null && rightCurrent != null) { var intersects = !(leftCurrent.Value.high <rightCurrent.Value.low || leftCurrent.Value.low> rightCurrent.Value.high); if (intersects) { resultList.AddLast(new Segment { low = Math.Max(leftCurrent.Value.low, rightCurrent.Value.low), high = Math.Min(leftCurrent.Value.high, rightCurrent.Value.high) }); } if (leftCurrent.Value.high < rightCurrent.Value.high) { leftCurrent = leftCurrent.Next; } else { rightCurrent = rightCurrent.Next; } } return(new UniqueIdentificationSet(false).With(x => x.__Assign(resultList))); } }
public HostSessionImpl(HostContext hostContext, ICancellationTokenSource cancellationTokenSource, MessageSender messageSender, PofDispatcher pofDispatcher, IConcurrentSet <Guid> remotelyHostedServices, IUniqueIdentificationSet availableInvocationIds, IConcurrentDictionary <uint, AsyncValueBox> invocationResponseBoxesById) { this.hostContext = hostContext; this.cancellationTokenSource = cancellationTokenSource; this.messageSender = messageSender; this.pofDispatcher = pofDispatcher; this.remotelyHostedServices = remotelyHostedServices; this.availableInvocationIds = availableInvocationIds; this.invocationResponseBoxesById = invocationResponseBoxesById; }
public GuestPhase(ClusteringPhaseFactory clusteringPhaseFactory, LocalServiceContainer localServiceContainer, ClusteringPhaseManager clusteringPhaseManager, MessageSender messageSender, PofDispatcher pofDispatcher, IUniqueIdentificationSet availableInvocationIds, IConcurrentDictionary <uint, AsyncValueBox> invocationResponseBoxesById) { this.clusteringPhaseFactory = clusteringPhaseFactory; this.localServiceContainer = localServiceContainer; this.clusteringPhaseManager = clusteringPhaseManager; this.messageSender = messageSender; this.pofDispatcher = pofDispatcher; this.availableInvocationIds = availableInvocationIds; this.invocationResponseBoxesById = invocationResponseBoxesById; }
public IUniqueIdentificationSet Except(IUniqueIdentificationSet removedSetInput) { var result = new UniqueIdentificationSet(false).With(x => this.__Access(x.__Assign)); var removedSet = new UniqueIdentificationSet(false).With(x => removedSetInput.__Access(x.__Assign)); removedSet.__Access(removedSegments => { foreach (var segment in removedSegments) { result.TakeRange(segment.low, segment.high); } }); return(result); }
public IUniqueIdentificationSet Merge(IUniqueIdentificationSet otherInput) { // clone other to prevent deadlock UniqueIdentificationSet other = new UniqueIdentificationSet(false); otherInput.__Access(other.__Assign); var results = new LinkedList <Segment>(); other.__Access(otherSegments => { lock (m_lock) { Segment currentSegment = null; foreach (var segment in MergeHelper_OrderSegmentsByLower(m_segments, otherSegments)) { if (currentSegment == null) { currentSegment = segment; } else { if (currentSegment.high != UInt32.MaxValue && currentSegment.high + 1 >= segment.low) { currentSegment.high = Math.Max(currentSegment.high, segment.high); } else { results.AddLast(currentSegment); currentSegment = new Segment { low = segment.low, high = segment.high }; } } } if (currentSegment != null) { results.AddLast(currentSegment); } } }); return(new UniqueIdentificationSet(false).With(uidSet => uidSet.__Assign(results))); }
public IUniqueIdentificationSet Intersect(IUniqueIdentificationSet setInput) { // [1 5] [10 16] [18 22] // [12] [4 6] [9 12] [15 20] var set = new UniqueIdentificationSet(false).With(x => setInput.__Access(x.__Assign)); lock (m_lock) { var resultList = new LinkedList<Segment>(); var leftCurrent = m_segments.First; var rightCurrent = set.m_segments.First; while (leftCurrent != null && rightCurrent != null) { var intersects = !(leftCurrent.Value.high < rightCurrent.Value.low || leftCurrent.Value.low > rightCurrent.Value.high); if (intersects) { resultList.AddLast(new Segment { low = Math.Max(leftCurrent.Value.low, rightCurrent.Value.low), high = Math.Min(leftCurrent.Value.high, rightCurrent.Value.high) }); } if (leftCurrent.Value.high < rightCurrent.Value.high) { leftCurrent = leftCurrent.Next; } else { rightCurrent = rightCurrent.Next; } } return new UniqueIdentificationSet(false).With(x => x.__Assign(resultList)); } }
public IUniqueIdentificationSet Except(IUniqueIdentificationSet removedSetInput) { var result = new UniqueIdentificationSet(false).With(x => this.__Access(x.__Assign)); var removedSet = new UniqueIdentificationSet(false).With(x => removedSetInput.__Access(x.__Assign)); removedSet.__Access(removedSegments => { foreach (var segment in removedSegments) { result.TakeRange(segment.low, segment.high); } }); return result; }
public IUniqueIdentificationSet Merge(IUniqueIdentificationSet otherInput) { // clone other to prevent deadlock UniqueIdentificationSet other = new UniqueIdentificationSet(false); otherInput.__Access(other.__Assign); var results = new LinkedList<Segment>(); other.__Access(otherSegments => { lock (m_lock) { Segment currentSegment = null; foreach (var segment in MergeHelper_OrderSegmentsByLower(m_segments, otherSegments)) { if (currentSegment == null) { currentSegment = segment; } else { if (currentSegment.high != UInt32.MaxValue && currentSegment.high + 1 >= segment.low) { currentSegment.high = Math.Max(currentSegment.high, segment.high); } else { results.AddLast(currentSegment); currentSegment = new Segment { low = segment.low, high = segment.high }; } } } if (currentSegment != null) { results.AddLast(currentSegment); } } }); return new UniqueIdentificationSet(false).With(uidSet => uidSet.__Assign(results)); }