[Test] public void UniqueCopy_Comparer_OutputIterator() { OutputIterator <string> destIter = IteratorUtil.Begin(dest); destIter.MoveNext(); OutputIterator <string> result = Algorithm.UniqueCopy(IteratorUtil.Begin(src), IteratorUtil.End(src), destIter, EqualityComparer <string> .Default); VerifyOutput(); Assert.IsNotNull(result); Assert.AreEqual(6, (result as ListIterator <string>).Position); Assert.AreEqual(MARKER, (result as ListIterator <string>).Read()); }
[Test] public void UniqueCopy_Predicate_OutputIterator() { OutputIterator <string> destIter = IteratorUtil.Begin(dest); destIter.MoveNext(); OutputIterator <string> result = Algorithm.UniqueCopy(IteratorUtil.Begin(src), IteratorUtil.End(src), destIter, delegate(string lhs, string rhs) { return(lhs == rhs); }); VerifyOutput(); Assert.IsNotNull(result); Assert.AreEqual(6, (result as ListIterator <string>).Position); Assert.AreEqual(MARKER, (result as ListIterator <string>).Read()); }
[Test] public void RemoveCopy_List_OutputIterator_Comparer() { OutputIterator <int> destIter = IteratorUtil.Begin(dest); destIter.MoveNext(); OutputIterator <int> result = Algorithm.RemoveCopy(src, destIter, 29, EqualityComparer <int> .Default); VerifyOutput(); Assert.IsNotNull(result); Assert.AreEqual(src.Length - 3, (result as ListIterator <int>).Position); }
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(); } }
[Test] public void RemoveCopyIf_OutputIterator() { OutputIterator <int> destIter = IteratorUtil.Begin(dest); destIter.MoveNext(); OutputIterator <int> result = Algorithm.RemoveCopyIf(IteratorUtil.Begin(src), IteratorUtil.End(src), destIter, Is29); VerifyOutput(); Assert.IsNotNull(result); Assert.AreEqual(src.Length - 3, (result as ListIterator <int>).Position); }
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); }
[Test] public void UniqueCopy_OutputIterator() { OutputIterator <int> destIter = IteratorUtil.Begin(dest); destIter.MoveNext(); OutputIterator <int> result = Algorithm.UniqueCopy(IteratorUtil.Begin(src), IteratorUtil.End(src), destIter); VerifyOutput(); Assert.IsNotNull(result); Assert.AreEqual(6, (result as ListIterator <int>).Position); Assert.AreEqual(Int32.MinValue, (result as ListIterator <int>).Read()); }
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 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); }
[Test] public void UniqueCopy_List_Predicate_OutputIterator() { OutputIterator <int> destIter = IteratorUtil.Begin(dest); destIter.MoveNext(); OutputIterator <int> result = Algorithm.UniqueCopy(src, destIter, delegate(int lhs, int rhs) { return(lhs == rhs); }); VerifyOutput(); Assert.IsNotNull(result); Assert.AreEqual(6, (result as ListIterator <int>).Position); Assert.AreEqual(Int32.MinValue, (result as ListIterator <int>).Read()); }
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; } } }
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 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 <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); }