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


TypeScript collections.LinkedList类代码示例

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


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

示例1: it

 it('should initialize a list from an iterable', () => {
   let list1 = LinkedList.from([0, 1, 2, 3]);
   let list2 = LinkedList.from(list1);
   expect(list2.isEmpty).to.equal(false);
   expect(list2.length).to.equal(4);
   expect(list2.first).to.equal(0);
   expect(list2.last).to.equal(3);
   expect(toArray(list2)).to.deep.equal([0, 1, 2, 3]);
 });
开发者ID:afshin,项目名称:phosphor,代码行数:9,代码来源:linkedlist.spec.ts

示例2: runMessageLoop

  /**
   * Run an iteration of the message loop.
   *
   * This will process all pending messages in the queue. If a message
   * is added to the queue while the message loop is running, it will
   * be processed on the next cycle of the loop.
   */
  function runMessageLoop(): void {
    // Clear the task ID so the next loop can be scheduled.
    loopTaskID = 0;

    // If the message queue is empty, there is nothing else to do.
    if (messageQueue.isEmpty) {
      return;
    }

    // Add a sentinel value to the end of the queue. The queue will
    // only be processed up to the sentinel. Messages posted during
    // this cycle will execute on the next cycle.
    let sentinel: PostedMessage = { handler: null, msg: null };
    messageQueue.addLast(sentinel);

    // Enter the message loop.
    while (true) {
      // Remove the first posted message in the queue.
      let posted = messageQueue.removeFirst()!;

      // If the value is the sentinel, exit the loop.
      if (posted === sentinel) {
        return;
      }

      // Dispatch the message if it has not been cleared.
      if (posted.handler && posted.msg) {
        sendMessage(posted.handler, posted.msg);
      }
    }
  }
开发者ID:rlugojr,项目名称:phosphor,代码行数:38,代码来源:index.ts

示例3: enqueueMessage

  /**
   * Add a message to the end of the message queue.
   *
   * This will automatically schedule a run of the message loop.
   */
  function enqueueMessage(handler: IMessageHandler, msg: Message): void {
    // Add the posted message to the queue.
    messageQueue.addLast({ handler, msg });

    // Bail if a loop task is already pending.
    if (loopTaskID !== 0) {
      return;
    }

    // Schedule a run of the message loop.
    loopTaskID = schedule(runMessageLoop);
  }
开发者ID:rlugojr,项目名称:phosphor,代码行数:17,代码来源:index.ts


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