亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? bplustreelong.cs

?? R樹與B樹的混合樹
?? CS
?? 第 1 頁 / 共 5 頁
字號:
			//this.ChildBufferNumbers[endlocation+1] = BplusTreeLong.NULLBUFFERNUMBER;
			if (this.SizeInUse()<this.Size/2)
			{
				MergeMe = true;
			}
			if (deletelocation==0) 
			{
				result = this.ChildKeys[0];
				// this is only relevant for the case of 2-3 trees (empty leaf after deletion)
				if (result==null) 
				{
					result = key; // deleted value
				}
			}
			return result;
		}
		/// <summary>
		/// insert key/position entry in self 
		/// </summary>
		/// <param name="key">Key to associate with the leaf</param>
		/// <param name="position">position associated with key in external structur</param>
		/// <param name="splitString">if not null then the smallest key in the new split leaf</param>
		/// <param name="splitNode">if not null then the node was split and this is the leaf to the right.</param>
		/// <returns>null unless the smallest key under this node has changed, in which case it returns the smallest key.</returns>
		public string Insert(string key, long position, out string splitString, out BplusNode splitNode) 
		{
			if (this.isLeaf) 
			{
				return this.InsertLeaf(key, position, out splitString, out splitNode);
			}
			splitString = null;
			splitNode = null;
			int insertposition = this.FindAtOrNextPosition(key, false);
			long insertBufferNumber = this.ChildBufferNumbers[insertposition];
			if (insertBufferNumber==BplusTreeLong.NULLBUFFERNUMBER) 
			{
				throw new BplusTreeException("key not followed by buffer number in non-leaf");
			}
			// insert in subtree
			BplusNode InsertChild = this.MaterializeNodeAtIndex(insertposition);
			BplusNode childSplit;
			string childSplitString;
			string childInsert = InsertChild.Insert(key, position, out childSplitString, out childSplit);
			// if there was a split the node must expand
			if (childSplit!=null) 
			{
				// insert the child
				this.Soil(); // redundant -- a child will have a change so this node will need to be copied
				int newChildPosition = insertposition+1;
				bool dosplit = false;
				// if there is no free space we must do a split
				if (this.ChildBufferNumbers[this.Size]!=BplusTreeLong.NULLBUFFERNUMBER) 
				{
					dosplit = true;
					this.PrepareForSplit();
				}
				// bubble over the current values to make space for new child
				for (int i=this.ChildKeys.Length-2; i>=newChildPosition-1; i--) 
				{
					int i1 = i+1;
					int i2 = i1+1;
					this.ChildKeys[i1] = this.ChildKeys[i];
					this.ChildBufferNumbers[i2] = this.ChildBufferNumbers[i1];
					BplusNode childNode = this.MaterializedChildNodes[i2] = this.MaterializedChildNodes[i1];
				}
				// record the new child
				this.ChildKeys[newChildPosition-1] = childSplitString;
				//this.MaterializedChildNodes[newChildPosition] = childSplit;
				//this.ChildBufferNumbers[newChildPosition] = childSplit.myBufferNumber;
				childSplit.Reparent(this, newChildPosition);
				// split, if needed
				if (dosplit) 
				{
					int splitpoint = this.MaterializedChildNodes.Length/2-1;
					splitString = this.ChildKeys[splitpoint];
					splitNode = new BplusNode(this.owner, this.parent, -1, this.isLeaf);
					// make copy of expanded node structure
					BplusNode[] materialized = this.MaterializedChildNodes;
					long[] buffernumbers = this.ChildBufferNumbers;
					string[] keys = this.ChildKeys;
					// repair the expanded node
					this.ChildKeys = new string[this.Size];
					this.MaterializedChildNodes = new BplusNode[this.Size+1];
					this.ChildBufferNumbers = new long[this.Size+1];
					this.Clear();
					Array.Copy(materialized, 0, this.MaterializedChildNodes, 0, splitpoint+1);
					Array.Copy(buffernumbers, 0, this.ChildBufferNumbers, 0, splitpoint+1);
					Array.Copy(keys, 0, this.ChildKeys, 0, splitpoint);
					// initialize the new node
					splitNode.Clear(); // redundant.
					int remainingKeys = this.Size-splitpoint;
					Array.Copy(materialized, splitpoint+1, splitNode.MaterializedChildNodes, 0, remainingKeys+1);
					Array.Copy(buffernumbers, splitpoint+1, splitNode.ChildBufferNumbers, 0, remainingKeys+1);
					Array.Copy(keys, splitpoint+1, splitNode.ChildKeys, 0, remainingKeys);
					// fix pointers in materialized children of splitnode
					splitNode.reParentAllChildren();
					// store the new node
					splitNode.DumpToFreshBuffer();
					splitNode.CheckIfTerminal();
					splitNode.Soil();
					this.CheckIfTerminal();
				}
				// fix pointers in children
				this.reParentAllChildren();
			}
			if (insertposition==0) 
			{
				// the smallest key may have changed
				return childInsert;
			}
			return null;  // no change in smallest key
		}
		/// <summary>
		/// Check to see if this is a terminal node, if so record it, otherwise forget it
		/// </summary>
		void CheckIfTerminal() 
		{
			if (!this.isLeaf) 
			{
				for (int i=0; i<this.Size+1; i++) 
				{
					if (this.MaterializedChildNodes[i]!=null) 
					{
						this.owner.ForgetTerminalNode(this);
						return;
					}
				}
			}
			this.owner.RecordTerminalNode(this);
		}
		/// <summary>
		/// insert key/position entry in self (as leaf)
		/// </summary>
		/// <param name="key">Key to associate with the leaf</param>
		/// <param name="position">position associated with key in external structure</param>
		/// <param name="splitString">if not null then the smallest key in the new split leaf</param>
		/// <param name="splitNode">if not null then the node was split and this is the leaf to the right.</param>
		/// <returns>smallest key value in keys, or null if no change</returns>
		public string InsertLeaf(string key, long position, out string splitString, out BplusNode splitNode) 
		{
			splitString = null;
			splitNode = null;
			bool dosplit = false;
			if (!this.isLeaf) 
			{
				throw new BplusTreeException("bad call to InsertLeaf: this is not a leaf");
			}
			this.Soil();
			int insertposition = this.FindAtOrNextPosition(key, false);
			if (insertposition>=this.Size) 
			{
				//throw new BplusTreeException("key too big and leaf is full");
				dosplit = true;
				this.PrepareForSplit();
			} 
			else 
			{
				// if it's already there then change the value at the current location (duplicate entries not supported).
				if (this.ChildKeys[insertposition]==null || this.owner.Compare(this.ChildKeys[insertposition], key)==0) // this.ChildKeys[insertposition].Equals(key)
				{
					this.ChildBufferNumbers[insertposition] = position;
					this.ChildKeys[insertposition] = key;
					if (insertposition==0) 
					{
						return key;
					} 
					else 
					{
						return null;
					}
				}
			}
			// check for a null position
			int nullindex = insertposition;
			while (nullindex<this.ChildKeys.Length && this.ChildKeys[nullindex]!=null) 
			{
				nullindex++;
			}
			if (nullindex>=this.ChildKeys.Length) 
			{
				if (dosplit) 
				{
					throw new BplusTreeException("can't split twice!!");
				}
				//throw new BplusTreeException("no space in leaf");
				dosplit = true;
				this.PrepareForSplit();
			}
			// bubble in the new info XXXX THIS SHOULD BUBBLE BACKWARDS	
			string nextkey = this.ChildKeys[insertposition];
			long nextposition = this.ChildBufferNumbers[insertposition];
			this.ChildKeys[insertposition] = key;
			this.ChildBufferNumbers[insertposition] = position;
			while (nextkey!=null) 
			{
				key = nextkey;
				position = nextposition;
				insertposition++;
				nextkey = this.ChildKeys[insertposition];
				nextposition = this.ChildBufferNumbers[insertposition];
				this.ChildKeys[insertposition] = key;
				this.ChildBufferNumbers[insertposition] = position;
			}
			// split if needed
			if (dosplit) 
			{
				int splitpoint = this.ChildKeys.Length/2;
				int splitlength = this.ChildKeys.Length - splitpoint;
				splitNode = new BplusNode(this.owner, this.parent, -1, this.isLeaf);
				// copy the split info into the splitNode
				Array.Copy(this.ChildBufferNumbers, splitpoint, splitNode.ChildBufferNumbers, 0, splitlength);
				Array.Copy(this.ChildKeys, splitpoint, splitNode.ChildKeys, 0, splitlength);
				Array.Copy(this.MaterializedChildNodes, splitpoint, splitNode.MaterializedChildNodes, 0, splitlength);
				splitString = splitNode.ChildKeys[0];
				// archive the new node
				splitNode.DumpToFreshBuffer();
				// store the node data temporarily
				long[] buffernumbers = this.ChildBufferNumbers;
				string[] keys = this.ChildKeys;
				BplusNode[] nodes = this.MaterializedChildNodes;
				// repair current node, copy in the other part of the split
				this.ChildBufferNumbers = new long[this.Size+1];
				this.ChildKeys = new string[this.Size];
				this.MaterializedChildNodes = new BplusNode[this.Size+1];
				Array.Copy(buffernumbers, 0, this.ChildBufferNumbers, 0, splitpoint);
				Array.Copy(keys, 0, this.ChildKeys, 0, splitpoint);
				Array.Copy(nodes, 0, this.MaterializedChildNodes, 0, splitpoint);
				for (int i=splitpoint; i<this.ChildKeys.Length; i++) 
				{
					this.ChildKeys[i] = null;
					this.ChildBufferNumbers[i] = BplusTreeLong.NULLBUFFERNUMBER;
					this.MaterializedChildNodes[i] = null;
				}
				// store the new node
				//splitNode.DumpToFreshBuffer();
				this.owner.RecordTerminalNode(splitNode);
				splitNode.Soil();
			}
			//return this.ChildKeys[0];
			if (insertposition==0) 
			{
				return key; // smallest key changed.
			} 
			else 
			{
				return null; // no change in smallest key
			}
		}
		/// <summary>
		/// Grow to this.size+1 in preparation for insertion and split
		/// </summary>
		void PrepareForSplit() 
		{
			int supersize = this.Size+1;
			long[] positions = new long[supersize+1];
			string[] keys = new string[supersize];
			BplusNode[] materialized = new BplusNode[supersize+1];
			Array.Copy(this.ChildBufferNumbers, 0, positions, 0, this.Size+1);
			positions[this.Size+1] = BplusTreeLong.NULLBUFFERNUMBER;
			Array.Copy(this.ChildKeys, 0, keys, 0, this.Size);
			keys[this.Size] = null;
			Array.Copy(this.MaterializedChildNodes, 0, materialized, 0, this.Size+1);
			materialized[this.Size+1] = null;
			this.ChildBufferNumbers = positions;
			this.ChildKeys = keys;
			this.MaterializedChildNodes = materialized;
		}
		public void Load(byte[] buffer) 
		{
			// load serialized data
			// indicator | seek position | [ key storage | seek position ]*
			this.Clear();
			if (buffer.Length!=owner.buffersize) 
			{
				throw new BplusTreeException("bad buffer size "+buffer.Length+" should be "+owner.buffersize);
			}
			byte indicator = buffer[0];
			this.isLeaf = false;
			if (indicator==BplusTreeLong.LEAF) 
			{
				this.isLeaf = true;
			} 
			else if (indicator!=BplusTreeLong.NONLEAF) 
			{
				throw new BplusTreeException("bad indicator, not leaf or nonleaf in tree "+indicator);
			}
			int index = 1;
			// get the first seek position
			this.ChildBufferNumbers[0] = BufferFile.RetrieveLong(buffer, index);
			System.Text.Decoder decode = System.Text.Encoding.UTF8.GetDecoder();
			index+= BufferFile.LONGSTORAGE;
			int maxKeyLength = this.owner.KeyLength;
			int maxKeyPayload = maxKeyLength - BufferFile.SHORTSTORAGE;
			//this.NumberOfValidKids = 0;
			// get remaining key storages and seek positions
			string lastkey = "";
			for (int KeyIndex=0; KeyIndex<this.Size; KeyIndex++) 
			{
				// decode and store a key
				short keylength = BufferFile.RetrieveShort(buffer, index);
				if (keylength<-1 || keylength>maxKeyPayload) 
				{
					throw new BplusTreeException("invalid keylength decoded");
				}
				index+= BufferFile.SHORTSTORAGE;
				string key = null;
				if (keylength==0) 
				{
					key = "";
				} 
				else if (keylength>0) 
				{
					int charCount = decode.GetCharCount(buffer, index, keylength);
					char[] ca = new char[charCount];
					decode.GetChars(buffer, index, keylength, ca, 0);
					//this.NumberOfValidKids++;
					key = new String(ca);
				}
				this.ChildKeys[KeyIndex] = key;
				index+= maxKeyPayload;
				// decode and store a seek position
				long seekPosition = BufferFile.RetrieveLong(buffer, index);
				if (!this.isLeaf) 
				{
					if (key==null & seekPosition!=BplusTreeLong.NULLBUFFERNUMBER) 
					{
						throw new BplusTreeException("key is null but position is not "+KeyIndex);
					} 
					else if (lastkey==null && key!=null) 
					{
						throw new BplusTreeException("null key followed by non-null key "+KeyIndex);
					}
				}
				lastkey = key;
				this.ChildBufferNumbers[KeyIndex+1] = seekPosition;
				index+= BufferFile.LONGSTORAGE;
			}
		}
		/// <summary>
		/// check that key is ok for node of this size (put here for locality of relevant code).
		/// </summary>
		/// <param name="key">key to check</param>
		/// <param name="owner">tree to contain node containing the key</param>
		/// <returns>true if key is ok</returns>
		public static bool KeyOK(string key, BplusTreeLong owner) 
		{
			if (key==null) 
			{ 
				return false;
			}
			System.Text.Encoder encode = System.Text.Encoding.UTF8.GetEncoder();
			int maxKeyLength = owner.KeyLength;
			int maxKeyPayload = maxKeyLength - BufferFile.SHORTSTORAGE;
			char[] keyChars = key.ToCharArray();
			int charCount = encode.GetByteCount(keyChars, 0, keyChars.Length, true);
			if (charCount>maxKeyPayload) 
			{
				return false;
			}
			return true;
		}
		public void Dump(byte[] buffer) 
		{
			// indicator | seek position | [ key storage | seek position ]*
			if (buffer.Length!=owner.buffersize) 
			{
				throw new BplusTreeException("bad buffer size "+buffer.Length+" should be "+owner.buffersize);
			}
			buffer[0] = BplusTreeLong.NONLEAF;
			if (this.isLeaf) { buffer[0] = BplusTreeLong.LEAF; }
			int index = 1;
			// store first seek position
			BufferFile.Store(this.ChildBufferNumbers[0], buffer, index);
			index+= BufferFile.LONGSTORAGE;
			System.Text.Encoder encode = System.Text.Encoding.UTF8.GetEncoder();
			// store remaining keys and seeks
			int maxKeyLength = this.owner.KeyLength;
			int maxKeyPayload = maxKeyLength - BufferFile.SHORTSTORAGE;
			string lastkey = "";
			for (int KeyIndex=0; KeyIndex<this.Size; KeyIndex++) 
			{
				// store a key
				string theKey = this.ChildKeys[KeyIndex];
				short charCount = -1;
				if (theKey!=null) 
				{
					char[] keyChars = theKey.ToCharArray();
					charCount = (short) encode.GetByteCount(keyChars, 0, keyChars.Length, true);
					if (charCount>maxKeyPayload) 
					{
						throw new BplusTreeException("string bytes to large for use as key "+charCount+">"+maxKeyPayload);
					}
					BufferFile.Store(charCount, buffer, index);
					index+= BufferFile.SHORTSTORAGE;
					encode.GetBytes(keyChars, 0, keyChars.Length, buffer, index, true);
				} 
				

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
制服.丝袜.亚洲.另类.中文| 亚洲免费在线视频| 亚洲福利电影网| 国产伦精品一区二区三区免费 | 午夜亚洲福利老司机| 99久久国产综合精品麻豆| 久久久久久久久久久电影| 麻豆精品国产91久久久久久| 欧美麻豆精品久久久久久| 午夜精品福利久久久| 欧美精品第1页| 精品影视av免费| 国产欧美日韩在线观看| 亚洲第一会所有码转帖| 亚洲自拍偷拍网站| 欧美亚日韩国产aⅴ精品中极品| 久久亚洲精品国产精品紫薇| 久久国产日韩欧美精品| www久久精品| av电影一区二区| 一个色在线综合| 日韩欧美在线一区二区三区| 国产黄人亚洲片| 亚洲激情av在线| 欧美一区二区视频网站| 国产精品一区在线观看乱码| 亚洲乱码国产乱码精品精小说 | 国产精品天美传媒| 欧美日韩你懂得| 风间由美性色一区二区三区| 一区二区欧美在线观看| 精品免费视频.| 欧美三级蜜桃2在线观看| 国产一区二区在线电影| 亚洲丝袜精品丝袜在线| 日韩三级视频中文字幕| 91猫先生在线| 成人免费观看男女羞羞视频| 日韩av中文在线观看| 亚洲免费在线观看视频| 中文字幕成人网| 亚洲色图欧美偷拍| 欧美日韩高清在线播放| 99国产精品久久| 99精品国产91久久久久久 | 亚洲亚洲人成综合网络| 国产精品伦理在线| 久久久久久久综合日本| 日韩三级伦理片妻子的秘密按摩| 色诱视频网站一区| 色综合天天做天天爱| 91免费版pro下载短视频| 成人av电影在线| 色综合天天综合| 欧美无人高清视频在线观看| 7777精品伊人久久久大香线蕉最新版| 成人高清av在线| 99视频国产精品| 欧美视频第二页| 日韩一区二区三区四区五区六区| 欧美一区二区三区四区五区| 日韩一区二区三免费高清| 欧美一区二区在线播放| 久久毛片高清国产| 中文字幕一区二区三区视频| 中文字幕日韩欧美一区二区三区| 国产亚洲一本大道中文在线| 精品88久久久久88久久久| 久久久精品国产免大香伊| 国产精品剧情在线亚洲| 爽好多水快深点欧美视频| 亚洲午夜羞羞片| 久久99精品久久久| 91麻豆免费看| 精品国产髙清在线看国产毛片| 日韩欧美国产电影| 成人免费视频视频在线观看免费 | 欧美日韩精品一区二区在线播放| 欧美精品xxxxbbbb| 中国色在线观看另类| 一区二区视频免费在线观看| 日韩精品一二三区| 99视频精品免费视频| 91麻豆精品国产91久久久使用方法 | 亚洲电影一区二区| 国产白丝精品91爽爽久久| 欧美精品久久久久久久久老牛影院| 精品精品国产高清a毛片牛牛 | 国产99精品在线观看| 日韩久久免费av| 中文字幕佐山爱一区二区免费| 看片的网站亚洲| 91麻豆精品国产91久久久久久| 国产精品不卡在线| 高清不卡一二三区| 国产视频911| 国产精品综合二区| 久久久不卡影院| 丁香天五香天堂综合| 久久久天堂av| 风间由美一区二区av101| 国产欧美一区二区精品忘忧草| 精彩视频一区二区| 精品国产青草久久久久福利| 免费三级欧美电影| 精品久久久久久久久久久久久久久久久 | 欧美一级高清片在线观看| 亚洲国产精品麻豆| 日韩一区二区三免费高清| 久久激情五月婷婷| 日本一区二区高清| 在线一区二区三区做爰视频网站| 樱花影视一区二区| 在线成人小视频| 国模冰冰炮一区二区| 欧美—级在线免费片| 欧洲av在线精品| 久草在线在线精品观看| 国产亚洲欧美日韩在线一区| 欧美日韩第一区日日骚| 免费人成在线不卡| 国产精品污www在线观看| 在线欧美日韩国产| 久久国产综合精品| 国产精品福利av| 欧美一区二区精品久久911| 成人国产精品免费观看动漫| 亚洲成av人影院在线观看网| 久久婷婷国产综合国色天香| 91久久久免费一区二区| 经典三级视频一区| 精久久久久久久久久久| 亚洲欧美欧美一区二区三区| 日韩一区二区电影在线| 一本一本久久a久久精品综合麻豆 一本一道波多野结衣一区二区 | 成人av网站免费观看| 水野朝阳av一区二区三区| 亚洲色图在线看| 久久精品男人天堂av| 91精品国产综合久久久久久久 | 欧美一级黄色录像| 欧美日韩一卡二卡三卡 | 91片黄在线观看| 成人理论电影网| 国产成人8x视频一区二区| 美女一区二区三区| 三级精品在线观看| 亚洲www啪成人一区二区麻豆| 中文字幕一区二区三区蜜月| 国产日韩欧美制服另类| 久久久久久亚洲综合| 中文av字幕一区| 亚洲人精品午夜| 午夜视频在线观看一区| 亚洲主播在线播放| 欧美aaaaaa午夜精品| 国产毛片精品国产一区二区三区| 久久精品国产在热久久| 久久99在线观看| 丁香婷婷综合激情五月色| 日本精品一级二级| 精品视频在线视频| 亚洲精品在线三区| 成人免费在线视频| 日韩精品一卡二卡三卡四卡无卡| 理论电影国产精品| 成a人片亚洲日本久久| 欧美三区在线视频| 日韩美女在线视频| 一区在线播放视频| 日本成人中文字幕| 91丨九色丨蝌蚪丨老版| 久久久久久麻豆| 综合久久久久综合| 久久精品国产第一区二区三区| 精品综合免费视频观看| 99视频国产精品| 精品久久久久久久久久久院品网| 国产精品大尺度| 国内成人精品2018免费看| 在线观看一区不卡| 中文字幕一区二区不卡| 青青草原综合久久大伊人精品优势| 成人免费高清视频| 精品国产乱码久久久久久1区2区| 亚洲乱码精品一二三四区日韩在线| 视频一区视频二区中文字幕| 波多野结衣中文字幕一区| 日韩欧美一级二级三级 | 久久综合九色欧美综合狠狠| 亚洲一区二区成人在线观看| 高清国产一区二区三区| 国产三级精品三级| 国产麻豆9l精品三级站| 欧美不卡激情三级在线观看| 午夜电影久久久| 欧美精品在线视频| 日韩成人精品在线| 91精品国产色综合久久不卡蜜臀| 一区二区欧美视频|