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


TypeScript iterator.INextIterator类代码示例

本文整理汇总了TypeScript中vs/base/common/iterator.INextIterator的典型用法代码示例。如果您正苦于以下问题:TypeScript INextIterator类的具体用法?TypeScript INextIterator怎么用?TypeScript INextIterator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: onRefreshItems

	// Ordered, but not necessarily contiguous items
	public onRefreshItems(iterator: INextIterator<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:AllureFer,项目名称:vscode,代码行数:35,代码来源:treeViewModel.ts

示例2: onInsertItems

	public onInsertItems(iterator: INextIterator<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 undefined;
			}

			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:SeanKilleen,项目名称:vscode,代码行数:54,代码来源:treeViewModel.ts

示例3: onRemoveItems

	// Contiguous items
	public onRemoveItems(iterator: INextIterator<string>): void {
		let itemId: string;
		let viewItem: IViewItem;
		let startIndex: number = null;
		let i: number;
		let 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.view.id] = i;
			this.onRefreshItem(viewItem);
		}
	}
开发者ID:burhandodhy,项目名称:azuredatastudio,代码行数:39,代码来源:heightMap.ts


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