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


C# NeoDatis.GetNbKeys方法代码示例

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


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

示例1: ValidateNode

		public static void ValidateNode(NeoDatis.Btree.IBTreeNode node)
		{
			if (!on)
			{
				return;
			}
			int nbKeys = node.GetNbKeys();
			if (node.HasParent() && nbKeys < node.GetDegree() - 1)
			{
				throw new NeoDatis.Btree.Exception.BTreeNodeValidationException("Node with less than "
					 + (node.GetDegree() - 1) + " keys");
			}
			int maxNbKeys = node.GetDegree() * 2 - 1;
			int nbChildren = node.GetNbChildren();
			int maxNbChildren = node.GetDegree() * 2;
			if (nbChildren != 0 && nbKeys == 0)
			{
				throw new NeoDatis.Btree.Exception.BTreeNodeValidationException("Node with no key but with children : "
					 + node);
			}
			for (int i = 0; i < nbKeys; i++)
			{
				if (node.GetKeyAndValueAt(i) == null)
				{
					throw new NeoDatis.Btree.Exception.BTreeNodeValidationException("Null key at " + 
						i + " on node " + node.ToString());
				}
				CheckValuesOfChild(node.GetKeyAndValueAt(i), node.GetChildAt(i, false));
			}
			for (int i = nbKeys; i < maxNbKeys; i++)
			{
				if (node.GetKeyAndValueAt(i) != null)
				{
					throw new NeoDatis.Btree.Exception.BTreeNodeValidationException("Not Null key at "
						 + i + " on node " + node.ToString());
				}
			}
			NeoDatis.Btree.IBTreeNode previousNode = null;
			for (int i = 0; i < nbChildren; i++)
			{
				if (node.GetChildAt(i, false) == null)
				{
					throw new NeoDatis.Btree.Exception.BTreeNodeValidationException("Null child at index "
						 + i + " on node " + node.ToString());
				}
				if (previousNode != null && previousNode == node.GetChildAt(i, false))
				{
					throw new NeoDatis.Btree.Exception.BTreeNodeValidationException("Two equals children at index "
						 + i + " : " + previousNode.ToString());
				}
				previousNode = node.GetChildAt(i, false);
			}
			for (int i = nbChildren; i < maxNbChildren; i++)
			{
				if (node.GetChildAt(i, false) != null)
				{
					throw new NeoDatis.Btree.Exception.BTreeNodeValidationException("Not Null child at "
						 + i + " on node " + node.ToString());
				}
			}
		}
开发者ID:Orvid,项目名称:SQLInterfaceCollection,代码行数:61,代码来源:BTreeValidator.cs

示例2: SearchKey

		public static bool SearchKey(System.IComparable key, NeoDatis.Btree.IBTreeNodeOneValuePerKey
			 node)
		{
			if (!on)
			{
				return false;
			}
			for (int i = 0; i < node.GetNbKeys(); i++)
			{
				if (node.GetKeyAndValueAt(i).GetKey().CompareTo(key) == 0)
				{
					return true;
				}
			}
			return false;
		}
开发者ID:Orvid,项目名称:SQLInterfaceCollection,代码行数:16,代码来源:BTreeValidator.cs

示例3: CheckValuesOfChild

		private static void CheckValuesOfChild(NeoDatis.Btree.IKeyAndValue key, NeoDatis.Btree.IBTreeNode
			 node)
		{
			if (!on)
			{
				return;
			}
			if (node == null)
			{
				return;
			}
			for (int i = 0; i < node.GetNbKeys(); i++)
			{
				if (node.GetKeyAndValueAt(i).GetKey().CompareTo(key.GetKey()) >= 0)
				{
					throw new NeoDatis.Btree.Exception.BTreeNodeValidationException("Left child with values bigger than pivot "
						 + key + " : " + node.ToString());
				}
			}
		}
开发者ID:Orvid,项目名称:SQLInterfaceCollection,代码行数:20,代码来源:BTreeValidator.cs

示例4: BuildDisplay

		private void BuildDisplay(NeoDatis.Btree.IBTreeNode node, int currentHeight, int 
			childIndex, object parentId, bool withIds)
		{
			if (currentHeight > lines.Length - 1)
			{
				return;
			}
			// get string buffer of this line
			System.Text.StringBuilder line = lines[currentHeight];
			if (withIds)
			{
				line.Append(node.GetId()).Append(":[");
			}
			else
			{
				line.Append("[");
			}
			for (int i = 0; i < node.GetNbKeys(); i++)
			{
				if (i > 0)
				{
					line.Append(" , ");
				}
				NeoDatis.Btree.IKeyAndValue kav = node.GetKeyAndValueAt(i);
				line.Append(kav.GetKey());
			}
			if (withIds)
			{
				line.Append("]:").Append(node.GetParentId()).Append("/").Append(parentId).Append(
					"    ");
			}
			else
			{
				line.Append("]  ");
			}
			for (int i = 0; i < node.GetNbChildren(); i++)
			{
				NeoDatis.Btree.IBTreeNode child = node.GetChildAt(i, false);
				if (child != null)
				{
					BuildDisplay(child, currentHeight + 1, i, node.GetId(), withIds);
				}
				else
				{
					lines[currentHeight + 1].Append("[Child " + (i + 1) + " null!] ");
				}
			}
		}
开发者ID:Orvid,项目名称:SQLInterfaceCollection,代码行数:48,代码来源:BTreeDisplay.cs

示例5: CheckIfCanMergeWith

		private void CheckIfCanMergeWith(NeoDatis.Btree.IBTreeNode node)
		{
			if (nbKeys + node.GetNbKeys() > maxNbKeys)
			{
				throw new NeoDatis.Btree.Exception.BTreeException("Trying to merge two nodes with too many keys "
					 + nbKeys + " + " + node.GetNbKeys() + " > " + maxNbKeys);
			}
			if (nbKeys > 0)
			{
				System.IComparable greatestOfThis = keys[nbKeys - 1];
				System.IComparable smallestOfOther = node.GetKeyAt(0);
				if (greatestOfThis.CompareTo(smallestOfOther) >= 0)
				{
					throw new NeoDatis.Btree.Exception.BTreeNodeValidationException("Trying to merge two nodes that have intersections :  "
						 + ToString() + " / " + node);
				}
			}
			if (nbKeys < nbChildren)
			{
				throw new NeoDatis.Btree.Exception.BTreeNodeValidationException("Trying to merge two nodes where the first one has more children than keys"
					);
			}
		}
开发者ID:Orvid,项目名称:SQLInterfaceCollection,代码行数:23,代码来源:AbstractBTreeNode.cs

示例6: MergeWith

		/// <summary>
		/// Can only merge node without intersection =&gt; the greater key of this must
		/// be smaller than the smallest key of the node
		/// </summary>
		public virtual void MergeWith(NeoDatis.Btree.IBTreeNode node)
		{
			NeoDatis.Btree.Tool.BTreeValidator.ValidateNode(this);
			NeoDatis.Btree.Tool.BTreeValidator.ValidateNode(node);
			CheckIfCanMergeWith(node);
			int j = nbKeys;
			for (int i = 0; i < node.GetNbKeys(); i++)
			{
				SetKeyAndValueAt(node.GetKeyAt(i), node.GetValueAsObjectAt(i), j, false, false);
				SetChildAt(node, i, j, false);
				j++;
			}
			// in this, we have to take the last child
			if (node.GetNbChildren() > node.GetNbKeys())
			{
				SetChildAt(node, node.GetNbChildren() - 1, j, true);
			}
			nbKeys += node.GetNbKeys();
			nbChildren += node.GetNbChildren();
			NeoDatis.Btree.Tool.BTreeValidator.ValidateNode(this);
		}
开发者ID:Orvid,项目名称:SQLInterfaceCollection,代码行数:25,代码来源:AbstractBTreeNode.cs


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