当前位置: 首页>>代码示例>>C#>>正文


C# MemorySlice.CopyTo方法代码示例

本文整理汇总了C#中MemorySlice.CopyTo方法的典型用法代码示例。如果您正苦于以下问题:C# MemorySlice.CopyTo方法的具体用法?C# MemorySlice.CopyTo怎么用?C# MemorySlice.CopyTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MemorySlice的用法示例。


在下文中一共展示了MemorySlice.CopyTo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CopyNodeDataToEndOfPage

        /// <summary>
        /// Internal method that is used when splitting pages
        /// No need to do any work here, we are always adding at the end
        /// </summary>
        internal void CopyNodeDataToEndOfPage(NodeHeader* other, MemorySlice key)
        {
            var index = NumberOfEntries;

            Debug.Assert(HasSpaceFor(SizeOf.NodeEntryWithAnotherKey(other, key) + Constants.NodeOffsetSize + SizeOf.NewPrefix(key)));

            var nodeSize = SizeOf.NodeEntryWithAnotherKey(other, key);

            Debug.Assert(IsBranch == false || index != 0 || key.KeyLength == 0);// branch page's first item must be the implicit ref

            var nodeVersion = other->Version; // every time new node is allocated the version is increased, but in this case we do not want to increase it
            if (nodeVersion > 0)
                nodeVersion -= 1;

            var prefixedKey = key as PrefixedSlice;
            if (prefixedKey != null && prefixedKey.NewPrefix != null)
                WritePrefix(prefixedKey.NewPrefix, prefixedKey.Header.PrefixId);

            var newNode = AllocateNewNode(index, nodeSize, nodeVersion);

            newNode->KeySize = key.Size;
            newNode->Flags = other->Flags;

            if(key.Options == SliceOptions.Key &&  key.Size > 0)
                key.CopyTo((byte*)newNode + Constants.NodeHeaderSize);

            if (IsBranch || other->Flags == (NodeFlags.PageRef))
            {
                newNode->PageNumber = other->PageNumber;
                newNode->Flags = NodeFlags.PageRef;
                return;
            }
            newNode->DataSize = other->DataSize;
            Memory.Copy((byte*)newNode + Constants.NodeHeaderSize + key.Size,
                                 (byte*)other + Constants.NodeHeaderSize + other->KeySize,
                                 other->DataSize);
        }
开发者ID:ricardobrandao,项目名称:ravendb,代码行数:41,代码来源:Page.cs

示例2: CreateNode

        private NodeHeader* CreateNode(int index, MemorySlice key, NodeFlags flags, int len, ushort previousNodeVersion)
        {
            Debug.Assert(index <= NumberOfEntries && index >= 0);
            Debug.Assert(IsBranch == false || index != 0 || key.KeyLength == 0);// branch page's first item must be the implicit ref
            if (HasSpaceFor(key, len) == false)
                throw new InvalidOperationException(string.Format("The page is full and cannot add an entry, this is probably a bug. Key: {0}, data length: {1}, size left: {2}", key, len, SizeLeft));

            var prefixedKey = key as PrefixedSlice;
            if (prefixedKey != null && prefixedKey.NewPrefix != null)
                WritePrefix(prefixedKey.NewPrefix, prefixedKey.Header.PrefixId);

            // move higher pointers up one slot
            for (int i = NumberOfEntries; i > index; i--)
            {
                KeysOffsets[i] = KeysOffsets[i - 1];
            }

            var nodeSize = SizeOf.NodeEntry(PageMaxSpace, key, len);
            var node = AllocateNewNode(index, nodeSize, previousNodeVersion);

            node->KeySize = key.Size;

            if (key.Options == SliceOptions.Key && key.Size > 0)
                key.CopyTo((byte*)node + Constants.NodeHeaderSize);

            node->Flags = flags;

            return node;
        }
开发者ID:ricardobrandao,项目名称:ravendb,代码行数:29,代码来源:Page.cs


注:本文中的MemorySlice.CopyTo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。