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


TypeScript Vector.removeAt方法代碼示例

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


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

示例1: removeItem

 /**
  * Remove the item from the list at the specified index.
  *
  * @param index - The index of the item to remove. This must be
  *   an integer in the range `[0, internal.length)`.
  *
  * @returns The item removed from the list.
  *
  * #### Notes
  * This may be reimplemented by subclasses to customize the behavior.
  */
 protected removeItem(index: number): T {
   let item = this.internal.removeAt(index);
   this.changed.emit({
     type: 'remove',
     newIndex: -1,
     newValue: void 0,
     oldIndex: index,
     oldValue: item,
   });
   return item;
 }
開發者ID:TypeFox,項目名稱:jupyterlab,代碼行數:22,代碼來源:observablelist.ts

示例2: replaceItems

  /**
   * Replace items at a specific location in the list.
   *
   * @param index - The index at which to modify the list. This must
   *   be an integer in the range `[0, internal.length]`.
   *
   * @param count - The number of items to remove from the list. This
   *   must be an integer in the range `[0, internal.length]`.
   *
   * @param items - The items to insert at the specified index.
   *
   * @returns An array of the items removed from the list.
   *
   * #### Notes
   * This may be reimplemented by subclasses to customize the behavior.
   */
  protected replaceItems(index: number, count: number, items: T[]): T[] {
    let old: T[] = [];
    while (count-- > 0) {
      old.push(this.internal.removeAt(index));
    }

    let i = index;
    let j = 0;
    let len = items.length;
    while (j < len) {
      this.internal.insert(i++, items[j++]);
    }
    this.changed.emit({
      type: 'replace',
      newIndex: index,
      newValue: items,
      oldIndex: index,
      oldValue: old,
    });
    return old;
  }
開發者ID:TypeFox,項目名稱:jupyterlab,代碼行數:37,代碼來源:observablelist.ts


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