public static ISingleLinkedList <ContextData> RecombineContext(ISingleLinkedList <ControllerContextData> source) { ISingleLinkedList <ContextData> ApplyAction(ControllerContextData action, ISingleLinkedList <ContextData> appliedContext) { ISingleLinkedList <ContextData> Subtracted() => appliedContext.Where(c => !action.СontextData.Equals(c)); switch (action.ContextBuildActionType) { case Add: return(SingleLinkedList(action.СontextData, appliedContext)); case Remove: return(Subtracted()); case Erasure: return(SingleLinkedList(action.СontextData, Subtracted())); default: throw new IndexOutOfRangeException(); } } return(source.Catamorphism( node: ApplyAction, empty: Empty <ContextData>)); }
public static ContextData GetCommentsTarget( this ISingleLinkedList <ContextData> context) { var result = context.SkipWhile(c => ContextExtensions.ExactScalar(c.Type, ContextType.Comment)); return(result.Value); }
public static bool StartsWithCommentsSequence( this ISingleLinkedList <ContextData> context, out Guid topCommentId, out ISingleLinkedList <ContextData> comments, out ContextData commentsTarget, out ISingleLinkedList <ContextData> tail) { var(commentsResult, rest) = context.Span(c => ContextExtensions.ExactScalar(c.Type, ContextType.Comment)); if (commentsResult.Any()) { topCommentId = commentsResult.Value.EntityId.Value; comments = commentsResult.Tail; commentsTarget = rest.Value; tail = rest.Tail; return(true); } topCommentId = Guid.Empty; comments = null; commentsTarget = null; tail = null; return(false); }
TResult CatamorphismRec(ISingleLinkedList <ContextData> node) => node.Match( Case(ContextType.Any, (contextData, subContext) => cases .First(caseFunc => caseFunc.contextType.HasFlag(contextData.Type)) .caseFunc(contextData, CatamorphismRec(subContext))), Case(ContextType.Empty, (x, y) => empty()));
public static bool StartsWith( this ISingleLinkedList <ContextData> context, Enum firstPtr, out ContextData first) { if (context != null && context.Value.StartsWith(firstPtr)) { first = context.Value; return(true); } first = null; return(false); }
public static bool StartsWith( this ISingleLinkedList <ContextData> context, Enum firstPtr, out ContextData first, out ISingleLinkedList <ContextData> tail) { if (context.StartsWith(firstPtr, out first)) { tail = context.Tail; return(true); } tail = null; return(true); }
public static bool StartsWith( this ISingleLinkedList <ContextData> context, Enum firstPtr, Enum secondPtr, out ContextData first, out ContextData second, out ISingleLinkedList <ContextData> tail) { if (context.StartsWith(firstPtr, out first, out var rest) && rest.StartsWith(secondPtr, out second, out tail)) { return(true); } first = null; second = null; tail = null; return(false); }
public ISingleLinkedList <T> InsertionSort(ISingleLinkedList <T> list) { throw new NotImplementedException(); }
public static bool StartsWith( this ISingleLinkedList <ContextData> context, Enum firstPtr) => context.StartsWith(firstPtr, out _);
public AddLikeCommand(ISingleLinkedList <ContextData> context, Guid author) : base(context, author) { }
public EditCommentCommand(ISingleLinkedList <ContextData> context, CommentEditDto editDto) : base(context) { EditDto = editDto; }
public LinkedQueue() { _list = new SingleLinkedList <Item>(); }
public LinkedStack() { _list = new SingleLinkedList <Item>(); }
public RemoveCommentCommand(ISingleLinkedList <ContextData> context, Guid commentId) : base(context) { CommentId = commentId; }
public AddCommentCommand(ISingleLinkedList <ContextData> context, CommentCreateDto createDto) : base(context) { CreateDto = createDto; }
public ISingleLinkedList <T> MergeSort(ISingleLinkedList <T> list, int leftIndex, int rightIndex) { throw new NotImplementedException(); }
protected LikeCommand(ISingleLinkedList <ContextData> context, Guid author) { Context = context; Author = author; }
public static TResult Catamorphism <TResult>( this ISingleLinkedList <ContextData> context, Func <TResult> empty, params (Enum contextType, Func <ContextData, TResult, TResult> caseFunc)[] cases)
protected CommentCommand(ISingleLinkedList <ContextData> context) { Context = context; }
public bool BinarySearch(ISingleLinkedList <T> list, T target) { throw new NotImplementedException(); }