コード例 #1
0
        public IteratableTreeNode(T value)
        {
            Value = value;

            Previous = null;
            Next     = null;
        }
コード例 #2
0
ファイル: Algorithms.Copy.cs プロジェクト: ggeurts/nhive
 public static void Copy <T, TSize, TInput, TOutput>(IIteratable <T, TSize, TInput> hive, TOutput target)
     where TInput : struct, IInputIterator <T, TSize, TInput>
     where TOutput : struct, IOutputIterator <T, TOutput>
     where TSize : struct, IConvertible
 {
     Copy <T, TSize, TInput, TOutput>(hive.Begin, hive.End, target);
 }
コード例 #3
0
        public bool Insert(int position, IIteratable <IteratableTreeNode <T> > iteratableNode)
        {
            if (Children == default)
            {
                Children = new List <ITreeNode <T> >();
            }

            if (position < 0 || position > Children.Count)
            {
                AddChild((ITreeNode <T>)iteratableNode);
                return(true);
            }

            var previous = position > 0 ? (IteratableTreeNode <T>)Children[position - 1] : null;
            var next     = position < Children.Count ? (IteratableTreeNode <T>)Children[position] : null;

            if (previous != null)
            {
                previous.Next = iteratableNode;
            }

            if (next != null)
            {
                next.Previous = iteratableNode;
            }

            iteratableNode.Previous = previous;
            iteratableNode.Next     = next;

            Children.Add((ITreeNode <T>)iteratableNode);
            return(true);
        }
コード例 #4
0
 /// <summary>
 /// Gets the first child of an group.
 /// </summary>
 /// <param name="_current">The current child element which is a group.</param>
 /// <returns>
 /// The first element of the child group if available;
 /// otherwise <c>null</c>.</returns>
 protected static IDialogComponent GetLastOfIIteratableChild(IIteratable _current)
 {
     if (_current != null && _current.HasChildren())
     {
         return(_current.GetLast());
     }
     return(null);
 }
コード例 #5
0
        /// <summary>
        /// Filters objects depending on <paramref name="predicate"/>
        /// </summary>
        /// <typeparam name="TSource"></typeparam>
        /// <param name="source"></param>
        /// <param name="predicate"></param>
        /// <returns></returns>
        public static IIteratable <TSource> Where <TSource>(this IIteratable <TSource> source, Func <TSource, bool> predicate)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }
            var ret = new WhereEnumerable <TSource>(source, predicate);

            return(ret);
        }
コード例 #6
0
        /// <summary>
        /// Uses <paramref name="func"/> on every object in <paramref name="source"/>
        /// </summary>
        /// <typeparam name="TSource"></typeparam>
        /// <param name="source"></param>
        /// <param name="func"></param>
        /// <returns></returns>
        public static IIteratable <TSource> Map <TSource>(this IIteratable <TSource> source, Func <TSource, TSource> func)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }
            var ret = new MapEnumerable <TSource>(source, func);

            return(ret);
        }
コード例 #7
0
 public static bool All <T>(this IIteratable <T> source, Func <T, bool> predicate)
 {
     foreach (var element in source)
     {
         if (!predicate(element))
         {
             return(false);
         }
     }
     return(true);
 }
コード例 #8
0
ファイル: Algorithms.Copy.cs プロジェクト: ggeurts/nhive
        internal static void Copy <T, TSize, TInput>(IIteratable <T, TSize, TInput> hive, T[] array, TSize startIndex)
            where TInput : struct, IInputIterator <T, TSize, TInput>
            where TSize : struct, IConvertible
        {
            long targetIndex = SizeOperations <TSize> .Default.ToInt64(startIndex);

            for (TInput i = hive.Begin; !i.Equals(hive.End); i.Increment())
            {
                array[targetIndex++] = i.Read();
            }
        }
コード例 #9
0
        /// <summary>
        /// Conerts <typeparamref name="IIteratable"/> <paramref name="source"/> to <typeparamref name="TSource"/> array
        /// </summary>
        /// <typeparam name="TSource"></typeparam>
        /// <param name="source"></param>
        /// <returns></returns>
        public static TSource[] ToArray <TSource>(this IIteratable <TSource> source)
        {
            TSource[] ret = new TSource[source.Count()];
            int       i   = 0;

            foreach (TSource item in source)
            {
                ret[i] = item;
                i++;
            }
            return(ret);
        }
コード例 #10
0
        private void ConnectPreviousAndNextNodes(IIteratable <IteratableTreeNode <T> > previous, IIteratable <IteratableTreeNode <T> > next)
        {
            if (previous != null)
            {
                previous.Next = next;
            }

            if (next != null)
            {
                next.Previous = previous;
            }
        }
コード例 #11
0
 /// <summary>
 /// Returns first object in <paramref name="source"/> which satisfies the <paramref name="predicate"/>
 /// </summary>
 /// <typeparam name="TSource"></typeparam>
 /// <param name="source"></param>
 /// <param name="predicate"></param>
 /// <returns></returns>
 public static TSource FirstOrDefault <TSource>(this IIteratable <TSource> source, Func <TSource, bool> predicate)
 {
     if (source == null)
     {
         throw new ArgumentNullException("source");
     }
     foreach (TSource item in source)
     {
         if (predicate(item))
         {
             return(item);
         }
     }
     return(default);
コード例 #12
0
        /// <summary>
        /// Returns number of objects in <paramref name="source"/>
        /// </summary>
        /// <typeparam name="TSource"></typeparam>
        /// <param name="source"></param>
        /// <returns></returns>
        public static int Count <TSource>(this IIteratable <TSource> source)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }
            int cnt = 0;

            foreach (TSource item in source)
            {
                cnt++;
            }
            return(cnt);
        }
コード例 #13
0
 /// <summary>
 /// Returns true if at least one object in <paramref name="source"/> satisfies the <paramref name="predicate"/>
 /// </summary>
 /// <typeparam name="TSource"></typeparam>
 /// <param name="source"></param>
 /// <param name="predicate"></param>
 /// <returns></returns>
 public static bool Some <TSource>(this IIteratable <TSource> source, Func <TSource, bool> predicate)
 {
     if (source == null)
     {
         throw new ArgumentNullException("source");
     }
     foreach (TSource item in source)
     {
         if (predicate(item))
         {
             return(true);
         }
     }
     return(false);
 }
コード例 #14
0
 /// <summary>
 /// Gets the next child of an group.
 /// </summary>
 /// <param name="_current">The current child element which is a group.</param>
 /// <returns>
 /// The next element of the child group if available;
 /// otherwise the first element if available;
 /// otherwise <c>null</c>.</returns>
 protected static IDialogComponent GetNextOfIIteratableChild(IIteratable _current)
 {
     if (_current != null && _current.HasChildren())
     {
         var next = _current.GetNext();
         if (next != null)
         {
             return(next);
         }
         else
         {
             next = _current.GetFirst();
             if (next != null)
             {
                 return(next);
             }
         }
     }
     return(null);
 }
コード例 #15
0
 /// <summary>
 /// Gets the previous child of an group.
 /// </summary>
 /// <param name="_current">The current child element which is a group.</param>
 /// <returns>
 /// The previous element of the child group if available;
 /// otherwise the last element if available;
 /// otherwise <c>null</c>.</returns>
 protected static IDialogComponent GetPreviouseOfIIteratableChild(IIteratable _current)
 {
     if (_current != null && _current.HasChildren())
     {
         var prev = _current.GetPrevious();
         if (prev != null)
         {
             return(prev);
         }
         else
         {
             prev = _current.GetLast();
             if (prev != null)
             {
                 return(prev);
             }
         }
     }
     return(null);
 }
コード例 #16
0
ファイル: ConcatEnumerable.cs プロジェクト: D0nya/CustomLINQ
 public ConcatEnumerable(IIteratable <TSource> first, IIteratable <TSource> second)
 {
     iteratables    = new IIteratable <TSource> [2];
     iteratables[0] = first;
     iteratables[1] = second;
 }
コード例 #17
0
 public static Range <T, TSize, TIterator> Enumerate <T, TSize, TIterator>(IIteratable <T, TSize, TIterator> hive)
     where TIterator : struct, IInputIterator <T, TSize, TIterator>
     where TSize : struct, IConvertible
 {
     return(new Range <T, TSize, TIterator>(hive));
 }
コード例 #18
0
 public void Add(IIteratable act)
 {
     Then = act;
 }
コード例 #19
0
 public MapEnumerator(IIteratable <T> sourceIteratable, Func <T, S> selector)
 {
     _sourceIteratable  = sourceIteratable;
     _sourceIEnumerator = sourceIteratable.GetEnumerator();
     _selector          = selector;
 }
コード例 #20
0
 public ConsoleRadioBoxElement(ConsoleRadioBox parent, string text, ConsoleColor color)
 {
     Parent = parent;
     Text   = text;
     Color  = color;
 }
コード例 #21
0
 public static IIteratable <T> Filter <T>(this IIteratable <T> source, Func <T, bool> predicate)
 {
     return(new WhereEnumerator <T>(source, predicate));
 }
コード例 #22
0
 public static IIteratable <S> Map <T, S>(this IIteratable <T> source, Func <T, S> selector)
 {
     return(new MapEnumerator <T, S>(source, selector));
 }
コード例 #23
0
 public void AddRouter(IRouterStatus RouterStatus, IIteratable Iterator)
 {
     Routers.Add(RouterStatus);
     IterableRouters.Add(Iterator);
 }
コード例 #24
0
ファイル: WhereEnumerable.cs プロジェクト: D0nya/CustomLINQ
 public WhereEnumerable(IIteratable <TSource> source, Func <TSource, bool> func)
 {
     this.source = source;
     this.func   = func;
 }
コード例 #25
0
 public WhereEnumerator(IIteratable <T> sourceIteratable, Func <T, bool> predicate)
 {
     _sourceIteratable  = sourceIteratable;
     _sourceIEnumerator = sourceIteratable.GetEnumerator();
     _predicate         = predicate;
 }
コード例 #26
0
 public HiveEnumerator(IIteratable <T, TSize, TIterator> hive)
     : this(hive.Begin, hive.End)
 {
 }
コード例 #27
0
 public MapEnumerable(IIteratable <TSource> source, Func <TSource, TSource> func)
 {
     this.source = source;
     this.func   = func;
 }
コード例 #28
0
 public Range(IIteratable <T, TSize, TIterator> hive)
 {
     _begin = hive.Begin;
     _end   = hive.End;
 }
コード例 #29
0
 public void AddRouter(IRouterStatus RouterStatus, IIteratable Iterator)
 {
     Routers.Add(RouterStatus);
     IterableRouters.Add(Iterator);
 }
コード例 #30
0
 public void Add(IIteratable act)
 {
     Meths.Add(act);
 }
コード例 #31
0
 public SelectEnumerable(IIteratable <TSource> source, Func <TSource, TRetrun> selector)
 {
     this.source   = source;
     this.selector = selector;
 }