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


TypeScript Vector.at方法代码示例

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


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

示例1: moveItem

 /**
  * Move an item in the list from one index to another.
  *
  * @param fromIndex - The initial index of the item. This must be
  *   an integer in the range `[0, internal.length)`.
  *
  * @param toIndex - The desired index for the item. This must be
  *   an integer in the range `[0, internal.length)`.
  *
  * @returns `true` if the item was moved, `false` otherwise.
  *
  * #### Notes
  * This may be reimplemented by subclasses to customize the behavior.
  */
 protected moveItem(fromIndex: number, toIndex: number): boolean {
   let before = this.internal.at(toIndex);
   move(this.internal, fromIndex, toIndex);
   let after = this.internal.at(toIndex);
   if (before === after) {
     return;
   }
   this.changed.emit({
     type: 'move',
     newIndex: toIndex,
     newValue: after,
     oldIndex: fromIndex,
     oldValue: after,
   });
   return true;
 }
开发者ID:TypeFox,项目名称:jupyterlab,代码行数:30,代码来源:observablelist.ts

示例2: setItem

 /**
  * Set the item at a specific index in the list.
  *
  * @param index - The index of interest. This must be an integer in
  *   the range `[0, internal.length)`.
  *
  * @param item - The item to set at the index.
  *
  * @returns The item which previously occupied the specified index.
  *
  * #### Notes
  * This may be reimplemented by subclasses to customize the behavior.
  */
 protected setItem(index: number, item: T): T {
   let old = this.internal.at(index);
   this.internal.set(index, item);
   this.changed.emit({
     type: 'set',
     newIndex: index,
     newValue: item,
     oldIndex: index,
     oldValue: old,
   });
   return old;
 }
开发者ID:TypeFox,项目名称:jupyterlab,代码行数:25,代码来源:observablelist.ts

示例3: get

 /**
  * Get the item at a specific index in the list.
  *
  * @param index - The index of the item of interest. If this is
  *   negative, it is offset from the end of the list.
  *
  * @returns The item at the specified index, or `undefined` if the
  *   index is out of range.
  */
 get(index: number): T {
   return this.internal.at(this._norm(index));
 }
开发者ID:TypeFox,项目名称:jupyterlab,代码行数:12,代码来源:observablelist.ts


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