コード例 #1
0
        /// <summary>Create a new list tuple by merging the items of two tuples together</summary>
        /// <param name="left"></param>
        /// <param name="right"></param>
        internal ListTuple(ITuple a, ITuple b)
        {
            if (a == null)
            {
                throw new ArgumentNullException("a");
            }
            if (b == null)
            {
                throw new ArgumentNullException("b");
            }

            int nA = a.Count;
            int nB = b.Count;

            m_offset = 0;
            m_count  = nA + nB;
            m_items  = new object[m_count];

            if (nA > 0)
            {
                a.CopyTo(m_items, 0);
            }
            if (nB > 0)
            {
                b.CopyTo(m_items, nA);
            }
        }
コード例 #2
0
        /// <summary>Create a new list tuple by merging the items of three tuples together</summary>
        public ListTuple(ITuple a, ITuple b, ITuple c)
        {
            Contract.NotNull(a, nameof(a));
            Contract.NotNull(b, nameof(b));
            Contract.NotNull(c, nameof(c));

            int nA = a.Count;
            int nB = b.Count;
            int nC = c.Count;

            m_offset = 0;
            m_count  = nA + nB + nC;
            m_items  = new object[m_count];

            if (nA > 0)
            {
                a.CopyTo(m_items, 0);
            }
            if (nB > 0)
            {
                b.CopyTo(m_items, nA);
            }
            if (nC > 0)
            {
                c.CopyTo(m_items, nA + nB);
            }
        }
コード例 #3
0
        public static object[] ToArray([NotNull] this ITuple tuple)
        {
            Contract.NotNull(tuple, nameof(tuple));

            var items = new object[tuple.Count];

            if (items.Length > 0)
            {
                tuple.CopyTo(items, 0);
            }
            return(items);
        }
コード例 #4
0
        public static object[] ToArray([NotNull] this ITuple tuple)
        {
            if (tuple == null)
            {
                throw new ArgumentNullException(nameof(tuple));
            }

            var items = new object[tuple.Count];

            if (items.Length > 0)
            {
                tuple.CopyTo(items, 0);
            }
            return(items);
        }
コード例 #5
0
        public ListTuple Concat(ITuple tuple)
        {
            if (tuple is ListTuple lt)
            {
                return(Concat(lt));
            }

            int count = tuple.Count;

            if (count == 0)
            {
                return(this);
            }

            var list = new object[m_count + count];

            Array.Copy(m_items, m_offset, list, 0, m_count);
            tuple.CopyTo(list, m_count);
            return(new ListTuple(list, 0, list.Length));
        }
コード例 #6
0
 public void CopyTo(object[] array, int offset)
 {
     m_items.CopyTo(array, offset);
 }