Example #1
0
        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>));
        }
Example #2
0
        public static ContextData GetCommentsTarget(
            this ISingleLinkedList <ContextData> context)
        {
            var result = context.SkipWhile(c => ContextExtensions.ExactScalar(c.Type, ContextType.Comment));

            return(result.Value);
        }
Example #3
0
        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()));
Example #5
0
        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);
        }
Example #6
0
        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);
        }
Example #7
0
        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();
 }
Example #9
0
 public static bool StartsWith(
     this ISingleLinkedList <ContextData> context,
     Enum firstPtr) =>
 context.StartsWith(firstPtr, out _);
Example #10
0
 public AddLikeCommand(ISingleLinkedList <ContextData> context, Guid author) : base(context, author)
 {
 }
Example #11
0
 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;
 }
Example #15
0
 public AddCommentCommand(ISingleLinkedList <ContextData> context, CommentCreateDto createDto) : base(context)
 {
     CreateDto = createDto;
 }
Example #16
0
 public ISingleLinkedList <T> MergeSort(ISingleLinkedList <T> list, int leftIndex, int rightIndex)
 {
     throw new NotImplementedException();
 }
Example #17
0
 protected LikeCommand(ISingleLinkedList <ContextData> context, Guid author)
 {
     Context = context;
     Author  = author;
 }
Example #18
0
 public static TResult Catamorphism <TResult>(
     this ISingleLinkedList <ContextData> context,
     Func <TResult> empty,
     params (Enum contextType, Func <ContextData, TResult, TResult> caseFunc)[] cases)
Example #19
0
 protected CommentCommand(ISingleLinkedList <ContextData> context)
 {
     Context = context;
 }
 public bool BinarySearch(ISingleLinkedList <T> list, T target)
 {
     throw new NotImplementedException();
 }