當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript IIterator.next方法代碼示例

本文整理匯總了TypeScript中vs/base/common/iterator.IIterator.next方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript IIterator.next方法的具體用法?TypeScript IIterator.next怎麽用?TypeScript IIterator.next使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在vs/base/common/iterator.IIterator的用法示例。


在下文中一共展示了IIterator.next方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: onRefreshItems

	// Ordered, but not necessarily contiguous items
	public onRefreshItems(iterator: IIterator<Item>): void {
		var item: Item;
		var viewItem: IViewItem;
		var newHeight: number;
		var i: number, j:number = null;
		var cummDiff = 0;

		while (item = iterator.next()) {
			i = this.indexes[item.id];

			for (; cummDiff !== 0 && j !== null && j < i; j++) {
				viewItem = this.heightMap[j];
				viewItem.top += cummDiff;
				this.onRefreshItem(viewItem);
			}

			viewItem = this.heightMap[i];
			newHeight = item.getHeight();
			viewItem.top += cummDiff;
			cummDiff += newHeight - viewItem.height;
			viewItem.height = newHeight;
			this.onRefreshItem(viewItem, true);

			j = i + 1;
		}

		if (cummDiff !== 0 && j !== null) {
			for (; j < this.heightMap.length; j++) {
				viewItem = this.heightMap[j];
				viewItem.top += cummDiff;
				this.onRefreshItem(viewItem);
			}
		}
	}
開發者ID:1Hgm,項目名稱:vscode,代碼行數:35,代碼來源:treeViewModel.ts

示例2: onInsertItems

	public onInsertItems(iterator: IIterator<Item>, afterItemId: string = null): number {
		var item: Item;
		var viewItem: IViewItem;
		var i: number, j: number;
		var totalSize: number;
		var sizeDiff = 0;

		if (afterItemId === null) {
			i = 0;
			totalSize = 0;
		} else {
			i = this.indexes[afterItemId] + 1;
			viewItem = this.heightMap[i - 1];

			if (!viewItem) {
				console.error('view item doesnt exist');
				return;
			}

			totalSize = viewItem.top + viewItem.height;
		}

		var boundSplice = this.heightMap.splice.bind(this.heightMap, i, 0);

		var itemsToInsert: IViewItem[] = [];

		while (item = iterator.next()) {
			viewItem = this.createViewItem(item);
			viewItem.top = totalSize + sizeDiff;
			this.emit('viewItem:create', { item: viewItem.model });

			this.indexes[item.id] = i++;
			itemsToInsert.push(viewItem);
			sizeDiff += viewItem.height;
		}

		boundSplice.apply(this.heightMap, itemsToInsert);

		for (j = i; j < this.heightMap.length; j++) {
			viewItem = this.heightMap[j];
			viewItem.top += sizeDiff;
			this.indexes[viewItem.model.id] = j;
		}

		for (j = itemsToInsert.length - 1; j >= 0; j--) {
			this.onInsertItem(itemsToInsert[j]);
		}

		for (j = this.heightMap.length - 1; j >= i; j--) {
			this.onRefreshItem(this.heightMap[j]);
		}

		return sizeDiff;
	}
開發者ID:1Hgm,項目名稱:vscode,代碼行數:54,代碼來源:treeViewModel.ts

示例3: onRemoveItems

	// Contiguous items
	public onRemoveItems(iterator: IIterator<string>): void {
		var itemId: string;
		var viewItem: IViewItem;
		var startIndex: number = null;
		var i: number;
		var sizeDiff = 0;

		while (itemId = iterator.next()) {
			i = this.indexes[itemId];
			viewItem = this.heightMap[i];

			if (!viewItem) {
				console.error('view item doesnt exist');
				return;
			}

			sizeDiff -= viewItem.height;
			delete this.indexes[itemId];
			this.onRemoveItem(viewItem);

			if (startIndex === null) {
				startIndex = i;
			}
		}

		if (sizeDiff === 0) {
			return;
		}

		this.heightMap.splice(startIndex, i - startIndex + 1);

		for (i = startIndex; i < this.heightMap.length; i++) {
			viewItem = this.heightMap[i];
			viewItem.top += sizeDiff;
			this.indexes[viewItem.model.id] = i;
			this.onRefreshItem(viewItem);
		}
	}
開發者ID:1Hgm,項目名稱:vscode,代碼行數:39,代碼來源:treeViewModel.ts


注:本文中的vs/base/common/iterator.IIterator.next方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。