/* Copyright (c) Microsoft Corporation All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT. See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. */ using System; using System.Collections; using System.Collections.Generic; using System.IO; using System.Globalization; using System.Reflection; using System.Linq; using Microsoft.Research.DryadLinq; #pragma warning disable 1591 namespace Microsoft.Research.DryadLinq.Internal { public interface IMultiEnumerable { UInt32 NumberOfInputs { get; } } public interface IMultiEnumerable : IEnumerable { UInt32 NumberOfInputs { get; } IEnumerable this[int index] { get; } } public interface IMultiEnumerable : IMultiEnumerable { IEnumerable First { get; } IEnumerable Second { get; } } public interface IMultiEnumerable : IMultiEnumerable { IEnumerable First { get; } IEnumerable Second { get; } IEnumerable Third { get; } } public class MultiEnumerable : IMultiEnumerable { private IEnumerable[] m_enumList; public MultiEnumerable(IEnumerable[] enumList) { this.m_enumList = enumList; } public UInt32 NumberOfInputs { get { return (UInt32)this.m_enumList.Length; } } public IEnumerable this[int index] { get { if (index < this.m_enumList.Length) { return this.m_enumList[index]; } //@@TODO: throw ArgumentOutOfRangeException? throw new DryadLinqException(DryadLinqErrorCode.IndexOutOfRange, SR.IndexOutOfRange); } } IEnumerator IEnumerable.GetEnumerator() { return this.GetEnumerator(); } IEnumerator IEnumerable.GetEnumerator() { return this.GetEnumerator(); } public IEnumerator GetEnumerator() { foreach (var x in this.m_enumList) { foreach (var y in x) { yield return y; } } } } public class MultiEnumerable : IMultiEnumerable { private IEnumerable m_first; private IEnumerable m_second; public MultiEnumerable(IEnumerable first, IEnumerable second) { this.m_first = first; this.m_second = second; } public UInt32 NumberOfInputs { get { return 2; } } public IEnumerable First { get { return this.m_first; } } public IEnumerable Second { get { return this.m_second; } } } public class MultiEnumerable : IMultiEnumerable { private IEnumerable m_first; private IEnumerable m_second; private IEnumerable m_third; public MultiEnumerable(IEnumerable first, IEnumerable second, IEnumerable third) { this.m_first = first; this.m_second = second; this.m_third = third; } public UInt32 NumberOfInputs { get { return 3; } } public IEnumerable First { get { return this.m_first; } } public IEnumerable Second { get { return this.m_second; } } public IEnumerable Third { get { return this.m_third; } } } }