public Arr <B> Map(Arr <A> ma, Func <A, B> f) { var bs = new B[ma.Count]; var iter = ma.GetEnumerator(); for (int i = 0; iter.MoveNext(); i++) { bs[i] = f(iter.Current); } return(bs); }
public bool Equals(Arr <A> x, Arr <A> y) { if (x.Count != y.Count) { return(false); } var xiter = x.GetEnumerator(); var yiter = y.GetEnumerator(); while (xiter.MoveNext() && yiter.MoveNext()) { if (!equals <EqA, A>(xiter.Current, yiter.Current)) { return(false); } } return(true); }
public int Compare(Arr <A> mx, Arr <A> my) { var cmp = mx.Count.CompareTo(my.Count); if (cmp == 0) { var xiter = mx.GetEnumerator(); var yiter = my.GetEnumerator(); while (xiter.MoveNext() && yiter.MoveNext()) { cmp = default(OrdA).Compare(xiter.Current, yiter.Current); if (cmp != 0) { return(cmp); } } return(0); } else { return(cmp); } }
public IEnumerator GetEnumerator() { return(Arr.GetEnumerator()); }
public IEnumerator <T> GetEnumerator() => Arr.GetEnumerator();