public static OutputIterator <T> UniqueCopy <T>(InputIterator <T> begin, InputIterator <T> end, OutputIterator <T> dest, IEqualityComparer <T> comparer) { if (begin.Equals(end)) { return(null); } begin = IteratorUtil.Clone(begin); dest = IteratorUtil.Clone(dest); T t = begin.Read(); dest.Write(t); dest.MoveNext(); begin.MoveNext(); for (; !begin.Equals(end); begin.MoveNext()) { T next = begin.Read(); if (!comparer.Equals(t, next)) { t = next; dest.Write(next); dest.MoveNext(); } } return(dest); }
public static void Merge <T>(InputIterator <T> begin1, InputIterator <T> end1, InputIterator <T> begin2, InputIterator <T> end2, OutputIterator <T> dest, Functional.BinaryPredicate <T> func) { T t1, t2; begin1 = IteratorUtil.Clone(begin1); begin2 = IteratorUtil.Clone(begin2); dest = IteratorUtil.Clone(dest); for (; !begin1.Equals(end1) && !begin2.Equals(end2); dest.MoveNext()) { t1 = begin1.Read(); t2 = begin2.Read(); bool less = func(t1, t2); if (less) { dest.Write(t1); begin1.MoveNext(); } else { dest.Write(t2); begin2.MoveNext(); } } Copy(begin1, end1, dest); Copy(begin2, end2, dest); }
public static void Merge <T>(InputIterator <T> begin1, InputIterator <T> end1, InputIterator <T> begin2, InputIterator <T> end2, OutputIterator <T> dest, IComparer <T> comp) { T t1, t2; begin1 = IteratorUtil.Clone(begin1); begin2 = IteratorUtil.Clone(begin2); dest = IteratorUtil.Clone(dest); for (; !begin1.Equals(end1) && !begin2.Equals(end2); dest.MoveNext()) { t1 = begin1.Read(); t2 = begin2.Read(); int compare = comp.Compare(t1, t2); if (compare == -1) { dest.Write(t1); begin1.MoveNext(); } else { dest.Write(t2); begin2.MoveNext(); } } Copy(begin1, end1, dest); Copy(begin2, end2, dest); }
public static OutputIterator <T> UniqueCopy <T>(InputIterator <T> begin, InputIterator <T> end, OutputIterator <T> dest, Functional.BinaryPredicate <T> func) { if (begin.Equals(end)) { return(null); } begin = IteratorUtil.Clone(begin); dest = IteratorUtil.Clone(dest); T t = begin.Read(); dest.Write(t); dest.MoveNext(); begin.MoveNext(); for (; !begin.Equals(end); begin.MoveNext()) { T next = begin.Read(); if (!func(t, next)) { t = next; dest.Write(next); dest.MoveNext(); } } return(dest); }
public static void ReplaceCopy <T>(InputIterator <T> begin, InputIterator <T> end, OutputIterator <T> dest, T oldValue, T newValue, IEqualityComparer <T> comparer) { for (begin = IteratorUtil.Clone(begin), dest = IteratorUtil.Clone(dest); !begin.Equals(end); begin.MoveNext(), dest.MoveNext()) { T srcValue = begin.Read(); if (comparer.Equals(oldValue, srcValue)) { dest.Write(newValue); } else { dest.Write(srcValue); } } }
public static void GenerateN <T>(OutputIterator <T> begin, int count, Functional.GenFunction <T> func) { for (begin = IteratorUtil.Clone(begin); count > 0; --count, begin.MoveNext()) { begin.Write(func()); } }
public static OutputIterator <T> FillN <T>(OutputIterator <T> begin, int count, T value) { for (begin = IteratorUtil.Clone(begin); count > 0; --count, begin.MoveNext()) { begin.Write(value); } return(begin); }
public static OutputIterator <O> Transform <I, O>(InputIterator <I> begin, InputIterator <I> end, OutputIterator <O> dest, Functional.UnaryFunction <I, O> func) { for (begin = IteratorUtil.Clone(begin), dest = IteratorUtil.Clone(dest); !begin.Equals(end); begin.MoveNext(), dest.MoveNext()) { dest.Write(func(begin.Read())); } return(dest); }
public static void CopyN <T>(InputIterator <T> begin, uint count, OutputIterator <T> target) { for (begin = IteratorUtil.Clone(begin), target = IteratorUtil.Clone(target); count > 0; --count) { target.Write(begin.Read()); begin.MoveNext(); target.MoveNext(); } }
public static OutputIterator <O> Transform <I, O>(IEnumerable <I> enumerable, OutputIterator <O> dest, Functional.UnaryFunction <I, O> func) { IEnumerator <I> enumerator = enumerable.GetEnumerator(); for (dest = IteratorUtil.Clone(dest); enumerator.MoveNext(); dest.MoveNext()) { dest.Write(func(enumerator.Current)); } return(dest); }
public static void ReplaceCopyIf <T>(InputIterator <T> begin, InputIterator <T> end, OutputIterator <T> dest, Functional.UnaryPredicate <T> func, T newValue) { for (begin = IteratorUtil.Clone(begin), dest = IteratorUtil.Clone(dest); !begin.Equals(end); begin.MoveNext(), dest.MoveNext()) { if (func(begin.Read())) { dest.Write(newValue); } } }
public static OutputIterator <T> Copy <T>(IEnumerable <T> enumerable, OutputIterator <T> target) { target = IteratorUtil.Clone(target); foreach (T t in enumerable) { target.Write(t); target.MoveNext(); } return(target); }
public static OutputIterator <T> Copy <T>(InputIterator <T> begin, InputIterator <T> end, OutputIterator <T> target) { for (begin = IteratorUtil.Clone(begin), target = IteratorUtil.Clone(target); !begin.Equals(end); begin.MoveNext(), target.MoveNext()) { target.Write(begin.Read()); } return(target); }
public static OutputIterator <O> Transform <I, O>(InputIterator <I> begin1, InputIterator <I> end1, InputIterator <I> begin2, OutputIterator <O> dest, Functional.BinaryFunction <I, I, O> func) { begin1 = IteratorUtil.Clone(begin1); begin2 = IteratorUtil.Clone(begin2); dest = IteratorUtil.Clone(dest); for (; !begin1.Equals(end1); begin1.MoveNext(), begin2.MoveNext(), dest.MoveNext()) { dest.Write(func(begin1.Read(), begin2.Read())); } return(dest); }
public static void ReverseCopy <T>(BidirectionalIterator <T> begin, BidirectionalIterator <T> end, OutputIterator <T> dest) { end = IteratorUtil.Clone(end); dest = IteratorUtil.Clone(dest); while (!begin.Equals(end)) { end.MovePrev(); dest.Write(end.Read()); dest.MoveNext(); } }
public static OutputIterator <T> RemoveCopyIf <T>(InputIterator <T> begin, InputIterator <T> end, OutputIterator <T> dest, Functional.UnaryPredicate <T> func) { for (begin = IteratorUtil.Clone(begin), dest = IteratorUtil.Clone(dest); !begin.Equals(end); begin.MoveNext()) { T t = begin.Read(); if (!func(t)) { dest.Write(t); dest.MoveNext(); } } return(dest); }
public static OutputIterator <T> RemoveCopy <T>(InputIterator <T> begin, InputIterator <T> end, OutputIterator <T> dest, T value, IEqualityComparer <T> comparer) { for (begin = IteratorUtil.Clone(begin), dest = IteratorUtil.Clone(dest); !begin.Equals(end); begin.MoveNext()) { T t = begin.Read(); if (!comparer.Equals(value, t)) { dest.Write(t); dest.MoveNext(); } } return(dest); }
public static void RotateCopy <T>(ForwardIterator <T> begin, ForwardIterator <T> middle, ForwardIterator <T> end, OutputIterator <T> dest) { Copy(begin, middle, Copy(middle, end, dest)); #if NEVER dest = IteratorUtil.Clone(dest); ForwardIterator <T> src = IteratorUtil.Clone(newBegin); newBegin = IteratorUtil.Clone(newBegin); for (; !src.Equals(end); dest.MoveNext(), src.MoveNext()) { dest.Write(src.Read()); } src = IteratorUtil.Clone(begin); for (; !src.Equals(newBegin); dest.MoveNext(), src.MoveNext()) { dest.Write(src.Read()); } #endif }
public static OutputIterator <T> RemoveCopy <T>(InputIterator <T> begin, InputIterator <T> end, OutputIterator <T> dest, T value) where T : IEquatable <T> { for (begin = IteratorUtil.Clone(begin), dest = IteratorUtil.Clone(dest); !begin.Equals(end); begin.MoveNext()) { T t = begin.Read(); if (!value.Equals(t)) { dest.Write(t); dest.MoveNext(); } } return(dest); }
public static void CopyN <T>(IEnumerable <T> enumerable, uint count, OutputIterator <T> target) { if (count == 0) { return; } target = IteratorUtil.Clone(target); foreach (T t in enumerable) { target.Write(t); target.MoveNext(); --count; if (count == 0) { return; } } }