public IVarTuple this[int?fromIncluded, int?toExcluded] { get { int begin = fromIncluded.HasValue ? TupleHelpers.MapIndexBounded(fromIncluded.Value, m_count) : 0; int end = toExcluded.HasValue ? TupleHelpers.MapIndexBounded(toExcluded.Value, m_count) : m_count; if (end <= begin) { return(STuple.Empty); } int p = this.Head.Count; if (begin >= p) { // all selected items are in the tail return(this.Tail[begin - p, end - p]); } if (end <= p) { // all selected items are in the head return(this.Head[begin, end]); } // selected items are both in head and tail return(new JoinedTuple(this.Head[begin, null], this.Tail[null, end - p])); } }
public IVarTuple this[int?fromIncluded, int?toExcluded] { get { int begin = fromIncluded.HasValue ? TupleHelpers.MapIndexBounded(fromIncluded.Value, m_count) : 0; int end = toExcluded.HasValue ? TupleHelpers.MapIndexBounded(toExcluded.Value, m_count) : m_count; int len = end - begin; if (len <= 0) { return(STuple.Empty); } if (begin == 0 && len == m_count) { return(this); } Contract.Assert(m_offset + begin >= m_offset); Contract.Assert(len >= 0 && len <= m_count); return(new ListTuple(m_items, m_offset + begin, len)); } }
public IVarTuple this[int?fromIncluded, int?toExcluded] { get { int count = m_items.Length; int begin = fromIncluded.HasValue ? TupleHelpers.MapIndexBounded(fromIncluded.Value, count) : 0; int end = toExcluded.HasValue ? TupleHelpers.MapIndexBounded(toExcluded.Value, count) : count; int len = end - begin; if (len <= 0) { return(STuple.Empty); } if (begin == 0 && len == count) { return(this); } Contract.Debug.Assert(begin >= 0); Contract.Debug.Assert((uint)len <= count); return(new ListTuple <T>(m_items.Slice(begin, len))); } }