本文整理汇总了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);
}
示例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;
}