Example #1
0
        /// <summary>
        /// Inserts the elements of a collection into the List at the specified index.
        /// </summary>
        /// <param name="index">The zero-based index at which the new elements should be inserted.</param>
        /// <param name="collection">The collection whose elements should be inserted into the List. The collection itself cannot be null, but it can contain elements that are null, if type T is a reference type.</param>
        public unsafe void InsertRange(int index, List <Triple> collection)
        {
            if (collection == null)
            {
                throw new ArgumentNullException("collection is null.");
            }
            if (index < 0)
            {
                throw new ArgumentOutOfRangeException("index is less than 0.");
            }
            if (index > Count)
            {
                throw new ArgumentOutOfRangeException("index is greater than Count.");
            }
            Triple_AccessorListAccessor tmpAccessor = collection;
            byte *targetPtr = m_ptr;

            for (int i = 0; i < index; i++)
            {
                { targetPtr += *(int *)targetPtr + sizeof(int); targetPtr += *(int *)targetPtr + sizeof(int); targetPtr += *(int *)targetPtr + sizeof(int); targetPtr += *(int *)targetPtr + sizeof(int); }
            }
            int offset = (int)(targetPtr - m_ptr);

            m_ptr = ResizeFunction(m_ptr - 4, offset + 4, tmpAccessor.length);
            Memory.Copy(tmpAccessor.m_ptr, m_ptr + offset + 4, tmpAccessor.length);
            *(int *)m_ptr += tmpAccessor.length;
            this.m_ptr    += 4;
        }
Example #2
0
        /// <summary>
        /// Adds the elements of the specified collection to the end of the List
        /// </summary>
        /// <param name="collection">The collection whose elements should be added to the end of the List. The collection itself cannot be null.</param>
        public unsafe void AddRange(Triple_AccessorListAccessor collection)
        {
            if (collection == null)
            {
                throw new ArgumentNullException("collection is null.");
            }
            int delta = collection.length;

            if (collection.m_cellId != m_cellId)
            {
                m_ptr = ResizeFunction(m_ptr - 4, *(int *)(m_ptr - 4) + 4, delta);
                Memory.Copy(collection.m_ptr, m_ptr + *(int *)m_ptr + 4, delta);
                *(int *)m_ptr += delta;
            }
            else
            {
                byte[] tmpcell = new byte[delta];
                fixed(byte *tmpcellptr = tmpcell)
                {
                    Memory.Copy(collection.m_ptr, tmpcellptr, delta);
                    m_ptr = ResizeFunction(m_ptr - 4, *(int *)(m_ptr - 4) + 4, delta);
                    Memory.Copy(tmpcellptr, m_ptr + *(int *)m_ptr + 4, delta);
                    *(int *)m_ptr += delta;
                }
            }
            this.m_ptr += 4;
        }
Example #3
0
        /// <summary>
        /// Adds the elements of the specified collection to the end of the List
        /// </summary>
        /// <param name="collection">The collection whose elements should be added to the end of the List. The collection itself cannot be null.</param>
        public unsafe void AddRange(List <Triple> collection)
        {
            if (collection == null)
            {
                throw new ArgumentNullException("collection is null.");
            }
            Triple_AccessorListAccessor tcollection = collection;
            int delta = tcollection.length;

            m_ptr = ResizeFunction(m_ptr - 4, *(int *)(m_ptr - 4) + 4, delta);
            Memory.Copy(tcollection.m_ptr, m_ptr + *(int *)m_ptr + 4, delta);
            *(int *)m_ptr += delta;
            this.m_ptr    += 4;
        }
        internal unsafe TripleStream_Accessor(byte *_CellPtr

                                              , ResizeFunctionDelegate func
                                              )
        {
            m_ptr = _CellPtr;

            ResizeFunction         = func;
            triples_Accessor_Field = new Triple_AccessorListAccessor(null,
                                                                     (ptr, ptr_offset, delta) =>
            {
                int substructure_offset = (int)(ptr - this.m_ptr);
                this.m_ptr = this.ResizeFunction(this.m_ptr, ptr_offset + substructure_offset, delta);
                return(this.m_ptr + substructure_offset);
            });
        }
Example #5
0
 internal _iterator(Triple_AccessorListAccessor target)
 {
     targetPtr   = target.m_ptr;
     endPtr      = targetPtr + target.length;
     this.target = target;
 }