示例#1
0
        /// <summary>
        /// Makes a separate header for a sequence slice.
        /// </summary>
        /// <param name="slice">The part of the sequence to be extracted.</param>
        /// <param name="storage">The storage block that will store the new sequence.</param>
        /// <param name="copyData">
        /// A value indicating whether to copy the elements of the extracted slice.
        /// </param>
        /// <returns>
        /// A new <see cref="Seq"/> instance containing the elements in the
        /// specified <paramref name="slice"/>.
        /// </returns>
        public Seq Slice(SeqSlice slice, MemStorage storage = null, bool copyData = false)
        {
            storage = storage ?? owner;
            var seq = NativeMethods.cvSeqSlice(this, slice, storage, copyData ? 1 : 0);

            seq.SetOwnerStorage(storage);
            return(seq);
        }
示例#2
0
        /// <summary>
        /// Copies part of the sequence elements to a compatible one-dimensional array.
        /// </summary>
        /// <typeparam name="TElement">The type of the elements in the sequence.</typeparam>
        /// <param name="array">The array on which to store sequence elements.</param>
        /// <param name="slice">The portion of the sequence to copy to the array.</param>
        public void CopyTo <TElement>(TElement[] array, SeqSlice slice) where TElement : struct
        {
            var arrayHandle = GCHandle.Alloc(array, GCHandleType.Pinned);

            try
            {
                NativeMethods.cvCvtSeqToArray(this, arrayHandle.AddrOfPinnedObject(), slice);
            }
            finally { arrayHandle.Free(); }
        }
示例#3
0
 /// <summary>
 /// Removes a sequence slice.
 /// </summary>
 /// <param name="slice">The part of the sequence to remove.</param>
 public void Remove(SeqSlice slice)
 {
     NativeMethods.cvSeqRemoveSlice(this, slice);
 }